FaceModel
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
JsonJig.h
1 //
2 // ConfigReader.h
3 // facemodel
4 //
5 // Created by Georg Ursits on 16/03/14.
6 //
7 //
8 
9 #pragma once
10 
11 #include <json/json.h>
12 #include <string>
13 
14 namespace iyf
15 {
22  class JsonJig
23  {
24  public:
28  enum Mode
29  {
32  };
33 
38  enum Format
39  {
42  };
43 
47  JsonJig();
48 
54  JsonJig(const char* path);
55 
59  ~JsonJig();
60 
67  bool readFromFile(const char* path);
68 
75  bool readFromString(const std::string &json);
76 
83  bool writeToFile(const char* path);
84 
93  bool writeToFile(const char* path, Format format);
94 
100 
107  Json::Value& getValue(const char* path);
108 
117  Json::Value& getValue(const char* path, Json::Value& startRef);
118 
125  void setValue(const char* path, Json::Value &val);
126 
127  private:
128  Json::Value& getValueRecursive(std::string path, Json::Value &curr);
129 
130  Json::Value root;
131  Json::Value *nullValue;
132  };
133 }
JsonJig()
constructs a plain object ready to have values added
Definition: JsonJig.cpp:15
~JsonJig()
properly cleans up
Definition: JsonJig.cpp:27
bool readFromFile(const char *path)
reads a jsonfiles contents
Definition: JsonJig.cpp:32
Definition: JsonJig.h:40
bool writeToFile(const char *path)
writes the currently stored json structure to a file
Definition: JsonJig.cpp:63
Format
enumeration that defines the format the json is going to be written, either if it's minified/compact ...
Definition: JsonJig.h:38
Definition: JsonJig.h:30
Definition: JsonJig.h:31
bool readFromString(const std::string &json)
creates a iyf::JsonJig file from an input string instead from a file read from disk ...
Definition: JsonJig.cpp:51
utility class to help managing typical operations on json files. (loading, manipulating, writing)
Definition: JsonJig.h:22
Json::Value & getRoot()
returns the root node of the json structure currently stored
Definition: JsonJig.cpp:99
Json::Value & getValue(const char *path)
traverses the json and trys to find the Json::Value at the specified path
Definition: JsonJig.cpp:104
Represents a JSON value.
Definition: json.h:435
void setValue(const char *path, Json::Value &val)
stets a json Value at a certain position
Definition: JsonJig.cpp:153
Mode
this enum helps to determine the performed operation wheter the file is going to ber read or written ...
Definition: JsonJig.h:28
Definition: JsonJig.h:41