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_object

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

  1. __init__(self: samson.SBValueMap) -> None

Creates an empty map.

  1. __init__(self: samson.SBValueMap, n: typing.SupportsInt | typing.SupportsIndex) -> None

Creates a map and preallocates storage.

Parameters:

n (int) – Expected number of entries.

  1. __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.

  1. get(self: samson.SBValueMap, key: str) -> samson.SBValue

Return the value stored for key or an empty samson.SBValue.

Parameters:

key (str) – Map key.

Returns:

Value associated with key, or an empty samson.SBValue when the key is missing.

Return type:

samson.SBValue

  1. get(self: samson.SBValueMap, key: str, default: object) -> object

Return the value stored for key or default when the key is missing.

Parameters:
  • key (str) – Map key.

  • default (object) – Fallback value returned when key does not exist.

Returns:

Stored value converted to a Python object, or default when the key is missing.

Return type:

object

insert(self: samson.SBValueMap, key: str, value: samson.SBValue) bool#

Insert key and value only when the key is missing.

Parameters:
Returns:

True if a new entry was inserted, or False when key already 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 key is missing, return default instead.

Parameters:
  • key (str) – Map key.

  • default (object, optional) – Fallback value returned when key is missing. The default is None.

Returns:

Removed value converted to a Python object, or default when key is missing.

Return type:

object

set(self: samson.SBValueMap, key: str, value: samson.SBValue) None#

Set key to value.

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.