aboutsummaryrefslogtreecommitdiff
path: root/bpkg/package.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-14 15:12:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-14 15:12:32 +0200
commitd05f9f046565f2d0d4135912103f96f0e66b454f (patch)
tree750c05a010e886de83edc30282476cc36cc1c127 /bpkg/package.cxx
parentf9b9844eabe29250298f8120fa32a3b98c718454 (diff)
Add initial database model
Diffstat (limited to 'bpkg/package.cxx')
-rw-r--r--bpkg/package.cxx38
1 files changed, 38 insertions, 0 deletions
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 <bpkg/package>
+
+#include <stdexcept> // 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);
+ }
+}