From d05f9f046565f2d0d4135912103f96f0e66b454f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Sep 2015 15:12:32 +0200 Subject: Add initial database model --- bpkg/package.cxx | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bpkg/package.cxx (limited to 'bpkg/package.cxx') diff --git a/bpkg/package.cxx b/bpkg/package.cxx new file mode 100644 index 0000000..7ffb99d --- /dev/null +++ b/bpkg/package.cxx @@ -0,0 +1,38 @@ +// file : bpkg/package.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include // invalid_argument + +using namespace std; + +namespace bpkg +{ + string + to_string (state s) + { + switch (s) + { + case state::fetched: return "fetched"; + case state::unpacked: return "unpacked"; + case state::configured: return "configured"; + case state::updated: return "updated"; + case state::broken: return "broken"; + } + + return string (); // Should never reach. + } + + state + from_string (const string& s) + { + if (s == "fetched") return state::fetched; + else if (s == "unpacked") return state::unpacked; + else if (s == "configured") return state::configured; + else if (s == "updated") return state::updated; + else if (s == "broken") return state::broken; + else throw invalid_argument (s); + } +} -- cgit v1.1