summaryrefslogtreecommitdiff
path: root/project2/json/conversion.h
blob: d87546210df44349c58a66b8ee9a9569d9e8bcef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef JSON_CONVERSION_H
#define JSON_CONVERSION_H

#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;
		json::Value operator()(const Boolean & 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::Object &) const;
		VariableType operator()(const json::Array &) const;
		template <class Copyable>
		VariableType operator()(const Copyable & i) const {
			return i;
		}
};

#endif