diff options
Diffstat (limited to 'project2/json/conversion.h')
-rw-r--r-- | project2/json/conversion.h | 28 |
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; + } +}; + + |