AnyMap

class cppmicroservices::AnyMap

A map data structure with support for compound keys.

This class adds convenience functions on top of the any_map class. The any_map is a recursive data structure, and its values can be retrieved via standard map functions or by using a dotted key notation specifying a compound key.

See
any_map

Inherits from cppmicroservices::any_map

Public Functions

AnyMap(map_type type)
AnyMap(const ordered_any_map &m)
AnyMap(const unordered_any_map &m)
AnyMap(const unordered_any_cimap &m)
map_type GetType() const

Get the underlying STL container type.

Return
The STL container type holding the map data.

mapped_type &AtCompoundKey(const key_type &key)

Get a key’s value, using a compound key notation.

A compound key consists of one or more key names, concatenated with the ‘.’ (dot) character. Each key except the last requires the referenced Any object to be of type AnyMap or std::vector<Any>. Containers of type std::vector<Any> are indexed using 0-based numerical key names.

For example, a AnyMap object holding data of the following layout

{
  one: 1,
  two: "two",
  three: {
    a: "anton",
    b: [ 3, 8 ]
  }
}
can be queried using the following notation:
map.AtCompoundKey("one");       // returns Any(1)
map.AtCompoundKey("three.a");   // returns Any(std::string("anton"))
map.AtCompoundKey("three.b.1"); // returns Any(8)

Return
A reference to the key’s value.
Parameters
  • key: The key hierachy to query.
Exceptions
  • std::invalid_argument: if the Any value for a given key is not of type AnyMap or std::vector<Any>.
  • std::out_of_range: if the key is not found or a numerical index would fall out of the range of an int type.

const mapped_type &AtCompoundKey(const key_type &key) const
class cppmicroservices::any_map

A map data structure which wraps different STL map types.

This is a convenience class providing a STL associative container interface for different underlying container types. Supported underlying types are

This class provides most of the STL functions for associated containers, including forward iterators. It is typically not instantiated by clients directly, but obtained via framework API calls, returning an AnyMap sub-class instance.

See
AnyMap

Subclassed by cppmicroservices::AnyMap

Public Types

enum map_type

Values:

ORDERED_MAP
UNORDERED_MAP
UNORDERED_MAP_CASEINSENSITIVE_KEYS
typedef std::string key_type
typedef Any mapped_type
typedef std::pair<const key_type, mapped_type> value_type
typedef std::size_t size_type
typedef std::ptrdiff_t difference_type
typedef value_type &reference
typedef value_type const &const_reference
typedef value_type *pointer
typedef value_type const *const_pointer
typedef std::map<std::string, Any> ordered_any_map
typedef std::unordered_map<std::string, Any> unordered_any_map
typedef std::unordered_map<std::string, Any, detail::any_map_cihash, detail::any_map_ciequal> unordered_any_cimap
typedef iter iterator
typedef const_iter const_iterator

Public Functions

any_map(map_type type)
any_map(const ordered_any_map &m)
any_map(const unordered_any_map &m)
any_map(const unordered_any_cimap &m)
any_map(const any_map &m)
any_map &operator=(const any_map &m)
~any_map()
iter begin()
const_iter begin() const
const_iter cbegin() const
iter end()
const_iter end() const
const_iter cend() const
bool empty() const
size_type size() const
size_type count(const key_type &key) const
void clear()
mapped_type &at(const key_type &key)
const mapped_type &at(const key_type &key) const
mapped_type &operator[](const key_type &key)
mapped_type &operator[](key_type &&key)
std::pair<iterator, bool> insert(const value_type &value)
const_iterator find(const key_type &key) const

Protected Attributes

map_type type
class const_iter

Inherits from cppmicroservices::any_map::iterator_base

Public Types

typedef any_map::const_reference reference
typedef any_map::const_pointer pointer
typedef const_iter iterator

Public Functions

const_iter()
const_iter(const iterator &it)
const_iter(const iter &it)
~const_iter()
const_iter(ociter &&it)
const_iter(uociter &&it, iter_type type)
reference operator*() const
pointer operator->() const
iterator &operator++()
iterator operator++(int)
bool operator==(const iterator &x) const
bool operator!=(const iterator &x) const

Public Members

ociter *o
uociter *uo
uocciiter *uoci
class iter

Inherits from cppmicroservices::any_map::iterator_base

Public Types

typedef any_map::reference reference
typedef any_map::pointer pointer
typedef iter iterator

Public Functions

iter()
iter(const iter &it)
~iter()
iter(oiter &&it)
iter(uoiter &&it, iter_type type)
reference operator*() const
pointer operator->() const
iterator &operator++()
iterator operator++(int)
bool operator==(const iterator &x) const
bool operator!=(const iterator &x) const

Public Members

oiter *o
uoiter *uo
uociiter *uoci