VtDictionary Functions

Functions for manipulating VtDictionary objects. More...

Functions

template<typename T >
bool VtDictionaryIsHolding (const VtDictionary &dictionary, const std::string &key)
 Returns true if dictionary contains key and the corresponding value is of type T. More...
 
template<typename T >
const T & VtDictionaryGet (const VtDictionary &dictionary, const std::string &key)
 Return a value held in a VtDictionary by reference. More...
 
template<class T , class U >
VtDictionaryGet (const VtDictionary &dictionary, const std::string &key, Vt_DefaultHolder< U > const &def)
 Return a value held in a VtDictionary, or a default value either if the supplied key is missing or if the types do not match. More...
 
VT_API VtDictionary VtDictionaryOver (const VtDictionary &strong, const VtDictionary &weak, bool coerceToWeakerOpinionType=false)
 Creates a dictionary containing strong composed over weak. More...
 
VT_API void VtDictionaryOver (VtDictionary *strong, const VtDictionary &weak, bool coerceToWeakerOpinionType=false)
 Updates strong to become strong composed over weak. More...
 
VT_API void VtDictionaryOver (const VtDictionary &strong, VtDictionary *weak, bool coerceToWeakerOpinionType=false)
 Updates weak to become strong composed over weak. More...
 
VT_API VtDictionary VtDictionaryOverRecursive (const VtDictionary &strong, const VtDictionary &weak, bool coerceToWeakerOpinionType=false)
 Returns a dictionary containing strong recursively composed over weak. More...
 
VT_API void VtDictionaryOverRecursive (VtDictionary *strong, const VtDictionary &weak, bool coerceToWeakerOpinionType=false)
 Updates strong to become strong composed recursively over weak. More...
 
VT_API void VtDictionaryOverRecursive (const VtDictionary &strong, VtDictionary *weak, bool coerceToWeakerOpinionType=false)
 Updates weak to become strong composed recursively over weak. More...
 

Detailed Description

Functions for manipulating VtDictionary objects.

Function Documentation

◆ VtDictionaryGet() [1/2]

const T& VtDictionaryGet ( const VtDictionary dictionary,
const std::string &  key 
)

Return a value held in a VtDictionary by reference.

If key is in dictionary and the corresponding value is of type T, returns a reference to the value.

Remarks
If key is not in dictionary, or the value for key is of the wrong type, a fatal error occurs, so clients should always call VtDictionaryIsHolding first.

Definition at line 414 of file dictionary.h.

◆ VtDictionaryGet() [2/2]

T VtDictionaryGet ( const VtDictionary dictionary,
const std::string &  key,
Vt_DefaultHolder< U > const &  def 
)

Return a value held in a VtDictionary, or a default value either if the supplied key is missing or if the types do not match.

For example, this code will get a bool value under key "key" if "key" has a boolean value in the dictionary. If there is no such key, or the value under the key is not a bool, the specified default (false) is returned.

bool val = VtDictionaryGet<bool>(dict, "key", VtDefault = false);

Definition at line 477 of file dictionary.h.

◆ VtDictionaryIsHolding()

bool VtDictionaryIsHolding ( const VtDictionary dictionary,
const std::string &  key 
)

Returns true if dictionary contains key and the corresponding value is of type T.

Definition at line 376 of file dictionary.h.

◆ VtDictionaryOver() [1/3]

VT_API VtDictionary VtDictionaryOver ( const VtDictionary strong,
const VtDictionary weak,
bool  coerceToWeakerOpinionType = false 
)

Creates a dictionary containing strong composed over weak.

The new dictionary will contain all key-value pairs from strong together with the key-value pairs from weak whose keys are not in strong.

If coerceToWeakerOpinionType is true then coerce a strong value to the weaker value's type, if there is a weaker value. This is mainly intended to promote to enum types.

◆ VtDictionaryOver() [2/3]

VT_API void VtDictionaryOver ( VtDictionary strong,
const VtDictionary weak,
bool  coerceToWeakerOpinionType = false 
)

Updates strong to become strong composed over weak.

The updated contents of strong will be all key-value pairs from strong together with the key-value pairs from weak whose keys are not in strong.

If coerceToWeakerOpinionType is true then coerce a strong value to the weaker value's type, if there is a weaker value. This is mainly intended to promote to enum types.

◆ VtDictionaryOver() [3/3]

VT_API void VtDictionaryOver ( const VtDictionary strong,
VtDictionary weak,
bool  coerceToWeakerOpinionType = false 
)

Updates weak to become strong composed over weak.

The updated contents of weak will be all key-value pairs from strong together with the key-value pairs from weak whose keys are not in strong.

If coerceToWeakerOpinionType is true then coerce a strong value to the weaker value's type, if there is a weaker value. This is mainly intended to promote to enum types.

◆ VtDictionaryOverRecursive() [1/3]

VT_API VtDictionary VtDictionaryOverRecursive ( const VtDictionary strong,
const VtDictionary weak,
bool  coerceToWeakerOpinionType = false 
)

Returns a dictionary containing strong recursively composed over weak.

The new dictionary will be all key-value pairs from strong together with the key-value pairs from weak whose keys are not in strong.

If a value for a key is in turn a dictionary, and both strong and weak have values for that key, then the result may not contain strong's exact value for the subdict. Rather, the result will contain a subdict that is the result of a recursive call to this method. Hence, the subdict, too, will contain values from weak that are not found in strong.

If coerceToWeakerOpinionType is true then coerce a strong value to the weaker value's type, if there is a weaker value. This is mainly intended to promote to enum types.

◆ VtDictionaryOverRecursive() [2/3]

VT_API void VtDictionaryOverRecursive ( VtDictionary strong,
const VtDictionary weak,
bool  coerceToWeakerOpinionType = false 
)

Updates strong to become strong composed recursively over weak.

The updated contents of strong will be all key-value pairs from strong together with the key-value pairs from weak whose keys are not in strong.

If a value for a key is in turn a dictionary, and both strong and weak have values for that key, then strong's subdict may not be left untouched. Rather, the dictionary will be replaced by the result of a recursive call to this method in which strong's subdictionary will have entries added if they are contained in weak but not in strong

If coerceToWeakerOpinionType is true then coerce a strong value to the weaker value's type, if there is a weaker value. This is mainly intended to promote to enum types.

◆ VtDictionaryOverRecursive() [3/3]

VT_API void VtDictionaryOverRecursive ( const VtDictionary strong,
VtDictionary weak,
bool  coerceToWeakerOpinionType = false 
)

Updates weak to become strong composed recursively over weak.

The updated contents of weak will be all key-value pairs from strong together with the key-value pairs from weak whose keys are not in strong.

If a value is in turn a dictionary, the dictionary in weak may not be replaced wholesale by that of strong. Rather, the dictionary will be replaced by the result of a recursive call to this method in which weak's subdictionary is recursively overlayed by strong's subdictionary.

The result is that no key/value pairs of will be lost in nested dictionaries. Rather, only non-dictionary values will be overwritten

If coerceToWeakerOpinionType is true then coerce a strong value to the weaker value's type, if there is a weaker value. This is mainly intended to promote to enum types.