20 #include <Poco/Poco.h>
21 #include <Poco/JSON/Object.h>
29 enum NymphInternalTypes {
30 NYMPH_TYPE_NULL = 0x00,
31 NYMPH_TYPE_NONE = 0x01,
32 NYMPH_TYPE_BOOLEAN_FALSE = 0x02,
33 NYMPH_TYPE_BOOLEAN_TRUE = 0x03,
34 NYMPH_TYPE_UINT8 = 0x04,
35 NYMPH_TYPE_SINT8 = 0x05,
36 NYMPH_TYPE_UINT16 = 0x06,
37 NYMPH_TYPE_SINT16 = 0x07,
38 NYMPH_TYPE_UINT32 = 0x08,
39 NYMPH_TYPE_SINT32 = 0x09,
40 NYMPH_TYPE_UINT64 = 0x0a,
41 NYMPH_TYPE_SINT64 = 0x0b,
42 NYMPH_TYPE_FLOAT = 0x0c,
43 NYMPH_TYPE_DOUBLE = 0x0d,
44 NYMPH_TYPE_ARRAY = 0x0e,
45 NYMPH_TYPE_EMPTY_STRING = 0x0f,
46 NYMPH_TYPE_STRING = 0x10,
47 NYMPH_TYPE_STRUCT = 0x11,
48 NYMPH_TYPE_VOID = 0x12,
49 NYMPH_TYPE_BLOB = 0x13
81 inline uint8_t getUInt8(std::string* binary,
int &index) {
82 return (uint8_t) (*binary)[index++];
86 inline uint16_t getUInt16(std::string* binary,
int &index) {
87 uint16_t val = *((uint16_t*) &((*binary)[index]));
93 inline uint32_t getUInt32(std::string* binary,
int &index) {
94 uint32_t val = *((uint32_t*) &((*binary)[index]));
100 inline uint64_t getUInt64(std::string* binary,
int &index) {
101 uint64_t val = *((uint64_t*) &((*binary)[index]));
107 inline int8_t getSInt8(std::string* binary,
int &index) {
108 return (int8_t) (*binary)[index++];
112 inline int16_t getSInt16(std::string* binary,
int &index) {
113 int16_t val = *((int16_t*) &((*binary)[index]));
119 inline int32_t getSInt32(std::string* binary,
int &index) {
120 int32_t val = *((int32_t*) &((*binary)[index]));
126 inline int64_t getSInt64(std::string* binary,
int &index) {
127 int64_t val = *((int64_t*) &((*binary)[index]));
138 virtual NymphTypes type() = 0;
139 virtual std::string toString(
bool quotes =
false) = 0;
140 virtual std::string serialize() = 0;
141 virtual bool deserialize(std::string* binary,
int &index) = 0;
142 virtual bool empty() = 0;
143 virtual uint32_t binarySize() = 0;
146 inline NymphType::~NymphType() {}
159 NymphTypes type() {
return NYMPH_NULL; }
160 std::string toString(
bool quotes =
false) {
return std::string(); }
161 std::string serialize() {
return std::string(); }
162 bool deserialize(std::string* binary,
int &index) {
return true; }
163 bool empty() {
return true; }
164 uint32_t binarySize() {
return 0; }
169 std::vector<NymphType*> values;
176 NymphTypes type() {
return NYMPH_ARRAY; }
177 std::string toString(
bool quotes =
false);
178 std::vector<NymphType*> getValues() {
return values; }
180 std::string serialize();
181 bool deserialize(std::string* binary,
int &index);
182 bool empty() {
return isEmpty; }
183 uint32_t binarySize() {
return (10 + binSize); }
193 NymphBoolean(std::string* value,
int &index) { deserialize(value, index); }
195 NymphTypes type() {
return NYMPH_BOOL; }
196 std::string toString(
bool quotes =
false);
197 void setValue(
bool value);
199 std::string serialize();
200 bool deserialize(std::string* binary,
int &index);
201 bool empty() {
return isEmpty; }
202 uint32_t binarySize() {
return 1; }
211 NymphUint8(uint8_t value) { this->value = value; }
212 NymphUint8(std::string* value,
int &index) { deserialize(value, index); }
213 NymphTypes type() {
return NYMPH_UINT8; }
214 std::string toString(
bool quotes =
false);
215 void setValue(uint8_t value) { this->value = value; isEmpty =
false; }
216 uint8_t getValue() {
return value; }
217 std::string serialize();
218 bool deserialize(std::string* binary,
int &index);
219 bool empty() {
return isEmpty; }
220 uint32_t binarySize() {
return 2; }
229 NymphSint8(int8_t value) { this->value = value; }
230 NymphSint8(std::string* value,
int &index) { deserialize(value, index); }
231 NymphTypes type() {
return NYMPH_SINT8; }
232 std::string toString(
bool quotes =
false);
233 void setValue(int8_t value);
234 int8_t getValue() {
return value; }
235 std::string serialize();
236 bool deserialize(std::string* binary,
int &index);
237 bool empty() {
return isEmpty; }
238 uint32_t binarySize() {
return 2; }
247 NymphUint16(uint16_t value) { this->value = value; }
248 NymphUint16(std::string* value,
int &index) { deserialize(value, index); }
249 NymphTypes type() {
return NYMPH_UINT16; }
250 std::string toString(
bool quotes =
false);
251 void setValue(uint16_t value) { this->value = value; isEmpty =
false; }
252 uint16_t getValue() {
return value; }
253 std::string serialize();
254 bool deserialize(std::string* binary,
int &index);
255 bool empty() {
return isEmpty; }
256 uint32_t binarySize() {
return 3; }
265 NymphSint16(int16_t value) { this->value = value; }
266 NymphSint16(std::string* value,
int &index) { deserialize(value, index); }
267 NymphTypes type() {
return NYMPH_SINT16; }
268 std::string toString(
bool quotes =
false);
269 void setValue(int16_t value) { this->value = value; isEmpty =
false; }
270 int16_t getValue() {
return value; }
271 std::string serialize();
272 bool deserialize(std::string* binary,
int &index);
273 bool empty() {
return isEmpty; }
274 uint32_t binarySize() {
return 3; }
283 NymphUint32(uint32_t value) { this->value = value; }
284 NymphUint32(std::string* value,
int &index) { deserialize(value, index); }
285 NymphTypes type() {
return NYMPH_UINT32; }
286 std::string toString(
bool quotes =
false);
287 void setValue(uint32_t value) { this->value = value; isEmpty =
false; }
288 uint32_t getValue() {
return value; }
289 std::string serialize();
290 bool deserialize(std::string* binary,
int &index);
291 bool empty() {
return isEmpty; }
292 uint32_t binarySize() {
return 5; }
301 NymphSint32(int32_t value) { this->value = value; }
302 NymphSint32(std::string* value,
int &index) { deserialize(value, index); }
303 NymphTypes type() {
return NYMPH_SINT32; }
304 std::string toString(
bool quotes =
false);
305 void setValue(int32_t value) { this->value = value; isEmpty =
false; }
306 int32_t getValue() {
return value; }
307 std::string serialize();
308 bool deserialize(std::string* binary,
int &index);
309 bool empty() {
return isEmpty; }
310 uint32_t binarySize() {
return 5; }
319 NymphUint64(uint64_t value) { this->value = value; }
320 NymphUint64(std::string* value,
int &index) { deserialize(value, index); }
321 NymphTypes type() {
return NYMPH_UINT64; }
322 std::string toString(
bool quotes =
false);
323 void setValue(int64_t value) { this->value = value; isEmpty =
false; }
324 uint64_t getValue() {
return value; }
325 std::string serialize();
326 bool deserialize(std::string* binary,
int &index);
327 bool empty() {
return isEmpty; }
328 uint32_t binarySize() {
return 9; }
337 NymphSint64(int64_t value) { this->value = value; }
338 NymphSint64(std::string* value,
int &index) { deserialize(value, index); }
339 NymphTypes type() {
return NYMPH_SINT64; }
340 std::string toString(
bool quotes =
false);
341 void setValue(int64_t value) { this->value = value; isEmpty =
false; }
342 int64_t getValue() {
return value; }
343 std::string serialize();
344 bool deserialize(std::string* binary,
int &index);
345 bool empty() {
return isEmpty; }
346 uint32_t binarySize() {
return 9; }
356 NymphDouble(std::string* value,
int &index) { deserialize(value, index); }
357 NymphTypes type() {
return NYMPH_DOUBLE; }
358 std::string toString(
bool quotes =
false);
359 std::string serialize();
360 bool deserialize(std::string* binary,
int &index);
361 bool empty() {
return isEmpty; }
362 void setValue(
double value) { this->value = value; }
363 double getValue() {
return value; }
364 uint32_t binarySize() {
return 9; }
373 NymphFloat(
float value) { this->value = value; }
374 NymphFloat(std::string* value,
int &index) { deserialize(value, index); }
375 NymphTypes type() {
return NYMPH_FLOAT; }
376 std::string toString(
bool quotes =
false);
377 std::string serialize();
378 bool deserialize(std::string* binary,
int &index);
379 bool empty() {
return isEmpty; }
380 void setValue(
float value) { this->value = value; }
381 float getValue() {
return value; }
382 uint32_t binarySize() {
return 5; }
393 NymphString() { isEmpty =
true; emptyString =
true; binSize = 0; }
395 NymphString(std::string* value,
int &index) { deserialize(value, index); }
396 NymphTypes type() {
return NYMPH_STRING; }
397 std::string toString(
bool quotes =
false);
398 std::string serialize();
399 bool deserialize(std::string* binary,
int &index);
400 bool empty() {
return isEmpty; }
401 void setValue(std::string value);
402 std::string getValue() {
return value; }
403 void setEmptyString(
bool val =
true) { isEmpty =
false; emptyString = val; }
404 uint32_t binarySize() {
return binSize; }
409 std::map<std::string, NymphPair> pairs;
416 NymphTypes type() {
return NYMPH_STRUCT; }
417 std::string toString(
bool quotes =
false);
418 std::string serialize();
419 bool deserialize(std::string* binary,
int &index);
420 bool empty() {
return isEmpty; }
421 void addPair(std::string key,
NymphType* value);
422 bool getValue(std::string key,
NymphType* &value);
423 uint32_t binarySize() {
return binSize; }
433 NymphBlob() { isEmpty =
true; binSize = 0; }
435 NymphBlob(std::string* value,
int &index) { deserialize(value, index); }
436 NymphTypes type() {
return NYMPH_BLOB; }
437 std::string toString(
bool quotes =
false);
438 std::string serialize();
439 bool deserialize(std::string* binary,
int &index);
440 bool empty() {
return isEmpty; }
441 void setValue(std::string value);
442 std::string getValue() {
return value; }
443 uint32_t binarySize() {
return binSize; }
Definition: nymph_types.h:168
Definition: nymph_types.h:427
Definition: nymph_types.h:187
Definition: nymph_types.h:350
Definition: nymph_types.h:368
Definition: nymph_types.h:157
Definition: nymph_types.h:260
Definition: nymph_types.h:296
Definition: nymph_types.h:332
Definition: nymph_types.h:224
Definition: nymph_types.h:386
Definition: nymph_types.h:408
Definition: nymph_types.h:133
Definition: nymph_types.h:242
Definition: nymph_types.h:278
Definition: nymph_types.h:314
Definition: nymph_types.h:206
Definition: nymph_types.h:151