HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_JSONValueMap Class Reference

UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects. More...

#include <UT_JSONValueMap.h>

Classes

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...
 
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...
 
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...
 
template<typename T >
SYS_NO_DISCARD_RESULT T getExpected (const UT_StringRef &key) const
 Access entry by name. If not found a json value exception is thrown. 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)
 
int64 append (const UT_StringHolder &key, UT_JSONValue *v)
 
void remove (const UT_StringHolder &key)
 
void rename (const UT_StringHolder &old_key, const UT_StringHolder &new_key)
 
UT_JSONValueArrayaddArrayChild (const UT_StringHolder &map_key)
 Adds a new array child to this map. More...
 
UT_JSONValueMapaddMapChild (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 ()
 
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
 

Detailed Description

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.

See Also
UT_JSONValue, UT_JSONValueArray
Examples:
packedshareddata/GU_PackedSharedData.h, and packedsphere/GU_PackedSphere.h.

Definition at line 44 of file UT_JSONValueMap.h.

Member Typedef Documentation

Constructor & Destructor Documentation

UT_JSONValueMap::UT_JSONValueMap ( )
UT_JSONValueMap::~UT_JSONValueMap ( )

Member Function Documentation

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.

int64 UT_JSONValueMap::append ( const UT_StringHolder key,
UT_JSONValue v 
)

Add key/value pair to the map. If the key already exists, the previous value will be deleted.

iterator UT_JSONValueMap::begin ( void  )
inline

Definition at line 246 of file UT_JSONValueMap.h.

void UT_JSONValueMap::bumpRef ( int  d)
inline

Reference count (for shared maps).

Definition at line 50 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)

iterator UT_JSONValueMap::end ( void  )
inline

Definition at line 247 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT int64 UT_JSONValueMap::entries ( ) const
inline

Return the number of entries in the map.

Definition at line 74 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT const UT_JSONValue* UT_JSONValueMap::get ( int64  i) const
inline

Access a const entry by index.

Examples:
packedshareddata/GU_PackedSharedData.C.

Definition at line 107 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT UT_JSONValue* UT_JSONValueMap::get ( int64  i)
inline

Access an entry by index.

Definition at line 110 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.

template<typename T >
SYS_NO_DISCARD_RESULT T UT_JSONValueMap::getExpected ( const UT_StringRef key) const
inline

Access entry by name. If not found a json value exception is thrown.

Definition at line 127 of file UT_JSONValueMap.h.

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.

SYS_NO_DISCARD_RESULT int UT_JSONValueMap::getRef ( ) const
inline

Get the number of references to this map.

Definition at line 56 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT SYS_HashType UT_JSONValueMap::hash ( ) const
template<typename T >
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.

Check equality

Definition at line 180 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT const UT_JSONValue* UT_JSONValueMap::operator() ( int64  i) const
inline

Access const entry by index.

Definition at line 81 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT UT_JSONValue* UT_JSONValueMap::operator() ( int64  i)
inline

Access entry by index.

Definition at line 84 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT const UT_JSONValue* UT_JSONValueMap::operator() ( const UT_StringRef k) const
inline

Access const entry by name (may be NULL pointer if k is not a key)

Definition at line 87 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT UT_JSONValue* UT_JSONValueMap::operator() ( const UT_StringRef k)
inline

Access entry by name (may be NULL pointer if k is not a key)

Definition at line 90 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT bool UT_JSONValueMap::operator== ( const UT_JSONValueMap arr) const

Check equality

SYS_NO_DISCARD_RESULT const UT_JSONValue* UT_JSONValueMap::operator[] ( int64  i) const
inline

Access const entry by index.

Definition at line 94 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT UT_JSONValue* UT_JSONValueMap::operator[] ( int64  i)
inline

Access entry by index.

Definition at line 97 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT const UT_JSONValue* UT_JSONValueMap::operator[] ( const UT_StringRef k) const
inline

Access const entry by name (may be NULL pointer if k is not a key)

Definition at line 100 of file UT_JSONValueMap.h.

SYS_NO_DISCARD_RESULT UT_JSONValue* UT_JSONValueMap::operator[] ( const UT_StringRef k)
inline

Access entry by name (may be NULL pointer if k is not a key)

Definition at line 103 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.

Friends And Related Function Documentation

friend class iterator
friend

Definition at line 262 of file UT_JSONValueMap.h.


The documentation for this class was generated from the following file: