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

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

#include <UT_JSONValueMap.h>

Public Member Functions

 UT_JSONValueMap ()
 
 ~UT_JSONValueMap ()
 
void bumpRef (int d)
 Reference count (for shared maps). More...
 
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
 
int64 entries () const
 Return the number of entries in the map. More...
 
void clear ()
 Clear the entries in the map. More...
 
const UT_JSONValueoperator() (int64 i) const
 Access const entry by index. More...
 
UT_JSONValueoperator() (int64 i)
 Access entry by index. More...
 
const UT_JSONValueoperator() (const UT_StringRef &k) const
 Access const entry by name (may be NULL pointer if k is not a key) More...
 
UT_JSONValueoperator() (const UT_StringRef &k)
 Access entry by name (may be NULL pointer if k is not a key) More...
 
const UT_JSONValueoperator[] (int64 i) const
 Access const entry by index. More...
 
UT_JSONValueoperator[] (int64 i)
 Access entry by index. More...
 
const UT_JSONValueoperator[] (const UT_StringRef &k) const
 Access const entry by name (may be NULL pointer if k is not a key) More...
 
UT_JSONValueoperator[] (const UT_StringRef &k)
 Access entry by name (may be NULL pointer if k is not a key) More...
 
const UT_JSONValueget (int64 i) const
 Access a const entry by index. More...
 
UT_JSONValueget (int64 i)
 Access an entry by index. More...
 
const UT_JSONValueget (const UT_StringRef &k) const
 Access const entry by name (may be NULL pointer if k is not a key) More...
 
UT_JSONValueget (const UT_StringRef &k)
 Access entry by name (may be NULL pointer if k is not a key) More...
 
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
 

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

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.

void UT_JSONValueMap::bumpRef ( int  d)
inline

Reference count (for shared maps).

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

int64 UT_JSONValueMap::entries ( void  ) const
inline

Return the number of entries in the map.

Definition at line 62 of file UT_JSONValueMap.h.

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

Access a const entry by index.

Definition at line 95 of file UT_JSONValueMap.h.

UT_JSONValue* UT_JSONValueMap::get ( int64  i)
inline

Access an entry by index.

Definition at line 98 of file UT_JSONValueMap.h.

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)

UT_JSONValue* UT_JSONValueMap::get ( const UT_StringRef k)

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

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.

int UT_JSONValueMap::getRef ( ) const
inline

Get the number of references to this map.

Definition at line 44 of file UT_JSONValueMap.h.

template<typename T >
bool UT_JSONValueMap::import ( const UT_StringRef key,
T result 
) const

Key/Value imports. This is implemented for T in:

  • bool
  • int64
  • fpreal64
  • UT_WorkBuffer/UT_StringHolder
  • UT_Int64Array
  • UT_Fpreal64Array Returns false if the key isn't in the map, or if the import from the UT_JSONValue fails.
const UT_JSONValue* UT_JSONValueMap::operator() ( int64  i) const
inline

Access const entry by index.

Definition at line 69 of file UT_JSONValueMap.h.

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

Access entry by index.

Definition at line 72 of file UT_JSONValueMap.h.

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 75 of file UT_JSONValueMap.h.

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 78 of file UT_JSONValueMap.h.

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

Access const entry by index.

Definition at line 82 of file UT_JSONValueMap.h.

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

Access entry by index.

Definition at line 85 of file UT_JSONValueMap.h.

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 88 of file UT_JSONValueMap.h.

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


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