HDK
|
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects. More...
#include <UT_JSONValueMap.h>
Classes | |
struct | InsertResult |
class | iterator |
Public Types | |
using | const_iterator = const iterator |
Public Member Functions | |
UT_JSONValueMap () | |
~UT_JSONValueMap () | |
void | bumpRef (int d) |
Reference count (for shared maps). More... | |
SYS_NO_DISCARD_RESULT int | getRef () const |
Get the number of references to this map. More... | |
UT_JSONValueMap * | makeUnique () const |
bool | save (UT_JSONWriter &os) const |
Save to an output stream. More... | |
void | dump () const |
Dump to stdout (same as save to std::cout) More... | |
int64 | getKeys (UT_StringArray &keys) const |
Get the list of keys. More... | |
int64 | getKeyReferences (UT_StringArray &keys) const |
SYS_NO_DISCARD_RESULT int64 | entries () const |
Return the number of entries in the map. More... | |
SYS_NO_DISCARD_RESULT int64 | size () const |
void | clear () |
Clear the entries in the map. More... | |
SYS_NO_DISCARD_RESULT const UT_JSONValue * | operator() (int64 i) const |
Access const entry by index. More... | |
SYS_NO_DISCARD_RESULT UT_JSONValue * | operator() (int64 i) |
Access entry by index. More... | |
SYS_NO_DISCARD_RESULT const UT_JSONValue * | operator() (const UT_StringRef &k) const |
Access const entry by name (may be NULL pointer if k is not a key) More... | |
SYS_NO_DISCARD_RESULT UT_JSONValue * | operator() (const UT_StringRef &k) |
Access entry by name (may be NULL pointer if k is not a key) More... | |
SYS_NO_DISCARD_RESULT const UT_JSONValue * | operator[] (int64 i) const |
Access const entry by index. More... | |
SYS_NO_DISCARD_RESULT UT_JSONValue * | operator[] (int64 i) |
Access entry by index. More... | |
SYS_NO_DISCARD_RESULT const UT_JSONValue * | operator[] (const UT_StringRef &k) const |
Access const entry by name (may be NULL pointer if k is not a key) More... | |
SYS_NO_DISCARD_RESULT UT_JSONValue * | operator[] (const UT_StringRef &k) |
Access entry by name (may be NULL pointer if k is not a key) More... | |
SYS_NO_DISCARD_RESULT const UT_JSONValue * | get (int64 i) const |
Access a const entry by index. More... | |
SYS_NO_DISCARD_RESULT UT_JSONValue * | get (int64 i) |
Access an entry by index. More... | |
SYS_NO_DISCARD_RESULT const UT_JSONValue * | get (const UT_StringRef &k) const |
Access const entry by name (may be NULL pointer if k is not a key) More... | |
SYS_NO_DISCARD_RESULT UT_JSONValue * | get (const UT_StringRef &k) |
Access entry by name (may be NULL pointer if k is not a key) More... | |
SYS_NO_DISCARD_RESULT int32 | get (const UT_StringRef &key, int32 def_value) const |
Access entry by name. If not found the default value is returned. More... | |
SYS_NO_DISCARD_RESULT int64 | get (const UT_StringRef &key, int64 def_value) const |
Access entry by name. If not found the default value is returned. More... | |
SYS_NO_DISCARD_RESULT UT_StringHolder | get (const UT_StringRef &key, const UT_StringRef &def_value) const |
Access entry by name. If not found the default value is returned. More... | |
SYS_NO_DISCARD_RESULT UT_StringArray | get (const UT_StringRef &key, const UT_StringArray &def_value) const |
Access entry by name. If not found the default value is returned. More... | |
SYS_NO_DISCARD_RESULT const UT_JSONValueMap * | getObject (const UT_StringRef &k) const |
SYS_NO_DISCARD_RESULT UT_JSONValueMap * | getObject (const UT_StringRef &k) |
SYS_NO_DISCARD_RESULT const UT_JSONValueArray * | getArray (const UT_StringRef &k) const |
SYS_NO_DISCARD_RESULT UT_JSONValueArray * | getArray (const UT_StringRef &k) |
InsertResult | insert (const UT_StringHolder &key, const UT_JSONValue &value) |
template<typename... ARGS> | |
InsertResult | emplace (const UT_StringHolder &key, ARGS &&...args) |
Emplace a value into the map. More... | |
void | remove (const UT_StringHolder &key) |
void | rename (const UT_StringHolder &old_key, const UT_StringHolder &new_key) |
UT_JSONValueArray * | addArrayChild (const UT_StringHolder &map_key) |
Adds a new array child to this map. More... | |
UT_JSONValueMap * | addMapChild (const UT_StringHolder &map_key) |
Adds a new map child to this map. More... | |
template<typename T > | |
bool | import (const UT_StringRef &key, T &result) const |
SYS_NO_DISCARD_RESULT SYS_HashType | hash () const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
SYS_NO_DISCARD_RESULT bool | operator== (const UT_JSONValueMap &arr) const |
SYS_NO_DISCARD_RESULT bool | operator!= (const UT_JSONValueMap &arr) const |
Friends | |
class | iterator |
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
UT_JSONValueMap stores a map of UT_JSONValue objects. Unlike a standard Houdini UT_StringMap, this object maintains the sort order in which objects were added.
Definition at line 37 of file UT_JSONValueMap.h.
using UT_JSONValueMap::const_iterator = const iterator |
Definition at line 260 of file UT_JSONValueMap.h.
UT_JSONValueMap::UT_JSONValueMap | ( | ) |
UT_JSONValueMap::~UT_JSONValueMap | ( | ) |
UT_JSONValueArray* UT_JSONValueMap::addArrayChild | ( | const UT_StringHolder & | map_key | ) |
Adds a new array child to this map.
UT_JSONValueMap* UT_JSONValueMap::addMapChild | ( | const UT_StringHolder & | map_key | ) |
Adds a new map child to this map.
Definition at line 258 of file UT_JSONValueMap.h.
|
inline |
Definition at line 261 of file UT_JSONValueMap.h.
Reference count (for shared maps).
Definition at line 43 of file UT_JSONValueMap.h.
void UT_JSONValueMap::clear | ( | ) |
Clear the entries in the map.
void UT_JSONValueMap::dump | ( | ) | const |
Dump to stdout (same as save to std::cout)
|
inline |
Emplace a value into the map.
Definition at line 163 of file UT_JSONValueMap.h.
Definition at line 259 of file UT_JSONValueMap.h.
|
inline |
Definition at line 262 of file UT_JSONValueMap.h.
|
inline |
Return the number of entries in the map.
Definition at line 71 of file UT_JSONValueMap.h.
|
inline |
Access a const entry by index.
Definition at line 106 of file UT_JSONValueMap.h.
|
inline |
Access an entry by index.
Definition at line 109 of file UT_JSONValueMap.h.
SYS_NO_DISCARD_RESULT const UT_JSONValue* UT_JSONValueMap::get | ( | const UT_StringRef & | k | ) | const |
Access const entry by name (may be NULL pointer if k is not a key)
SYS_NO_DISCARD_RESULT UT_JSONValue* UT_JSONValueMap::get | ( | const UT_StringRef & | k | ) |
Access entry by name (may be NULL pointer if k is not a key)
SYS_NO_DISCARD_RESULT int32 UT_JSONValueMap::get | ( | const UT_StringRef & | key, |
int32 | def_value | ||
) | const |
Access entry by name. If not found the default value is returned.
SYS_NO_DISCARD_RESULT int64 UT_JSONValueMap::get | ( | const UT_StringRef & | key, |
int64 | def_value | ||
) | const |
Access entry by name. If not found the default value is returned.
SYS_NO_DISCARD_RESULT UT_StringHolder UT_JSONValueMap::get | ( | const UT_StringRef & | key, |
const UT_StringRef & | def_value | ||
) | const |
Access entry by name. If not found the default value is returned.
SYS_NO_DISCARD_RESULT UT_StringArray UT_JSONValueMap::get | ( | const UT_StringRef & | key, |
const UT_StringArray & | def_value | ||
) | const |
Access entry by name. If not found the default value is returned.
SYS_NO_DISCARD_RESULT const UT_JSONValueArray* UT_JSONValueMap::getArray | ( | const UT_StringRef & | k | ) | const |
Access const array entry by name (may be NULL pointer if k is not a key) This is a convenience function to get() if we know the key is an array.
SYS_NO_DISCARD_RESULT UT_JSONValueArray* UT_JSONValueMap::getArray | ( | const UT_StringRef & | k | ) |
Access array entry by name (may be NULL pointer if k is not a key) This is a convenience function to get() if we know the key is an array.
int64 UT_JSONValueMap::getKeyReferences | ( | UT_StringArray & | keys | ) | const |
Get a list of the keys. However, rather than duplicating the string values, this method simply keeps shallow references. While it's more efficient, it's also relies on the fact that the map will not change while the string array exists.
int64 UT_JSONValueMap::getKeys | ( | UT_StringArray & | keys | ) | const |
Get the list of keys.
SYS_NO_DISCARD_RESULT const UT_JSONValueMap* UT_JSONValueMap::getObject | ( | const UT_StringRef & | k | ) | const |
Access const object entry by name (may be NULL pointer if k is not a key) This is a convenience function to get() if we know the key is an object.
SYS_NO_DISCARD_RESULT UT_JSONValueMap* UT_JSONValueMap::getObject | ( | const UT_StringRef & | k | ) |
Access object entry by name (may be NULL pointer if k is not a key) This is a convenience function to get() if we know the key is an object.
|
inline |
Get the number of references to this map.
Definition at line 49 of file UT_JSONValueMap.h.
SYS_NO_DISCARD_RESULT SYS_HashType UT_JSONValueMap::hash | ( | ) | const |
bool UT_JSONValueMap::import | ( | const UT_StringRef & | key, |
T & | result | ||
) | const |
Key/Value imports. See UT_JSONValue for all available import types. Returns false if the key isn't in the map, or if the import from the UT_JSONValue fails.
InsertResult UT_JSONValueMap::insert | ( | const UT_StringHolder & | key, |
const UT_JSONValue & | value | ||
) |
Add key/value pair to the map. If the key already exists, the previous value will be deleted.
UT_JSONValueMap* UT_JSONValueMap::makeUnique | ( | ) | const |
Maps are typically stored as shared pointers. This method will make a unique copy. May return "this" (if the reference count is already unique).
|
inline |
Check equality
Definition at line 196 of file UT_JSONValueMap.h.
|
inline |
Access const entry by index.
Definition at line 80 of file UT_JSONValueMap.h.
|
inline |
Access entry by index.
Definition at line 83 of file UT_JSONValueMap.h.
|
inline |
Access const entry by name (may be NULL pointer if k is not a key)
Definition at line 86 of file UT_JSONValueMap.h.
|
inline |
Access entry by name (may be NULL pointer if k is not a key)
Definition at line 89 of file UT_JSONValueMap.h.
SYS_NO_DISCARD_RESULT bool UT_JSONValueMap::operator== | ( | const UT_JSONValueMap & | arr | ) | const |
Check equality
|
inline |
Access const entry by index.
Definition at line 93 of file UT_JSONValueMap.h.
|
inline |
Access entry by index.
Definition at line 96 of file UT_JSONValueMap.h.
|
inline |
Access const entry by name (may be NULL pointer if k is not a key)
Definition at line 99 of file UT_JSONValueMap.h.
|
inline |
Access entry by name (may be NULL pointer if k is not a key)
Definition at line 102 of file UT_JSONValueMap.h.
void UT_JSONValueMap::remove | ( | const UT_StringHolder & | key | ) |
Remove key/value pair from the map. Do nothing if the key does not exist.
void UT_JSONValueMap::rename | ( | const UT_StringHolder & | old_key, |
const UT_StringHolder & | new_key | ||
) |
Rename a key in the map. Do nothing if the old key does not exist. If the old key exists and another entry uses the new key then remove the other entry and rename the entry with the old key.
bool UT_JSONValueMap::save | ( | UT_JSONWriter & | os | ) | const |
Save to an output stream.
|
inline |
Definition at line 73 of file UT_JSONValueMap.h.
Definition at line 269 of file UT_JSONValueMap.h.