All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
VtDictionary Class Reference

A map with string keys and VtValue values. More...

#include <dictionary.h>

Public Types

typedef _Map::key_type key_type
 
typedef _Map::mapped_type mapped_type
 
typedef _Map::value_type value_type
 
typedef _Map::allocator_type allocator_type
 
typedef _Map::size_type size_type
 
typedef Iterator< _Map *, _Map::iterator > iterator
 
typedef Iterator< _Map const *, _Map::const_iterator > const_iterator
 

Public Member Functions

 TF_MALLOC_TAG_NEW ("Vt", "VtDictionary")
 
 VtDictionary ()
 Creates an empty VtDictionary.
 
 VtDictionary (int size)
 Creates an empty VtDictionary with at least size buckets.
 
template<class _InputIterator >
 VtDictionary (_InputIterator f, _InputIterator l)
 Creates a VtDictionary with a copy of a range.
 
VT_API VtDictionary (VtDictionary const &other)
 Creates a copy of the supplied VtDictionary.
 
VT_API VtDictionary (VtDictionary &&other)=default
 Creates a new VtDictionary by moving the supplied VtDictionary.
 
VT_API VtDictionary (std::initializer_list< value_type > init)
 Creates a new VtDictionary from a braced initializer list.
 
VT_API VtDictionaryoperator= (VtDictionary const &other)
 Copy assignment operator.
 
VT_API VtDictionaryoperator= (VtDictionary &&other)=default
 Move assignment operator.
 
VT_API VtValueoperator[] (const std::string &key)
 Returns a reference to the VtValue that is associated with a particular key.
 
VT_API size_type count (const std::string &key) const
 Counts the number of elements whose key is key.
 
VT_API size_type count (const char *key) const
 Counts the number of elements whose key is key.
 
VT_API size_type erase (const std::string &key)
 Erases the element whose key is key.
 
VT_API void erase (iterator it)
 Erases the element pointed to by it.
 
VT_API void erase (iterator f, iterator l)
 Erases all elements in a range.
 
VT_API void clear ()
 Erases all of the elements.
 
VT_API iterator find (const std::string &key)
 Finds an element whose key is key.
 
VT_API iterator find (const char *key)
 Finds an element whose key is key.
 
VT_API const_iterator find (const std::string &key) const
 Finds an element whose key is key.
 
VT_API const_iterator find (const char *key) const
 Finds an element whose key is key.
 
VT_API iterator begin ()
 Returns an iterator pointing to the beginning of the VtDictionary.
 
VT_API const_iterator begin () const
 Returns an iterator pointing to the beginning of the VtDictionary.
 
VT_API iterator end ()
 Returns an iterator pointing to the end of the VtDictionary.
 
VT_API const_iterator end () const
 Returns an iterator pointing to the end of the VtDictionary.
 
VT_API size_type size () const
 Returns the size of the VtDictionary.
 
VT_API bool empty () const
 true if the VtDictionary's size is 0.
 
VT_API void swap (VtDictionary &dict)
 Swaps the contents of two VtDictionaries.
 
template<class _InputIterator >
void insert (_InputIterator f, _InputIterator l)
 Inserts a range into the VtDictionary.
 
VT_API std::pair< iterator, bool > insert (const value_type &obj)
 Inserts obj into the VtDictionary.
 
VT_API VtValue const * GetValueAtPath (std::string const &keyPath, char const *delimiters=":") const
 Return a pointer to the value at keyPath if one exists.
 
VT_API VtValue const * GetValueAtPath (std::vector< std::string > const &keyPath) const
 Return a pointer to the value at keyPath if one exists.
 
VT_API void SetValueAtPath (std::string const &keyPath, VtValue const &value, char const *delimiters=":")
 Set the value at keyPath to value.
 
VT_API void SetValueAtPath (std::vector< std::string > const &keyPath, VtValue const &value)
 Set the value at keyPath to value.
 
VT_API void EraseValueAtPath (std::string const &keyPath, char const *delimiters=":")
 Erase the value at keyPath.
 
VT_API void EraseValueAtPath (std::vector< std::string > const &keyPath)
 Erase the value at keyPath.
 

Friends

void swap (VtDictionary &lhs, VtDictionary &rhs)
 
size_t hash_value (VtDictionary const &dict)
 

Detailed Description

A map with string keys and VtValue values.

VtDictionary converts to and from a python dictionary as long as each element contains either

  • another VtDictionary (converts to a nested dictionary)
  • std::vector<VtValue> (converts to a nested list)
  • VtValue with one of the supported Vt Types.

For a list of functions that can manipulate VtDictionary objects, see the
VtDictionary Functions group page .

Definition at line 43 of file dictionary.h.

Member Typedef Documentation

◆ allocator_type

typedef _Map::allocator_type allocator_type

Definition at line 177 of file dictionary.h.

◆ const_iterator

typedef Iterator<_Map const*, _Map::const_iterator> const_iterator

Definition at line 181 of file dictionary.h.

◆ iterator

typedef Iterator<_Map*, _Map::iterator> iterator

Definition at line 180 of file dictionary.h.

◆ key_type

typedef _Map::key_type key_type

Definition at line 174 of file dictionary.h.

◆ mapped_type

typedef _Map::mapped_type mapped_type

Definition at line 175 of file dictionary.h.

◆ size_type

typedef _Map::size_type size_type

Definition at line 178 of file dictionary.h.

◆ value_type

typedef _Map::value_type value_type

Definition at line 176 of file dictionary.h.

Constructor & Destructor Documentation

◆ VtDictionary() [1/6]

VtDictionary ( )
inline

Creates an empty VtDictionary.

Definition at line 184 of file dictionary.h.

◆ VtDictionary() [2/6]

VtDictionary ( int  size)
inlineexplicit

Creates an empty VtDictionary with at least size buckets.

Definition at line 187 of file dictionary.h.

◆ VtDictionary() [3/6]

VtDictionary ( _InputIterator  f,
_InputIterator  l 
)
inline

Creates a VtDictionary with a copy of a range.

Definition at line 191 of file dictionary.h.

◆ VtDictionary() [4/6]

VT_API VtDictionary ( VtDictionary const &  other)

Creates a copy of the supplied VtDictionary.

◆ VtDictionary() [5/6]

VT_API VtDictionary ( VtDictionary &&  other)
default

Creates a new VtDictionary by moving the supplied VtDictionary.

◆ VtDictionary() [6/6]

VT_API VtDictionary ( std::initializer_list< value_type >  init)

Creates a new VtDictionary from a braced initializer list.

Member Function Documentation

◆ begin() [1/2]

VT_API iterator begin ( )

Returns an iterator pointing to the beginning of the VtDictionary.

◆ begin() [2/2]

VT_API const_iterator begin ( ) const

Returns an iterator pointing to the beginning of the VtDictionary.

◆ clear()

VT_API void clear ( )

Erases all of the elements.

◆ count() [1/2]

VT_API size_type count ( const char *  key) const

Counts the number of elements whose key is key.

◆ count() [2/2]

VT_API size_type count ( const std::string &  key) const

Counts the number of elements whose key is key.

◆ empty()

VT_API bool empty ( ) const

true if the VtDictionary's size is 0.

◆ end() [1/2]

VT_API iterator end ( )

Returns an iterator pointing to the end of the VtDictionary.

◆ end() [2/2]

VT_API const_iterator end ( ) const

Returns an iterator pointing to the end of the VtDictionary.

◆ erase() [1/3]

VT_API size_type erase ( const std::string &  key)

Erases the element whose key is key.

◆ erase() [2/3]

VT_API void erase ( iterator  f,
iterator  l 
)

Erases all elements in a range.

◆ erase() [3/3]

VT_API void erase ( iterator  it)

Erases the element pointed to by it.

◆ EraseValueAtPath() [1/2]

VT_API void EraseValueAtPath ( std::string const &  keyPath,
char const *  delimiters = ":" 
)

Erase the value at keyPath.

keyPath is a delimited string of sub-dictionary names. Key path elements are produced by calling TfStringTokenize() with keyPath and delimiters. If no such element exists at keyPath, do nothing. If keyPath identifies a sub-dictionary, erase the entire sub-dictionary.

◆ EraseValueAtPath() [2/2]

VT_API void EraseValueAtPath ( std::vector< std::string > const &  keyPath)

Erase the value at keyPath.

If no such element exists at keyPath, do nothing. If keyPath identifies a sub-dictionary, erase the entire sub-dictionary.

◆ find() [1/4]

VT_API iterator find ( const char *  key)

Finds an element whose key is key.

◆ find() [2/4]

VT_API const_iterator find ( const char *  key) const

Finds an element whose key is key.

◆ find() [3/4]

VT_API iterator find ( const std::string &  key)

Finds an element whose key is key.

◆ find() [4/4]

VT_API const_iterator find ( const std::string &  key) const

Finds an element whose key is key.

◆ GetValueAtPath() [1/2]

VT_API VtValue const * GetValueAtPath ( std::string const &  keyPath,
char const *  delimiters = ":" 
) const

Return a pointer to the value at keyPath if one exists.

keyPath is a delimited string of sub-dictionary names. Key path elements are produced by calling TfStringTokenize() with keyPath and delimiters. keyPath may identify a leaf element or an entire sub-dictionary. Return null if no such element at keyPath exists.

◆ GetValueAtPath() [2/2]

VT_API VtValue const * GetValueAtPath ( std::vector< std::string > const &  keyPath) const

Return a pointer to the value at keyPath if one exists.

keyPath may identify a leaf element or an entire sub-dictionary. Return null if no such element at keyPath exists.

◆ insert() [1/2]

void insert ( _InputIterator  f,
_InputIterator  l 
)
inline

Inserts a range into the VtDictionary.

Definition at line 304 of file dictionary.h.

◆ insert() [2/2]

VT_API std::pair< iterator, bool > insert ( const value_type &  obj)

Inserts obj into the VtDictionary.

◆ operator=() [1/2]

VT_API VtDictionary & operator= ( VtDictionary &&  other)
default

Move assignment operator.

◆ operator=() [2/2]

VT_API VtDictionary & operator= ( VtDictionary const &  other)

Copy assignment operator.

◆ operator[]()

VT_API VtValue & operator[] ( const std::string &  key)

Returns a reference to the VtValue that is associated with a particular key.

◆ SetValueAtPath() [1/2]

VT_API void SetValueAtPath ( std::string const &  keyPath,
VtValue const &  value,
char const *  delimiters = ":" 
)

Set the value at keyPath to value.

keyPath is a delimited string of sub-dictionary names. Key path elements are produced by calling TfStringTokenize() with keyPath and delimiters. Create sub-dictionaries as necessary according to the path elements in keyPath. If keyPath identifies a full sub-dictionary, replace the entire sub-dictionary with value.

◆ SetValueAtPath() [2/2]

VT_API void SetValueAtPath ( std::vector< std::string > const &  keyPath,
VtValue const &  value 
)

Set the value at keyPath to value.

Create sub-dictionaries as necessary according to the path elements in keyPath. If keyPath identifies a full sub-dictionary, replace the entire sub-dictionary with value.

◆ size()

VT_API size_type size ( ) const

Returns the size of the VtDictionary.

◆ swap()

VT_API void swap ( VtDictionary dict)

Swaps the contents of two VtDictionaries.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( VtDictionary const &  dict)
friend

Definition at line 294 of file dictionary.h.

◆ swap

void swap ( VtDictionary lhs,
VtDictionary rhs 
)
friend

Definition at line 290 of file dictionary.h.


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