SBValueMap#
This class exposes bindings for the SAMSON SDK SBValueMap class that describes a value map. This is a convenience class that contains a map from string to samson.SBValue, and can be used, for example, to pass into a function a map of parameters, or another data.
- class samson.SBValueMap(*args, **kwargs)#
Bases:
pybind11_objectThis class describes a value map.
This is a convenience class that contains a map from string to
SBValue, and can be used, for example, to pass a parameter map into a function.SAMSON API: Introspection, SBCMetaValueMap, SBCMetaValue
Overloaded function.
__init__(self: samson.SBValueMap) -> None
Creates an empty map.
__init__(self: samson.SBValueMap, n: typing.SupportsInt | typing.SupportsIndex) -> None
Creates a map and preallocates storage.
- Parameters:
n (int) – Expected number of entries.
__init__(self: samson.SBValueMap, valueMap: samson.SBValueMap) -> None
Copy constructor.
- Parameters:
valueMap (samson.SBValueMap) – Source map.
- at(self: samson.SBValueMap, key: str) samson.SBValue#
Returns value for key; raises KeyError if key is missing.
- clear(self: samson.SBValueMap) None#
Removes all entries from the map.
- contains(self: samson.SBValueMap, key: str) bool#
Returns whether key exists in the map.
- erase(self: samson.SBValueMap, key: str) bool#
Erases an entry by key and returns whether erasure succeeded.
- get(*args, **kwargs)#
Overloaded function.
get(self: samson.SBValueMap, key: str) -> samson.SBValue
Return the value stored for
keyor an emptysamson.SBValue.- Parameters:
key (str) – Map key.
- Returns:
Value associated with
key, or an emptysamson.SBValuewhen the key is missing.- Return type:
get(self: samson.SBValueMap, key: str, default: object) -> object
Return the value stored for
keyordefaultwhen the key is missing.- Parameters:
key (str) – Map key.
default (object) – Fallback value returned when
keydoes not exist.
- Returns:
Stored value converted to a Python object, or
defaultwhen the key is missing.- Return type:
object
- insert(self: samson.SBValueMap, key: str, value: samson.SBValue) bool#
Insert
keyandvalueonly when the key is missing.- Parameters:
key (str) – Map key.
value (samson.SBValue) – Value to insert.
- Returns:
Trueif a new entry was inserted, orFalsewhenkeyalready exists.- Return type:
bool
- items(self: samson.SBValueMap) list[tuple[str, samson.SBValue]]#
Returns a snapshot list of (key, value) pairs.
- keys(self: samson.SBValueMap) list[str]#
Returns a snapshot list of keys.
- pop(self: samson.SBValueMap, key: str, default: object = None) object#
Remove and return the value stored for
key.If
keyis missing, returndefaultinstead.- Parameters:
key (str) – Map key.
default (object, optional) – Fallback value returned when
keyis missing. The default isNone.
- Returns:
Removed value converted to a Python object, or
defaultwhenkeyis missing.- Return type:
object
- set(self: samson.SBValueMap, key: str, value: samson.SBValue) None#
Set
keytovalue.- Parameters:
key (str) – Map key.
value (samson.SBValue) – Value to store. Any existing value for the same key is replaced.
- swap(self: samson.SBValueMap, valueMap: samson.SBValueMap) None#
Swaps maps in O(1)
- toDict(self: samson.SBValueMap) dict[str, samson.SBValue]#
Creates a Python dictionary snapshot from this value map.
- update(self: samson.SBValueMap, dict: dict) None#
Updates map from a Python dictionary (str -> SBValue).
- values(self: samson.SBValueMap) list[samson.SBValue]#
Returns a snapshot list of values.