A map structure that can store nested maps of keys and values. By including serialization/nested_map.hpp, it gains serialization capability.
More...
#include <nested_map.hpp>
|
| nested_map ()=default |
| construct empty table
|
|
| nested_map (std::initializer_list< std::pair< const Key, Value > > init) |
|
nested_map & | operator= (const nested_map &other) |
| overwrite this nested_map with a copy of the other
|
|
void | merge (const nested_map &other) |
| merges the other nested_map into this
|
|
void | clear () |
|
template<typename T> |
std::enable_if< std::is_same< T, Value >::value, T >::type | get_mapped_value_or_default (const Key &key) const |
| Retrieves a value of type T associated with a given key from the map's values.
|
|
template<typename T> |
std::enable_if<!std::is_same< T, Value >::value, T >::type | get_mapped_value_or_default (const Key &value) const |
| Retrieves a value of type T associated with a given key from the map's values.
|
|
template<std::size_t T> |
auto | get_mapped_value_or_default (const Key &value) const |
| Retrieves a value from a std::variant associated with a given key, based on a type index.
|
|
template<typename T> |
std::enable_if< std::is_same< T, Value >::value, T >::type | get_mapped_value_or_throw (const Key &value, const std::string &error_msg={}) const |
| Retrieves the value associated with a given key, throwing an exception if the key is not found.
|
|
template<typename T> |
std::enable_if<!std::is_same< T, Value >::value, T >::type | get_mapped_value_or_throw (const Key &value, const std::string &error_msg={}) const |
| Retrieves the value associated with a given key, throwing an exception if the key is not found or the type does not match.
|
|
template<std::size_t T> |
auto | get_mapped_value_or_throw (const Key &value, const std::string &error_msg={}) const |
| Retrieves a value from a std::variant associated with a given key, based on a type index.
|
|
template<typename Key, typename Value>
struct cbeam::container::nested_map< Key, Value >
A map structure that can store nested maps of keys and values. By including serialization/nested_map.hpp, it gains serialization capability.
◆ key_type
template<typename Key, typename Value>
◆ mapped_type
template<typename Key, typename Value>
◆ nested_tables
template<typename Key, typename Value>
A map of keys to nested nested_map
instances, allowing hierarchical data organization.
◆ table_of_values
template<typename Key, typename Value>
A table mapping keys to values, capable of storing the actual data elements for serialization.
◆ nested_map() [1/2]
template<typename Key, typename Value>
◆ nested_map() [2/2]
template<typename Key, typename Value>
◆ clear()
template<typename Key, typename Value>
◆ get_mapped_value_or_default() [1/3]
template<typename Key, typename Value>
template<typename T>
std::enable_if< std::is_same< T, Value >::value, T >::type cbeam::container::nested_map< Key, Value >::get_mapped_value_or_default |
( |
const Key & | key | ) |
const |
|
inline |
Retrieves a value of type T associated with a given key from the map's values.
This function template fetches the value of type T associated with the specified key in the nested_map. If the key is not found in the map, a default-constructed value of type T is returned.
- Template Parameters
-
T | The type to be retrieved from the map's value. If the map uses std::variant as the value type, T is interpreted as the type to retrieve from the std::variant. |
- Parameters
-
key | The key whose value is to be retrieved. |
- Returns
- The value of type T associated with the key if it exists, or a default-constructed value of type T if the key is not found.
◆ get_mapped_value_or_default() [2/3]
template<typename Key, typename Value>
template<typename T>
std::enable_if<!std::is_same< T, Value >::value, T >::type cbeam::container::nested_map< Key, Value >::get_mapped_value_or_default |
( |
const Key & | value | ) |
const |
|
inline |
Retrieves a value of type T associated with a given key from the map's values.
This function template fetches the value of type T associated with the specified key in the nested_map. If the map's value type is std::variant, T is interpreted as the specific type to be extracted from the std::variant. If the key is not found in the map, a default-constructed value of type T is returned.
- Template Parameters
-
T | The type to be retrieved from the map's value. If T is not the value type of the nested_map, T is interpreted as the type to retrieve from the std::variant. |
- Parameters
-
key | The key whose value is to be retrieved. |
- Returns
- The value of type T associated with the key if it exists, or a default-constructed value of type T if the key is not found.
◆ get_mapped_value_or_default() [3/3]
template<typename Key, typename Value>
template<std::size_t T>
Retrieves a value from a std::variant associated with a given key, based on a type index.
This function template is specialized for maps where the value type is std::variant. It fetches the value associated with the specified key and extracts the value at the specified type index within the std::variant. If the key is not found in the map, a default-constructed value of the type at the given index in the std::variant is returned.
- Template Parameters
-
T | The type index within the std::variant from which to retrieve the value. |
- Parameters
-
key | The key whose value, a std::variant, is to be retrieved and inspected. |
- Returns
- The value at the specified type index within the std::variant if the key exists; otherwise, a default-constructed value of the corresponding type.
◆ get_mapped_value_or_throw() [1/3]
template<typename Key, typename Value>
template<typename T>
std::enable_if< std::is_same< T, Value >::value, T >::type cbeam::container::nested_map< Key, Value >::get_mapped_value_or_throw |
( |
const Key & | value, |
|
|
const std::string & | error_msg = {} ) const |
|
inline |
Retrieves the value associated with a given key, throwing an exception if the key is not found.
This function template attempts to retrieve the value associated with the specified key in the nested_map. This template specialization is used if T is the Value type. if the key is found, it returns the associated value, otherwise an exception is thrown.
- Template Parameters
-
T | The type of the value to be retrieved. |
- Parameters
-
key | The key whose value is to be retrieved. |
error_msg | Optional custom error message for the exception. If empty, a default message is used. |
- Returns
- The value associated with the key of type T.
- Exceptions
-
◆ get_mapped_value_or_throw() [2/3]
template<typename Key, typename Value>
template<typename T>
std::enable_if<!std::is_same< T, Value >::value, T >::type cbeam::container::nested_map< Key, Value >::get_mapped_value_or_throw |
( |
const Key & | value, |
|
|
const std::string & | error_msg = {} ) const |
|
inline |
Retrieves the value associated with a given key, throwing an exception if the key is not found or the type does not match.
This function template is specialized for maps where the value type is std::variant. It attempts to retrieve the value associated with the specified key in the nested_map. If T is one of the types in the variant, it attempts to retrieve the value of type T from the variant. If the key is not found, or if the type T is not compatible with the stored value, an exception is thrown.
- Template Parameters
-
T | The type of the value to be retrieved. |
- Parameters
-
key | The key whose value is to be retrieved. |
error_msg | Optional custom error message for the exception. If empty, a default message is used. |
- Returns
- The value associated with the key of type T.
- Exceptions
-
◆ get_mapped_value_or_throw() [3/3]
template<typename Key, typename Value>
template<std::size_t T>
Retrieves a value from a std::variant associated with a given key, based on a type index.
This function template is specialized for maps where the value type is std::variant. It fetches the value associated with the specified key and extracts the value at the specified type index within the std::variant. If the key is not found in the map, an exception is thrown.
- Template Parameters
-
T | The type index within the std::variant from which to retrieve the value. |
- Parameters
-
key | The key whose value, a std::variant, is to be retrieved and inspected. |
error_msg | Optional custom error message for the exception. If empty, a default message is used. |
- Returns
- The value at the specified type index within the std::variant if the key exists; otherwise, a default-constructed value of the corresponding type.
◆ merge()
template<typename Key, typename Value>
◆ operator=()
template<typename Key, typename Value>
overwrite this nested_map with a copy of the other
◆ data
template<typename Key, typename Value>
key value pairs of Value instances that store the actual data
◆ sub_tables
template<typename Key, typename Value>
The documentation for this struct was generated from the following file: