11 #ifndef __UT_JSONValue__
12 #define __UT_JSONValue__
113 bool record_source_offsets =
false);
118 bool loadFromFile(
const char* file_name,
119 bool record_source_offsets =
false);
122 bool saveToFile(
const char* file_name,
180 result = myData.myInt != 0;
183 result = myData.myReal != 0;
196 result = myData.myBool ? 1 : 0;
215 result = myData.myBool ? 1. : 0.;
247 return myType == JSON_REAL || myType == JSON_INT ||
254 void setBool(
bool v);
262 { setStringType(s,
length, JSON_STRING); }
264 { setStringType(s, JSON_STRING); }
268 { setStringType(s,
length, JSON_KEY); }
270 { setStringType(s, JSON_KEY); }
300 bool setUniformArray(
int nvalues,
const int32 *
data);
301 bool setUniformArray(
int nvalues,
const int64 *
data);
302 bool setUniformArray(
int nvalues,
const fpreal16 *
data);
303 bool setUniformArray(
int nvalues,
const fpreal32 *
data);
304 bool setUniformArray(
int nvalues,
const fpreal64 *
data);
310 {
return myMapIndex; }
317 {
return mySourceLine; }
319 {
return mySourceOffset; }
321 { mySourceLine = line; mySourceOffset =
offset; }
343 myCurrArrayPos = myNumArrayEntries = 0;
353 myValue = src.myValue;
354 myIsValid = src.myIsValid;
355 myCurrArrayPos = src.myCurrArrayPos;
356 myNumArrayEntries = src.myNumArrayEntries;
357 myValueType = src.myValueType;
358 myMapKeys = src.myMapKeys;
366 bool atEnd()
const {
return !myIsValid; }
369 if(myValue && myIsValid)
371 if(myValueType == JSON_MAP)
374 if(myCurrArrayPos >= myMapKeys.entries())
377 else if(myValueType == JSON_ARRAY)
380 if(myCurrArrayPos >= myNumArrayEntries)
395 if(myValue && myIsValid)
397 if(myValueType == JSON_MAP)
399 else if(myValueType == JSON_ARRAY)
420 if (!getLowerCaseKey(tmp))
428 if(myValue && myIsValid)
430 if(myValueType == JSON_MAP)
432 key = myMapKeys(myCurrArrayPos);
464 myNumArrayEntries = 0;
468 myValueType = myValue->getType();
472 if(myValueType == JSON_MAP)
474 if(myValue->getMap()->entries() == 0)
477 myValue->getMap()->getKeys(myMapKeys);
479 else if(myValueType == JSON_ARRAY)
481 if(myValue->getArray()->entries() == 0)
484 myNumArrayEntries = myValue->getArray()->entries();
494 int64 myCurrArrayPos, myNumArrayEntries;
506 const char *key_value);
509 const char *key_value);
522 {
return !(*
this ==
src); }
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
SYS_NO_DISCARD_RESULT UT_JSONValueArray * getArray() const
Get the array value (may return a NULL pointer)
#define SYS_DEPRECATED(__V__)
bool isNumber() const
Returns whether the value can be interpreted as a number.
SYS_NO_DISCARD_RESULT const UT_JSONValue * get(int64 i) const
Access a const entry by index.
SYS_FORCE_INLINE void clear()
void setNull()
Set value to a null.
void setKey(const UT_StringHolder &s)
const GLuint GLenum const void * binary
UT_JSONValueArray stores a list of UT_JSONValue objects.
std::size_t SYS_HashType
Define the type for hash values.
UT_JSONValueArray * myArray
SYS_NO_DISCARD_RESULT int getSourceOffset() const
JSON reader class which handles parsing of JSON or bJSON files.
Class which writes ASCII or binary JSON streams.
void removeNullValuesRecursive()
bool getLowerCaseKey(UT_StringHolder &key)
Get a lower case map key (for case insensitive maps)
SYS_NO_DISCARD_RESULT traverser beginTraversal()
bool atEnd() const
No post increment as it is harmful.
SYS_NO_DISCARD_RESULT int getSourceLine() const
Used by UT_JSONValue parsing from a stream.
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
void setSourceOffset(int line, int offset)
void setKey(const char *s, int64 length=-1)
const traverser & operator=(const traverser &src)
SYS_NO_DISCARD_RESULT UT_JSONValueMap * getMap() const
Get the map value (may return a NULL pointer)
Traverse the children of the current value.
traverser(const traverser &src)
#define SYS_NO_DISCARD_RESULT
UT_JSONValue & operator=(const UT_JSONValue &v)
SYS_NO_DISCARD_RESULT UT_JSONValue * findParentValueRecursive(const UT_StringHolder &map_key, const char *key_value)
SYS_NO_DISCARD_RESULT SYS_HashType hash() const
Compute a hash.
GLuint GLsizei GLsizei * length
traverser & operator++()
++iterator
void setString(const UT_StringHolder &s)
void setString(const char *s, int64 length=-1)
SYS_NO_DISCARD_RESULT int getMapIndex() const
Used internally by UT_JSONValueMap.
SYS_NO_DISCARD_RESULT UT_StringRef toLower() const
SYS_NO_DISCARD_RESULT UT_JSONValue * findValueRecursive(const UT_StringHolder &map_key, const char *key_value)
bool getKey(UT_StringHolder &key)
SYS_NO_DISCARD_RESULT Type getType() const
Get the type of data stored in the object.
Class to store JSON objects as C++ objects.
UT_JSONValue * getValue()
SYS_NO_DISCARD_RESULT bool operator!=(const UT_JSONValue &src) const
SYS_FORCE_INLINE const UT_JSONValue * get(int64 i) const
Access a const entry by index.
void setMapIndex(int i)
Used internally by UT_JSONValueMap.