LSPMap Class¶
-
class
LSPMap
¶ An LSPMap is a data structure mapping keys to values. A map is both an associative table and an array. Setting a value to an existing key will overwrite any value previously set for that key.
When used as an array-like structure, adding a new unkeyed element to an LSPMap with
addValue()
automatically assigns an integer key to the element equal to the largest integer key already present plus one, or zero if no integer key exists.Most of the functions below exist in multiple versions: Values and keys can be manipulated through their native type (like
int
,double
,std::string
,LSPMap
,LSPFunction
, …) or manipulated with anLSPValue
which is a container that can hold any type of value. Using the native type is more convenient and results in less overhead most of the time.LSPValue
should only be used when you don’t know the type of the manipulated value.The iterators returned by the method
iterator()
follow the fail-fast convention: if the map is structurally modified after the creation of an iterator (by using the methods add, set, unset or clear), the iterator will throw an exception. In other words, you can’t modify a map while you are iterating over it.Since: 10.0
Summary¶
count |
Returns the number of elements in the map. |
clear |
Erases all elements from the map. |
addValue |
Adds the given value to the map. |
addInt |
Adds the given integer value to the map. |
addDouble |
Adds the given double value to the map. |
addBool |
Adds the given boolean value to the map. |
addExpression |
Adds the given LSExpression to the map. |
addString |
Adds the given string to the map. |
addMap |
Adds the given LSPMap to the map. |
addFunction |
Adds the given LSPFunction to the map. |
addModule |
Adds the given LSPModule to the map. |
getValue |
Gets the LSPValue associated with the given key. |
getValue |
Returns the value associated with the given key as an LSPValue. |
getValue |
Gets the LSPValue associated with the given key. |
getInt |
Gets the integer value associated with the given key. |
getInt |
Returns the integer value associated with the given key. |
getInt |
Returns the integer value associated with the given key. |
getDouble |
Gets the double value associated with the given key. |
getDouble |
Returns the double value associated with the given key. |
getDouble |
Returns the double value associated with the given key. |
getBool |
Gets the boolean value associated with the given key. |
getBool |
Returns the boolean value associated with the given key. |
getBool |
Returns the boolean value associated with the given key. |
getString |
Gets the string associated with the given key. |
getString |
Returns the string associated with the given key. |
getString |
Returns the string associated with the given key. |
getExpression |
Gets the LSExpression associated with the given key. |
getExpression |
Returns the LSExpression associated with the given key. |
getExpression |
Gets the LSExpression associated with the given key. |
getMap |
Gets the LSPMap associated with the given key. |
getMap |
Returns the LSPMap associated with the given key. |
getMap |
Gets the LSPMap associated with the given key. |
getFunction |
Gets the LSPFunction associated with the given key. |
getFunction |
Returns the LSPFunction associated with the given key. |
getFunction |
Gets the LSPFunction associated with the given key. |
getModule |
Gets the LSPModule associated with the given key. |
getModule |
Returns the LSPModule associated with the given key. |
getModule |
Gets the LSPModule associated with the given key. |
setValue |
Associates the LSPValue with the given key. |
setValue |
Associates the LSPValue with the given key in the map. |
setValue |
Associates an LSPValue with the given key. |
setInt |
Associates the integer value with the given key in the map. |
setInt |
Associates the integer value with the given key in the map. |
setInt |
Associates an integer value with the given key. |
setDouble |
Associates the double value with the given key in the map. |
setDouble |
Associates the double value with the given key in the map. |
setDouble |
Associates a double value with the given key. |
setBool |
Associates the boolean value with the given key in the map. |
setBool |
Associates the boolean value with the given key in the map. |
setBool |
Associates a boolean value with the given key. |
setString |
Associates the string with the given key in the map. |
setString |
Associates the string with the given key in the map. |
setString |
Associates a string with the given key. |
setExpression |
Associates the LSExpression with the given key in the map. |
setExpression |
Associates the LSExpression with the given key in the map. |
setExpression |
Associates an LSExpression with the given key. |
setMap |
Associates the LSPMap with the given key in the map. |
setMap |
Associates the LSPMap with the given key in the map. |
setMap |
Associates an LSPMap with the given key. |
setFunction |
Associates the LSPFunction with the given key in the map. |
setFunction |
Associates the LSPFunction with the given key in the map. |
setFunction |
Associates an LSPFunction with the given key. |
setModule |
Associates the LSPModule with the given key in the map. |
setModule |
Associates the LSPModule with the given key in the map. |
setModule |
Associates an LSPModule with the given key. |
unset |
Unsets the given key in the map if present. |
unset |
Unsets the given key in the map if present. |
unset |
Unsets the given key in the map if present. |
isDefined |
Returns true if the given key is defined in the map. |
isDefined |
Returns true if the given key is defined in the map. |
isDefined |
Returns true if the given key is defined in the map. |
iterator |
Returns a new iterator to the elements of this map. |
asValue |
Gets the map as an LSPValue. |
LSPValue |
Returns the map as an LSPValue. |
Functions¶
-
void
LSPMap
::
clear
() const¶ Erases all elements from the map. After this call,
count()
returns zero.
-
void
LSPMap
::
addValue
(const LSPValue &value)¶ Adds the given value to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Parameters: value – Value to add in the map.
-
void
LSPMap
::
addInt
(lsint value)¶ Adds the given integer value to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Parameters: value – Integer value to add in the map.
-
void
LSPMap
::
addDouble
(lsdouble value)¶ Adds the given double value to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Parameters: value – Double value to add in the map.
-
void
LSPMap
::
addBool
(bool value)¶ Adds the given boolean value to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Parameters: value – Boolean value to add in the map.
-
void
LSPMap
::
addExpression
(const LSExpression &expr)¶ Adds the given
LSExpression
to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.Parameters: expr – LSExpression to add in the map.
-
void
LSPMap
::
addString
(const std::string &str)¶ Adds the given string to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Parameters: str – String to add in the map.
-
void
LSPMap
::
addMap
(const LSPMap &map)¶ Adds the given
LSPMap
to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.Parameters: map – LSPMap to add in the map.
-
void
LSPMap
::
addFunction
(const LSPFunction &func)¶ Adds the given
LSPFunction
to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.Parameters: func – LSPFunction to add in the map.
-
void
LSPMap
::
addModule
(const LSPModule &module)¶ Adds the given
LSPModule
to the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.Parameters: module – LSPModule to add in the map.
-
LSPValue
LSPMap
::
getValue
(lsint key) const¶ Gets the LSPValue associated with the given key. If the key is not present in the map, an LSPValue representing nil is returned.
Parameters: key – Integer key. Returns: LSPValue associated with the key.
-
LSPValue
LSPMap
::
getValue
(const std::string &key) const¶ Returns the value associated with the given key as an
LSPValue
. If no value is associated with the key, an LSPValue representing nil is returned.Parameters: key – String key. Returns: LSPValue associated with the key.
-
LSPValue
LSPMap
::
getValue
(const LSPValue &key) const¶ Gets the
LSPValue
associated with the given key. The key must not be nil. If the key is not present in the map, an LSPValue representing nil is returned.Parameters: key – LSPValue key. Returns: LSPValue associated with the key.
-
lsint
LSPMap
::
getInt
(lsint key) const¶ Gets the integer value associated with the given key. The value must exist and must be a integer.
Parameters: key – Integer key. Returns: Integer value associated with the key.
-
lsint
LSPMap
::
getInt
(const std::string &key) const¶ Returns the integer value associated with the given key. The value must exist and must be an integer.
Parameters: key – String key. Returns: Integer value associated with the key.
-
lsint
LSPMap
::
getInt
(const LSPValue &key) const¶ Returns the integer value associated with the given key. The key must not be nil. The value must exist and must be an integer.
Parameters: key – LSPValue key. Returns: Integer value associated with the key.
-
lsdouble
LSPMap
::
getDouble
(lsint key) const¶ Gets the double value associated with the given key. The value must exist and must be a double.
Parameters: key – Integer key. Returns: Double value associated with the key.
-
lsdouble
LSPMap
::
getDouble
(const std::string &key) const¶ Returns the double value associated with the given key. The value must exist and must be a double.
Parameters: key – String key. Returns: Double value associated with the key.
-
lsdouble
LSPMap
::
getDouble
(const LSPValue &key) const¶ Returns the double value associated with the given key. The key must not be nil. The value must exist and must be a double.
Parameters: key – LSPValue key. Returns: Double value associated with the key.
-
bool
LSPMap
::
getBool
(lsint key) const¶ Gets the boolean value associated with the given key. The value must exist and must be a boolean.
Parameters: key – Integer key. Returns: Boolean value associated with the key.
-
bool
LSPMap
::
getBool
(const std::string &key) const¶ Returns the boolean value associated with the given key. The value must exist and must be a boolean.
Parameters: key – String key. Returns: Boolean value associated with the key.
-
bool
LSPMap
::
getBool
(const LSPValue &key) const¶ Returns the boolean value associated with the given key. The key must not be nil. The value must exist and must be a boolean.
Parameters: key – LSPValue key. Returns: Boolean value associated with the key.
-
std::string
LSPMap
::
getString
(lsint key) const¶ Gets the string associated with the given key. The value must exist and must be a string.
Parameters: key – Integer key. Returns: String associated with the key.
-
std::string
LSPMap
::
getString
(const std::string &key) const¶ Returns the string associated with the given key. The value must exist and must be a string.
Parameters: key – String key. Returns: String value associated with the key.
-
std::string
LSPMap
::
getString
(const LSPValue &key) const¶ Returns the string associated with the given key. The key must not be nil. The value must exist and must be a string.
Parameters: key – LSPValue key. Returns: String associated with the key.
-
LSExpression
LSPMap
::
getExpression
(lsint key) const¶ Gets the LSExpression associated with the given key. The value must exist and must be an
LSExpression
.Parameters: key – Integer key. Returns: LSExpression associated with the key.
-
LSExpression
LSPMap
::
getExpression
(const std::string &key) const¶ Returns the
LSExpression
associated with the given key. The value must exist and must be anLSExpression
.Parameters: key – String key. Returns: LSExpression associated with the key.
-
LSExpression
LSPMap
::
getExpression
(const LSPValue &key) const¶ Gets the
LSExpression
associated with the given key. The key must not be nil. The value must exist and must be anLSExpression
.Parameters: key – LSPValue key. Returns: LSExpression associated with the key.
-
LSPMap
LSPMap
::
getMap
(lsint key) const¶ Gets the LSPMap associated with the given key. The value must exist and must be an
LSPMap
.Parameters: key – Integer key. Returns: LSPMap associated with the key.
-
LSPMap
LSPMap
::
getMap
(const std::string &key) const¶ Returns the
LSPMap
associated with the given key. The value must exist and must be anLSPMap
.Parameters: key – String key. Returns: LSPMap associated with the key.
-
LSPMap
LSPMap
::
getMap
(const LSPValue &key) const¶ Gets the
LSPMap
associated with the given key. The key must not be nil. The value must exist and must be anLSPMap
.Parameters: key – LSPValue key. Returns: LSPMap associated with the key.
-
LSPFunction
LSPMap
::
getFunction
(lsint key) const¶ Gets the LSPFunction associated with the given key. The value must exist and must be an
LSPFunction
.Parameters: key – Integer key. Returns: LSPFunction associated with the key.
-
LSPFunction
LSPMap
::
getFunction
(const std::string &key) const¶ Returns the
LSPFunction
associated with the given key. The value must must exist and must be anLSPFunction
.Parameters: key – String key. Returns: LSPFunction associated with the key.
-
LSPFunction
LSPMap
::
getFunction
(const LSPValue &key) const¶ Gets the
LSPFunction
associated with the given key. The key must not be nil. The value must exist and must be anLSPFunction
.Parameters: key – LSPValue key. Returns: LSPFunction associated with the key.
-
LSPModule
LSPMap
::
getModule
(lsint key) const¶ Gets the LSPModule associated with the given key. The value must exist and must be an
LSPModule
.Parameters: key – Integer key. Returns: LSPModule associated with the key.
-
LSPModule
LSPMap
::
getModule
(const std::string &key) const¶ Returns the
LSPModule
associated with the given key. The value must exist and must be anLSPModule
.
-
LSPModule
LSPMap
::
getModule
(const LSPValue &key) const¶ Gets the
LSPModule
associated with the given key. The key must not be nil. The value must exist and must be anLSPModule
.Parameters: key – LSPValue key. Returns: LSPModule associated with the key.
-
void
LSPMap
::
setValue
(lsint key, const LSPValue &value)¶ Associates the
LSPValue
with the given key. If the value is nil, this has the same effect asLSPMap::unset()
. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – Integer key.
- value – LSPValue to set.
-
void
LSPMap
::
setValue
(const std::string &key, const LSPValue &value)¶ Associates the
LSPValue
with the given key in the map. If the value is nil, this has the same effect asLSPMap::unset()
. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – String key.
- value – LSPValue to set.
-
void
LSPMap
::
setValue
(const LSPValue &key, const LSPValue &value)¶ Associates an
LSPValue
with the given key. The key must not be nil. If the value is nil, this has the same effect asLSPMap::unset()
. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – LSPValue key.
- value – LSPValue value.
-
void
LSPMap
::
setInt
(lsint key, lsint value)¶ Associates the integer value with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – Integer key.
- value – Integer value to set.
-
void
LSPMap
::
setInt
(const std::string &key, lsint value)¶ Associates the integer value with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- value – Integer value to set.
-
void
LSPMap
::
setInt
(const LSPValue &key, lsint value)¶ Associates an integer value with the given key. The key must not be nil. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – LSPValue key.
- value – Integer value.
-
void
LSPMap
::
setDouble
(lsint key, lsdouble value)¶ Associates the double value with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – Integer key.
- value – Double value to set.
-
void
LSPMap
::
setDouble
(const std::string &key, lsdouble value)¶ Associates the double value with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- value – Double value to set.
-
void
LSPMap
::
setDouble
(const LSPValue &key, lsdouble value)¶ Associates a double value with the given key. The key must not be nil. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – LSPValue key.
- value – Double value.
-
void
LSPMap
::
setBool
(lsint key, bool value)¶ Associates the boolean value with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – Integer key.
- value – Boolean value to set.
-
void
LSPMap
::
setBool
(const std::string &key, bool value)¶ Associates the boolean value with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- value – Boolean value to set.
-
void
LSPMap
::
setBool
(const LSPValue &key, bool value)¶ Associates a boolean value with the given key. The key must not be nil. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – LSPValue key.
- value – Boolean value.
-
void
LSPMap
::
setString
(lsint key, const std::string &value)¶ Associates the string with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – Integer key.
- value – String to set.
-
void
LSPMap
::
setString
(const std::string &key, const std::string &value)¶ Associates the string with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- value – String value to set.
-
void
LSPMap
::
setString
(const LSPValue &key, const std::string &value)¶ Associates a string with the given key. The key must not be nil. If the map already contained an association for the key, the previous value s replaced.
Parameters: - key – LSPValue key.
- value – String value.
-
void
LSPMap
::
setExpression
(lsint key, const LSExpression &expr)¶ Associates the
LSExpression
with the given key in the map. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – Integer key.
- expr – LSExpression to set.
-
void
LSPMap
::
setExpression
(const std::string &key, const LSExpression &expr)¶ Associates the LSExpression with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- expr – LSExpression to set.
-
void
LSPMap
::
setExpression
(const LSPValue &key, const LSExpression &expr)¶ Associates an
LSExpression
with the given key. The key must not be nil. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – LSPValue key.
- expr – LSExpression value.
-
void
LSPMap
::
setMap
(lsint key, const LSPMap &map)¶ Associates the
LSPMap
with the given key in the map. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – Integer key.
- map – LSPMap to set.
-
void
LSPMap
::
setMap
(const std::string &key, const LSPMap &map)¶ Associates the LSPMap with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- map – LSPMap to set.
-
void
LSPMap
::
setMap
(const LSPValue &key, const LSPMap &map)¶ Associates an
LSPMap
with the given key. The key must not be nil. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – LSPValue key.
- map – LSPMap value.
-
void
LSPMap
::
setFunction
(lsint key, const LSPFunction &func)¶ Associates the
LSPFunction
with the given key in the map. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – Integer key.
- func – LSPFunction to set.
-
void
LSPMap
::
setFunction
(const std::string &key, const LSPFunction &func)¶ Associates the LSPFunction with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- func – LSPFunction to set.
-
void
LSPMap
::
setFunction
(const LSPValue &key, const LSPFunction &func)¶ Associates an
LSPFunction
with the given key. The key must not be nil. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – LSPValue key.
- func – LSPFunction value.
-
void
LSPMap
::
setModule
(lsint key, const LSPModule &module)¶ Associates the
LSPModule
with the given key in the map. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – Integer key.
- module – LSPModule to set.
-
void
LSPMap
::
setModule
(const std::string &key, const LSPModule &module)¶ Associates the LSPModule with the given key in the map. If the map already contained an association for the key, the previous value is replaced.
Parameters: - key – String key.
- module – LSPModule to set.
-
void
LSPMap
::
setModule
(const LSPValue &key, const LSPModule &module)¶ Associates an
LSPModule
with the given key. The key must not be nil. If the map already contained an association for the key, the previous value is replaced.Parameters: - key – LSPValue key.
- module – LSPModule value.
-
void
LSPMap
::
unset
(lsint key)¶ Unsets the given key in the map if present. If the key doesn’t exist in the map, does nothing.
Parameters: key – Integer key.
-
void
LSPMap
::
unset
(const std::string &key)¶ Unsets the given key in the map if present. If the key doesn’t exist in the map, does nothing.
Parameters: key – String key.
-
void
LSPMap
::
unset
(const LSPValue &key)¶ Unsets the given key in the map if present. If the key doesn’t exist in the map, does nothing.
Parameters: key – LSPValue key.
-
bool
LSPMap
::
isDefined
(lsint key) const¶ Returns true if the given key is defined in the map.
Parameters: key – Integer key.
-
bool
LSPMap
::
isDefined
(const std::string &key) const¶ Returns true if the given key is defined in the map.
Parameters: key – String key.
-
bool
LSPMap
::
isDefined
(const LSPValue &key) const¶ Returns true if the given key is defined in the map.
Parameters: key – LSPValue key.
-
LSPMapIterator
LSPMap
::
iterator
() const¶ Returns a new iterator to the elements of this map.