Hash-map of meta-information of the form key = value pair or key = {value1, ..., valueN}
More...
#include <MetainfoMap.h>
Public Types | |
| using | map_type = MetainfoMapImpl::map_type |
| Type of the underlying hash-map. | |
| using | value_type = map_type::value_type |
Type of an entry of the MetainfoMapImpl (std::pair<std::string, meta_info_value>) | |
| using | key_type = map_type::key_type |
Type of the key (std::string) | |
| using | mapped_type = map_type::mapped_type |
Type of the value (MetainfoMapImpl::Value) | |
| using | size_type = map_type::size_type |
An unsigned integral type (std::size_t) | |
| using | iterator = map_type::iterator |
A forward iterator to value_type | |
| using | const_iterator = map_type::const_iterator |
A forward iterator to const value_type | |
Public Member Functions | |
| meta_info_map () | |
| Default constructor (empty map) | |
| meta_info_map (std::initializer_list< value_type > list) | |
| Construct from initalizer-list. More... | |
| meta_info_map (const meta_info_map &)=default | |
| Copy constructor. More... | |
| meta_info_map (meta_info_map &&)=default | |
| Move constructor. | |
| meta_info_map & | operator= (const meta_info_map &)=default |
| Copy assignment. More... | |
| meta_info_map & | operator= (meta_info_map &&)=default |
| Move assignment. | |
| meta_info_map & | operator= (std::initializer_list< value_type > list) |
| Construct from initalizer-list. More... | |
| meta_info_map | clone () const |
| Clone the current meta_info_map object by performing a deep copy. More... | |
| meta_info_map (const std::shared_ptr< MetainfoMapImpl > &map) | |
| Construct with MetainfoMapImpl (internal use) | |
| template<class StringType > | |
| bool | has_key (StringType &&key) const noexcept |
| Check if key exists in the map. More... | |
| std::vector< std::string > | keys () const |
| Get vector of strings of all available keys. More... | |
| std::vector< TypeID > | types () const |
| Get vector of all available keys. More... | |
| template<class KeyType , class ValueType > | |
| bool | insert (KeyType &&key, ValueType &&value) noexcept |
| Insert a new element in the map. More... | |
| template<class ValueType , class KeyType > | |
| ValueType | as (KeyType &&key) const |
Convert value of element with key to type T More... | |
| std::size_t | size () const noexcept |
| Returns the number of elements in the meta_info_map. | |
| bool | empty () const noexcept |
| Returns a bool value indicating whether the meta_info_map is empty, i.e. whether its size is 0. | |
| void | clear () noexcept |
| All the elements in the meta_info_map are dropped: their destructors are called, and they are removed from the container, leaving it with a size of 0. | |
| iterator | begin () noexcept |
| Returns an iterator pointing to the first element in the meta_info_map. | |
| const_iterator | begin () const noexcept |
| iterator | end () noexcept |
| Returns an iterator pointing to the past-the-end element in the meta_info_map. | |
| const_iterator | end () const noexcept |
| void | swap (meta_info_map &other) noexcept |
| Swap with other. | |
| bool | operator== (const meta_info_map &right) const noexcept |
| Test for equality. | |
| bool | operator!= (const meta_info_map &right) const noexcept |
| Test for inequality. | |
| const std::shared_ptr< MetainfoMapImpl > & | impl () const |
| Get implementation pointer. | |
| template<class StringType > | |
| iterator | find (StringType &&key) noexcept |
Search the container for an element with a key equivalent to key and return an iterator to it if found, otherwise it returns an iterator to meta_info_map::end. More... | |
| template<class StringType > | |
| const_iterator | find (StringType &&key) const noexcept |
| iterator | erase (const_iterator position) |
| Removes from the MetainfoMapImpl either a single element or a range of elements [first,last) | |
| size_type | erase (const key_type &key) |
| iterator | erase (const_iterator first, const_iterator last) |
| mapped_type & | operator[] (const key_type &key) noexcept |
| Return a reference to mapped value given by key. | |
| mapped_type & | operator[] (key_type &&key) noexcept |
| mapped_type & | at (const key_type &key) |
| Return a reference to mapped value given by key. More... | |
| const mapped_type & | at (const key_type &key) const |
Friends | |
| std::ostream & | operator<< (std::ostream &stream, const meta_info_map &s) |
| Convert to stream. | |
Hash-map of meta-information of the form key = value pair or key = {value1, ..., valueN}
They keys are strings (std::string), while the values can be booleans, integers (32 and 64 bit), floating point numbers (32 and 64 bit) or strings.
Definition at line 34 of file MetainfoMap.h.
|
inline |
|
default |
Copy constructor.
This performs a shallow copy, meaning the objects share the same underlying MetainfoMapImpl. To deep copy the object call meta_info_map::clone().
Example
|
inline |
Convert value of element with key to type T
If the type T is different than the internally stored type, the function does its best to convert the value to T in a meaningful way.
| key | Key of the new element |
T| exception | key does not exist or conversion results in truncation of the value |
Definition at line 214 of file MetainfoMap.h.
|
inline |
Return a reference to mapped value given by key.
| exception | No mapped value with given key exists |
Definition at line 238 of file MetainfoMap.h.
|
inline |
Clone the current meta_info_map object by performing a deep copy.
Example: To deep copy a meta_info_map
Definition at line 135 of file MetainfoMap.h.
|
inlinenoexcept |
Search the container for an element with a key equivalent to key and return an iterator to it if found, otherwise it returns an iterator to meta_info_map::end.
| key | Key to be searched for |
Definition at line 180 of file MetainfoMap.h.
|
inlinenoexcept |
Check if key exists in the map.
| key | Key to be searched for |
Definition at line 148 of file MetainfoMap.h.
|
inlinenoexcept |
Insert a new element in the map.
The element is inserted only if its key is not equivalent to the key of any other element already in the map (keys in a MetainfoMapImpl are unique).
| key | Key of the new element |
| value | Object to be copied to (or moved as) the value of the new element |
Definition at line 199 of file MetainfoMap.h.
|
inline |
Get vector of strings of all available keys.
To get the corresponding TypeIDs, use meta_info_map::types().
Definition at line 160 of file MetainfoMap.h.
|
default |
Copy assignment.
This performs a shallow copy, meaning the objects share the same underlying MetainfoMapImpl. To deep copy the object call meta_info_map::clone().
Example
|
inline |
|
inline |
Get vector of all available keys.
To get the corresponding keys, use meta_info_map::keys().
Definition at line 169 of file MetainfoMap.h.