summaryrefslogtreecommitdiff
path: root/project2/json/conversion.h
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-10-17 19:29:44 +0000
committerrandomdan <randomdan@localhost>2011-10-17 19:29:44 +0000
commit4be487b9a9c0bb93587ed276c43fe3fba3e7c895 (patch)
treed02d1824d0efb520cda0564292500ea7c386ce0c /project2/json/conversion.h
parentAdd some functional variables for date handling and string manipulation (diff)
downloadproject2-4be487b9a9c0bb93587ed276c43fe3fba3e7c895.tar.bz2
project2-4be487b9a9c0bb93587ed276c43fe3fba3e7c895.tar.xz
project2-4be487b9a9c0bb93587ed276c43fe3fba3e7c895.zip
Adds the JSON and CouchDB module
Diffstat (limited to 'project2/json/conversion.h')
-rw-r--r--project2/json/conversion.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/project2/json/conversion.h b/project2/json/conversion.h
new file mode 100644
index 0000000..acd22fb
--- /dev/null
+++ b/project2/json/conversion.h
@@ -0,0 +1,28 @@
+#include "variables.h"
+#include "json.h"
+#include <boost/numeric/conversion/cast.hpp>
+
+class ConversionNotSupported { };
+class Project2ToJson : public boost::static_visitor<json::Value> {
+ public:
+ json::Value operator()(const boost::posix_time::ptime & i) const;
+ json::Value operator()(const Null & c) const;
+ json::Value operator()(const Glib::ustring & c) const;
+ template <class Numeric>
+ json::Value operator()(const Numeric & i) const {
+ return boost::numeric_cast<json::Number>(i);
+ }
+};
+
+class JsonToProject2 : public boost::static_visitor<VariableType> {
+ public:
+ VariableType operator()(const json::Boolean &) const;
+ VariableType operator()(const json::Object &) const;
+ VariableType operator()(const json::Array &) const;
+ template <class Copyable>
+ VariableType operator()(const Copyable & i) const {
+ return i;
+ }
+};
+
+