-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJsonHandler.h
41 lines (31 loc) · 1000 Bytes
/
JsonHandler.h
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
/*
* Title : JsonHandler.h
*/
#ifndef JSON_HANDLER_H_
#define JSON_HANDLER_H_
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <list>
#include <sstream>
#include "Define.h"
namespace pt = boost::property_tree;
class JsonHandler
{
private:
pt::ptree _tree;
std::list<std::string> arrayTypeList;
std::stringstream ss;
public:
//JsonHandler() { initMap(); }
bool readXml(const std::string& filename);
bool readJson(const std::string& filename);
bool writeJson(const std::string& filename);
private:
void initMap();
bool findType(const std::string& name);
void getXmlArray(pt::ptree& pt, const std::string& tname, uint8_t tab);
void getXmlSequence(pt::ptree& pt, const std::string& tname, uint8_t tab);
NodeType getXmlAttrType(pt::ptree& node);
};
#endif /* JSON_HANDLER_H_ */