Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
archiver.h
Go to the documentation of this file.
1#ifndef ARCHIVER_H_
2#define ARCHIVER_H_
3
4#include <cstddef>
5#include <string>
6
16
19
22
25
28
32
35
38
45
48
51
57public:
59
63 JsonReader(const char* json);
64
67
68 // Archive concept
69
70 operator bool() const { return !mError; }
71
73 JsonReader& Member(const char* name);
74 bool HasMember(const char* name) const;
76
77 JsonReader& StartArray(size_t* size = 0);
79
80 JsonReader& operator&(bool& b);
81 JsonReader& operator&(unsigned& u);
82 JsonReader& operator&(int& i);
83 JsonReader& operator&(double& d);
84 JsonReader& operator&(std::string& s);
85
87
88 static const bool IsReader = true;
89 static const bool IsWriter = !IsReader;
90
91private:
92 JsonReader(const JsonReader&);
93 JsonReader& operator=(const JsonReader&);
94
95 void Next();
96
97 // PIMPL
98 void* mDocument;
99 void* mStack;
100 bool mError;
101};
102
104public:
106 JsonWriter();
107
109 ~JsonWriter();
110
112 const char* GetString() const;
113
114 // Archive concept
115
116 operator bool() const { return true; }
117
119 JsonWriter& Member(const char* name);
120 bool HasMember(const char* name) const;
122
123 JsonWriter& StartArray(size_t* size = 0);
125
126 JsonWriter& operator&(bool& b);
127 JsonWriter& operator&(unsigned& u);
128 JsonWriter& operator&(int& i);
129 JsonWriter& operator&(double& d);
130 JsonWriter& operator&(std::string& s);
132
133 static const bool IsReader = false;
134 static const bool IsWriter = !IsReader;
135
136private:
137 JsonWriter(const JsonWriter&);
138 JsonWriter& operator=(const JsonWriter&);
139
140 // PIMPL idiom
141 void* mWriter;
142 void* mStream;
143};
144
145#endif // ARCHIVER_H__
std::string name
Represents a JSON reader which implements Archiver concept.
Definition archiver.h:56
JsonReader & EndArray()
Definition archiver.cpp:109
bool HasMember(const char *name) const
Definition archiver.cpp:83
~JsonReader()
Destructor.
Definition archiver.cpp:42
JsonReader & StartArray(size_t *size=0)
Definition archiver.cpp:89
JsonReader(const char *json)
Constructor.
Definition archiver.cpp:31
static const bool IsReader
Definition archiver.h:88
JsonReader & EndObject()
Definition archiver.cpp:58
JsonReader & operator&(bool &b)
Definition archiver.cpp:119
JsonReader & Member(const char *name)
Definition archiver.cpp:68
static const bool IsWriter
Definition archiver.h:89
JsonReader & SetNull()
Definition archiver.cpp:179
JsonReader & StartObject()
Definition archiver.cpp:48
JsonWriter & operator&(bool &b)
Definition archiver.cpp:261
JsonWriter & SetNull()
Definition archiver.cpp:286
static const bool IsReader
Definition archiver.h:133
JsonWriter & Member(const char *name)
Definition archiver.cpp:240
const char * GetString() const
Obtains the serialized JSON string.
Definition archiver.cpp:226
static const bool IsWriter
Definition archiver.h:134
JsonWriter & StartArray(size_t *size=0)
Definition archiver.cpp:251
JsonWriter & EndObject()
Definition archiver.cpp:235
JsonWriter & EndArray()
Definition archiver.cpp:256
JsonWriter()
Constructor.
Definition archiver.cpp:216
~JsonWriter()
Destructor.
Definition archiver.cpp:221
JsonWriter & StartObject()
Definition archiver.cpp:230
bool HasMember(const char *name) const
Definition archiver.cpp:245
char * s