blob: d1d79385c63d9462dc331012d714a311422df258 (
plain) (
blame)
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
|
#include <cstddef>
#include <map>
#include <memory>
#include <string>
namespace TehJSON
{
class JSON
{
public:
JSON();
JSON(const JSON& other) = default;
~JSON();
// Leaf methods
template <typename T>
T& get();
template <typename T>
void set(T value);
std::string leafType();
std::string getSerialized();
std::string _getSerialized(int currIndent);
template <typename T>
static std::string serializeData(std::shared_ptr<void> data);
// Non leaf methods
JSON& operator[](std::string name);
size_t childCount();
// std::vector<std::string> childNames();
private:
bool isLeaf = false;
// Leaf data fields
std::shared_ptr<void> data;
std::string (*dataSerializer)(std::shared_ptr<void>);
// Not leaf data fields
std::map<std::string, JSON> children;
};
}
|