-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_types.hpp
56 lines (35 loc) · 1.11 KB
/
json_types.hpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _JSON_TYPES_H_
#define _JSON_TYPES_H_
#include <boost/variant.hpp>
#include <boost/variant/recursive_wrapper.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <map>
#include <vector>
#include <string>
#include <stdexcept>
#include <boost/cstdint.hpp>
namespace json_qi {
struct json_subobject;
struct json_array;
typedef std::string json_string_type;
typedef double json_int_type;
typedef double json_float_type;
typedef boost::variant<
json_string_type
, json_int_type
, json_float_type
, boost::recursive_wrapper<json_subobject>
, boost::recursive_wrapper<json_array> > json_object;
struct json_subobject {
typedef std::map<json_string_type, json_object> object_map;
object_map contents;
json_subobject& operator=(std::map<json_string_type, json_object> m) { contents = m; }
};
struct json_array {
typedef std::vector<json_object> object_list;
object_list contents;
};
}
BOOST_FUSION_ADAPT_STRUCT(json_qi::json_array, (json_qi::json_array::object_list, contents));
BOOST_FUSION_ADAPT_STRUCT(json_qi::json_subobject, (json_qi::json_subobject::object_map, contents));
#endif