|
msl 1.3.0
|
Generic key-value associative container.
#include <Dictionary.h>
Public Types | |
| using | container = std::unordered_map<std::string, boost::any> |
| Underlying container. | |
| using | value_type = container::value_type |
| Pair of (key, value). | |
| using | iterator = container::iterator |
| Iterator on the elements. | |
| using | const_iterator = container::const_iterator |
| Read-only iterator on the elements. | |
| using | Pointer = std::shared_ptr<Dictionary> |
| Reference-counted pointer to Dictionary. | |
| using | ConstPointer = std::shared_ptr<Dictionary const> |
| Reference-counted constant pointer to Dictionary. | |
Public Member Functions | |
| Dictionary (std::initializer_list< container::value_type > values) | |
| Create a dictionary from pairs of (key, value). | |
| Dictionary (Dictionary const &)=default | |
| Dictionary (Dictionary &&)=default | |
| Dictionary & | operator= (Dictionary const &)=default |
| Dictionary & | operator= (Dictionary &&)=default |
| container::mapped_type | get (std::string const &key) const |
| Return a generic value. | |
| template<typename T> | |
| T const & | get (std::string const &key) const |
| Return a typed value (read-only). | |
| template<typename T> | |
| T & | get (std::string const &key) |
| Return a typed value. | |
| bool | has (std::string const &key) const |
| Check whether the key is in the dictionary. | |
| boost::typeindex::type_info const & | type (std::string const &key) const |
| Return the type of a key. | |
| template<typename T> | |
| Dictionary & | set (std::string const &key, T &&value) |
| Set the value at given key, create it if required. | |
| bool | empty () const |
| Check whether the dictionary is empty. | |
| size_t | size () const |
| Return the number of items in the dictionary. | |
| iterator | begin () |
| Return a read-write iterator to the first element. | |
| const_iterator | begin () const |
| Return a read-only iterator to the first element. | |
| const_iterator | cbegin () const |
| Return a read-only iterator to the first element. | |
| iterator | end () |
| Return a read-write iterator past the last element. | |
| const_iterator | end () const |
| Return a read-only iterator past the last element. | |
| const_iterator | cend () const |
| Return a read-only iterator past the last element. | |
| Dictionary & | clear () |
| Erases all elements. | |
| Dictionary & | insert (std::initializer_list< value_type > &&data) |
| Inserts elements. | |
Static Public Member Functions | |
| static std::shared_ptr< Dictionary > | New (std::initializer_list< value_type > &&data) |
| Create a dictionary from pairs of (key, value). | |
| container::mapped_type msl::Dictionary::get | ( | std::string const & | key | ) | const |
Return a generic value.
Raise an exception if the key is not in the dictionary
|
inline |
Return a typed value (read-only).
Raise an exception if the key is not in the dictionary or if the type is wrong
|
inline |
Return a typed value.
Raise an exception if the key is not in the dictionary or if the type is wrong
| boost::typeindex::type_info const & msl::Dictionary::type | ( | std::string const & | key | ) | const |
Return the type of a key.
Raise an exception if the key is not in the dictionary