-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson_man.h
More file actions
62 lines (50 loc) · 1.22 KB
/
json_man.h
File metadata and controls
62 lines (50 loc) · 1.22 KB
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
57
58
59
60
61
62
#ifndef JSON_MAN_H_
#define JSON_MAN_H_
#include <string.h>
#include "json/json.h"
class JsonMan
{
public:
JsonMan():ready_(false){}
~JsonMan(){}
bool isAvail()
{
return ready_;
}
bool set(const std::string& data);
void operator>>(std::string& jsonstr);
void operator<<(const std::string& jsonstr);
/** \brief Experimental and untested: represents a "path" to access a node.
*
* Syntax:
* - "." => root node
* - ".[n]" => elements at index 'n' of root node (an array value)
* - ".name" => member named 'name' of root node (an object value)
* - ".name1.name2.name3"
* - ".[0][1][2].name1[3]"
* - ".%" => member name is provided as parameter
* - ".[%]" => index is provied as parameter
*/
/*
* return:
* 0 success
* -1 path not found
* -2 check consistency failed
* -3 unavailable new_data
*/
int update(const std::string& path,const std::string& new_data,const std::string& old_data);
/*
* return:
* 0 success
* -1 path not found
*/
int getSub(const std::string& path,std::string& cfg);
private:
//Json::Value& get(const std::string& path);
void get(const std::string& path,Json::Value& v);
private:
//std::string m_data;
Json::Value root_;
bool ready_;
};
#endif