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

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_JSONValueMapmakeUnique () 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_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 ()
 
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
 

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:
mocapstream/MocapStreamRokokoHDK.C, packedshareddata/GU_PackedSharedData.h, and packedsphere/GU_PackedSphere.h.

Definition at line 37 of file UT_JSONValueMap.h.

Member Typedef Documentation

Definition at line 260 of file UT_JSONValueMap.h.

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.

iterator UT_JSONValueMap::begin ( void  )
inline

Definition at line 258 of file UT_JSONValueMap.h.

const_iterator UT_JSONValueMap::begin ( void  ) const
inline

Definition at line 261 of file UT_JSONValueMap.h.

void UT_JSONValueMap::bumpRef ( int  d)
inline

Reference count (for shared maps).

Definition at line 43 of file UT_JSONValueMap.h.

void UT_JSONValueMap::clear ( )

Clear the entries in the map.

Examples:
mocapstream/MocapStreamRokokoHDK.C.
void UT_JSONValueMap::dump ( ) const

Dump to stdout (same as save to std::cout)

template<typename... ARGS>
InsertResult UT_JSONValueMap::emplace ( const UT_StringHolder key,
ARGS &&...  args 
)
inline

Emplace a value into the map.

Definition at line 163 of file UT_JSONValueMap.h.

iterator UT_JSONValueMap::end ( void  )
inline

Definition at line 259 of file UT_JSONValueMap.h.

const_iterator UT_JSONValueMap::end ( void  ) const
inline

Definition at line 262 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 71 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:
mocapstream/MocapStreamRokokoHDK.C, and packedshareddata/GU_PackedSharedData.C.

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

Examples:
mocapstream/MocapStreamRokokoHDK.C.
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.

Examples:
mocapstream/MocapStreamRokokoHDK.C.
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 49 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.

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).

Check equality

Definition at line 196 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 80 of file UT_JSONValueMap.h.

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

Access entry by index.

Definition at line 83 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 86 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 89 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 93 of file UT_JSONValueMap.h.

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

Access entry by index.

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

SYS_NO_DISCARD_RESULT int64 UT_JSONValueMap::size ( void  ) const
inline

Definition at line 73 of file UT_JSONValueMap.h.

Friends And Related Function Documentation

friend class iterator
friend

Definition at line 269 of file UT_JSONValueMap.h.


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