11 #ifndef __UT_JSONValue__ 
   12 #define __UT_JSONValue__ 
  162                                 bool record_source_offsets = 
false);
 
  165     bool         parseValue(std::istream& is);
 
  169     bool         loadFromFile(
const char* file_name,
 
  170                                 bool record_source_offsets = 
false);
 
  173     bool         saveToFile(
const char* file_name,
 
  192         return !isMap() && !isArray();
 
  254                 result = myData.myInt != 0;
 
  257                 result = myData.myReal != 0;
 
  270                 result = myData.myBool ? 1 : 0;
 
  289                 result = myData.myBool ? 1. : 0.;
 
  318     template <
typename T>
 
  324                     return  myType == JSON_REAL || myType == JSON_INT ||
 
  331     void         setBool(
bool v);
 
  339                     { setStringType(s, 
length, JSON_STRING); }
 
  341                     { setStringType(s, JSON_STRING); }
 
  345                     { setStringType(s, 
length, JSON_KEY); }
 
  347                     { setStringType(s, JSON_KEY); }
 
  384     bool         setUniformArray(
int nvalues, 
const int32 *
data);
 
  385     bool         setUniformArray(
int nvalues, 
const int64 *
data);
 
  386     bool         setUniformArray(
int nvalues, 
const fpreal16 *
data);
 
  387     bool         setUniformArray(
int nvalues, 
const fpreal32 *
data);
 
  388     bool         setUniformArray(
int nvalues, 
const fpreal64 *
data);
 
  394                          { 
return myMapIndex; }
 
  401                          { 
return mySourceLine; }
 
  403                          { 
return mySourceOffset; }
 
  405                          { mySourceLine = line; mySourceOffset = 
offset; }
 
  478                 myCurrArrayPos = myNumArrayEntries = 0;
 
  488                             myValue = src.myValue;
 
  489                             myIsValid = src.myIsValid;
 
  490                             myCurrArrayPos = src.myCurrArrayPos;
 
  491                             myNumArrayEntries = src.myNumArrayEntries;
 
  492                             myValueType =  src.myValueType;
 
  493                             myMapKeys = src.myMapKeys;
 
  503                 return myCurrArrayPos == rhs.myCurrArrayPos
 
  504                        && myIsValid == rhs.myIsValid;
 
  508                 return !(*
this == rhs);
 
  526             bool        atEnd()
 const   { 
return !myIsValid; }
 
  529                             if(myValue && myIsValid)
 
  531                                 if(myValueType == JSON_MAP)
 
  534                                     if(myCurrArrayPos >= myMapKeys.entries())
 
  537                                 else if(myValueType == JSON_ARRAY)
 
  540                                     if(myCurrArrayPos >= myNumArrayEntries)
 
  555                 if (myValue && myIsValid)
 
  556                     return iteratorValue();
 
  561                 if (myValue && myIsValid)
 
  567                 if (myValue && myIsValid
 
  568                         && (myValueType == JSON_ARRAY || myValueType == JSON_MAP))
 
  570                     return myCurrArrayPos;
 
  588                 if (!getLowerCaseKey(tmp))
 
  596                 if(myValue && myIsValid)
 
  598                     if(myValueType == JSON_MAP)
 
  600                         key = myMapKeys(myCurrArrayPos);
 
  631                  myNumArrayEntries = 0;
 
  635                  : myValue(value_in), myIsValid(false), myCurrArrayPos(start_idx)
 
  637                  myNumArrayEntries = 0;
 
  647             int64                myCurrArrayPos;
 
  648             int64                myNumArrayEntries;
 
  660         using pointer = std::pair<exint, UT_JSONValue*>;
 
  668         using traverser::operator++;
 
  669         using traverser::operator==;
 
  670         using traverser::operator!=;
 
  674                  return std::make_pair(
 
  693         using reference = std::tuple<exint, UT_StringHolder, UT_JSONValue&>;
 
  694         using pointer = std::tuple<exint, UT_StringHolder, UT_JSONValue*>;
 
  702         using traverser::operator++;
 
  703         using traverser::operator==;
 
  704         using traverser::operator!=;
 
  710             return std::make_tuple(
 
  717             return std::make_tuple(
 
  723             if (myValue && myIsValid)
 
  725                 if (myValueType == JSON_MAP)
 
  727                     return myMapKeys(myCurrArrayPos);
 
  758         using traverser::operator++;
 
  759         using traverser::operator==;
 
  760         using traverser::operator!=;
 
  767             if (myValue && myIsValid)
 
  769                 if (myValueType == JSON_MAP)
 
  771                     return myMapKeys(myCurrArrayPos);
 
  781     template <
typename IteratorT>
 
  787             return IteratorT(myValue);
 
  791             return IteratorT(myValue, myValue->count());
 
  796             return IteratorT(me->myValue);
 
  798         const IteratorT 
end()
 const 
  801             return IteratorT(me->myValue, me->myValue->
count());
 
  885     std::pair<traverser, bool> 
insert(
 
  890     template <
typename... ARGS>
 
  901     template <
typename... ARGS>
 
  946             const char *key_value);
 
  949             const char *key_value);
 
  962                         { 
return !(*
this == 
src); }
 
  968     void                 setStringType(
const char *
s, 
int64 l, 
Type t);
 
  991 template <std::
size_t N, std::enable_if_t<N == 0, 
int> = 0>
 
  999 template <std::
size_t N, std::enable_if_t<N == 1, 
int> = 0>
 
 1006 template <std::
size_t N, std::enable_if_t<N==0, 
int> = 0>
 
 1010     return it.getArrayIndex();
 
 1013 template <std::
size_t N, std::enable_if_t<N == 1, 
int> = 0>
 
 1020 template <std::
size_t N, std::enable_if_t<N==0, 
int> = 0>
 
 1024     return it.getArrayIndex();
 
 1027 template <std::
size_t N, std::enable_if_t<N == 1, 
int> = 0>
 
 1034 template <std::
size_t N, std::enable_if_t<N == 2, 
int> = 0>
 
 1045     : 
public std::integral_constant<std::size_t, 2>
 
 1048 template <std::
size_t N>
 
 1051     using type = decltype(get<N>(std::declval<UT_JSONValue::map_traverser>()));
 
 1056     : 
public std::integral_constant<std::size_t, 2>
 
 1059 template <std::
size_t N>
 
 1062     using type = decltype(get<N>(std::declval<UT_JSONValue::indexed_traverser>()));
 
 1067     : 
public std::integral_constant<std::size_t, 3>
 
 1070 template <std::
size_t N>
 
 1073     using type = decltype(get<N>(
 
 1074             std::declval<UT_JSONValue::indexed_map_traverser>()));
 
Used to iterate over a map from a json value. 
 
const traverser const_iterator
 
traverser find(const UT_StringRef &key)
 
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects. 
 
SYS_NO_DISCARD_RESULT const_iterator begin() const 
 
#define SYS_DEPRECATED(__V__)
 
const UT_JSONValue & value() const 
 
SYS_NO_DISCARD_RESULT UT_JSONValue * operator()(const UT_StringRef &k)
 
SYS_NO_DISCARD_RESULT traverser begin()
 
bool isNumber() const 
Returns whether the value can be interpreted as a number. 
 
SYS_FORCE_INLINE void clear()
 
GLsizei const GLfloat * value
 
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. 
 
SYS_NO_DISCARD_RESULT const UT_JSONValue * operator()(const UT_StringRef &k) const 
 
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
 
SYS_NO_DISCARD_RESULT UT_JSONValue & operator[](const UT_StringRef &k)
 
std::size_t SYS_HashType
Define the type for hash values. 
 
UT_JSONValueArray * myArray
 
void erase(const UT_StringRef &k)
 
SYS_NO_DISCARD_RESULT int getSourceOffset() const 
 
GLuint GLsizei GLsizei * length
 
map_traverser(UT_JSONValue *v)
 
const UT_StringHolder & key() const 
 
JSON reader class which handles parsing of JSON or bJSON files. 
 
SYS_NO_DISCARD_RESULT bool isMap() const 
 
UT_JSONValue & operator=(const UT_StringHolder &s)
 
Class which writes ASCII or binary JSON streams. 
 
void removeNullValuesRecursive()
 
**But if you need a result
 
bool getLowerCaseKey(UT_StringHolder &key)
Get a lower case map key (for case insensitive maps) 
 
const UT_JSONValue * operator->() const 
 
decltype(get< N >(std::declval< UT_JSONValue::map_traverser >())) type
 
SYS_NO_DISCARD_RESULT traverser beginTraversal()
 
const UT_JSONValue * getValue() const 
 
const UT_JSONValue * operator->() const 
 
indexed_traverser(UT_JSONValue *v, exint end_len)
 
__hostdev__ float getValue(uint32_t i) const 
 
SYS_NO_DISCARD_RESULT UT_JSONValue * operator()(int64 i)
 
bool contains(const UT_StringRef &key) const 
 
SYS_NO_DISCARD_RESULT int getSourceLine() const 
Used by UT_JSONValue parsing from a stream. 
 
SYS_NO_DISCARD_RESULT bool isValueType() const 
 
void setSourceOffset(int line, int offset)
 
SYS_NO_DISCARD_RESULT const_iterator end() const 
 
GLint GLint GLsizei GLint GLenum GLenum type
 
decltype(get< N >(std::declval< UT_JSONValue::indexed_traverser >())) type
 
void setKey(const char *s, int64 length=-1)
 
json_proxy< indexed_traverser > indexed_proxy
 
traverser emplace_back(ARGS &&...args)
Insert a json value to the back of the contained array. 
 
const UT_JSONValue & value() const 
 
const traverser & operator=(const traverser &src)
 
decltype(get< N >(std::declval< UT_JSONValue::indexed_map_traverser >())) type
 
std::pair< traverser, bool > insert(const UT_StringHolder &key, const UT_JSONValue &value)
Add a key/value pair to the contained map. 
 
SYS_NO_DISCARD_RESULT indexed_map_proxy enumerateMap()
 
SYS_NO_DISCARD_RESULT UT_JSONFindResult findParentValueRecursive(const UT_StringHolder &map_key, const char *key_value)
 
static const UT_StringHolder theEmptyString
 
json_proxy< indexed_map_traverser > indexed_map_proxy
 
UT_JSONValue & operator=(fpreal64 v)
 
Traverse the children of the current value. 
 
SYS_NO_DISCARD_RESULT const indexed_proxy enumerate() const 
 
const UT_JSONValue & operator*() const 
 
int64 getArrayIndex() const 
 
indexed_map_traverser(UT_JSONValue *v, exint end_len)
 
traverser(const traverser &src)
 
SYS_NO_DISCARD_RESULT indexed_proxy enumerate()
 
friend class UT_JSONValue
 
#define SYS_NO_DISCARD_RESULT
 
SYS_NO_DISCARD_RESULT bool isArray() const 
 
UT_JSONValue & operator=(const UT_JSONValue &v)
 
std::forward_iterator_tag iterator_category
 
SYS_NO_DISCARD_RESULT SYS_HashType hash() const 
Compute a hash. 
 
UT_JSONValue * operator->()
 
indexed_traverser(UT_JSONValue *v)
 
UT_JSONValue & operator=(int64 v)
 
SYS_NO_DISCARD_RESULT const UT_JSONValue & operator[](int64 i) const 
 
SYS_NO_DISCARD_RESULT const UT_JSONValue * operator()(int64 i) const 
 
bool getKey(UT_StringHolder &key) const 
 
traverser & operator++()
++iterator 
 
void setString(const UT_StringHolder &s)
 
SYS_NO_DISCARD_RESULT UT_JSONValue & operator[](int64 i)
 
const UT_JSONValue & value() const 
 
const UT_StringHolder & key() const 
 
SYS_NO_DISCARD_RESULT const map_proxy items() const 
 
const UT_JSONValue & operator*() const 
 
bool operator==(const traverser &rhs) const 
No post increment as it is harmful. 
 
void setString(const char *s, int64 length=-1)
 
UT_JSONFindResult(UT_JSONValue *v=nullptr, int64 idx=-1)
 
SYS_NO_DISCARD_RESULT int getMapIndex() const 
Used internally by UT_JSONValueMap. 
 
SYS_NO_DISCARD_RESULT exint count() const 
Number of elements contained inside the json value. 
 
SYS_NO_DISCARD_RESULT UT_StringRef toLower() const 
 
SYS_NO_DISCARD_RESULT map_proxy items()
 
GA_API const UT_StringHolder N
 
SYS_NO_DISCARD_RESULT const_iterator cend() const 
 
SYS_NO_DISCARD_RESULT Type getType() const 
Get the type of data stored in the object. 
 
json_proxy< map_traverser > map_proxy
 
Class to store JSON objects as C++ objects. 
 
**If you just want to fire and args
 
UT_JSONValue * getValue()
 
SYS_NO_DISCARD_RESULT bool isNull() const 
 
SYS_NO_DISCARD_RESULT bool operator!=(const UT_JSONValue &src) const 
 
const IteratorT end() const 
 
UT_JSONValue * operator->()
 
bool getKey(UT_String &key)
Deprecated in favour of UT_StringHolder method. 
 
map_traverser(UT_JSONValue *v, exint end_len)
 
UT_JSONValue & operator=(bool v)
 
UT_API size_t format(char *buffer, size_t buffer_size, const UT_JSONValue &v)
 
SYS_NO_DISCARD_RESULT UT_JSONFindResult findValueRecursive(const UT_StringHolder &map_key, const char *key_value)
 
UT_JSONValue & operator*()
 
traverser append(const UT_JSONValue &v)
Insert a json value to the back of the contained array. 
 
SYS_NO_DISCARD_RESULT const UT_StringHolder & getString() const 
 
indexed_map_traverser(UT_JSONValue *v)
 
const IteratorT begin() const 
 
SYS_NO_DISCARD_RESULT const indexed_map_proxy enumerateMap() const 
 
std::pair< traverser, bool > emplace(const UT_StringHolder &key, ARGS &&...args)
Add an entry to the contained map. 
 
void setMapIndex(int i)
Used internally by UT_JSONValueMap. 
 
bool operator!=(const traverser &rhs) const 
 
SYS_NO_DISCARD_RESULT traverser end()
 
SYS_NO_DISCARD_RESULT const_iterator cbegin() const