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. Theany_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
(ordered_any_map &&m)¶
-
AnyMap
(const unordered_any_map &m)¶
-
AnyMap
(unordered_any_map &&m)¶
-
AnyMap
(const unordered_any_cimap &m)¶
-
AnyMap
(unordered_any_cimap &&m)¶
-
map_type
GetType
() const¶ Get the underlying STL container type.
- Return
- The STL container type holding the map data.
-
const mapped_type &
AtCompoundKey
(const key_type &key) const¶ 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
orstd::vector<Any>
. Containers of typestd::vector<Any>
are indexed using 0-based numerical key names.For example, a
AnyMap
object holding data of the following layoutcan be queried using the following notation:{ one: 1, two: "two", three: { a: "anton", b: [ 3, 8 ] } }
map.AtCompoundKey("one"); // returns Any(1) map.AtCompoundKey("three.a"); // returns Any(std::string("anton")) map.AtCompoundKey("three.b.1"); // returns Any(8)
-
mapped_type
AtCompoundKey
(const key_type &key, mapped_type defaultValue) const¶ Return a key’s value, using a compound key notation if the key is found in the map or return the provided default value if the key is not found.
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
orstd::vector<Any>
. Containers of typestd::vector<Any>
are indexed using 0-based numerical key names.For example, a
AnyMap
object holding data of the following layoutcan be queried using the following notation:{ one: 1, two: "two", three: { a: "anton", b: [ 3, 8 ] } }
map.AtCompoundKey("one", Any()); // returns Any(1) map.AtCompoundKey("four", Any()); // returns Any() map.AtCompoundKey("three.a", Any()); // returns Any(std::string("anton")) map.AtCompoundKey("three.c", Any()); // returns Any() map.AtCompoundKey("three.b.1", Any()); // returns Any(8) map.AtCompoundKey("three.b.4", Any()); // returns Any()
- Return
- A copy of the key’s value.
- Parameters
key
: The key hierachy to query.defaultValue
: is the value to be returned if the key is not found
-
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
any_map::ordered_any_map
(a STL map)any_map::unordered_any_map
(a STL unordered map)any_map::unordered_any_cimap
(a STL unordered map with case insensitive key comparison)
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
-
using
key_type
= std::string¶
-
using
value_type
= std::pair<const key_type, mapped_type>¶
-
using
size_type
= std::size_t¶
-
using
difference_type
= std::ptrdiff_t¶
-
using
reference
= value_type&¶
-
using
const_reference
= const value_type&¶
-
using
pointer
= value_type *¶
-
using
const_pointer
= const value_type *¶
-
using
unordered_any_cimap
= std::unordered_map<std::string, Any, detail::any_map_cihash, detail::any_map_ciequal>¶
-
using
const_iterator
= const_iter¶
Public Functions
-
any_map
(const ordered_any_map &m)¶
-
any_map
(ordered_any_map &&m)¶
-
any_map
(const unordered_any_map &m)¶
-
any_map
(unordered_any_map &&m)¶
-
any_map
(const unordered_any_cimap &m)¶
-
any_map
(unordered_any_cimap &&m)¶
-
~any_map
()¶
-
const_iter
begin
() const¶
-
const_iter
cbegin
() const¶
-
const_iter
end
() const¶
-
const_iter
cend
() const¶
-
bool
empty
() 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¶ return the iterator to the value referenced by key
-
size_type
erase
(const key_type &key)¶ Erase entry for value for ‘key’.
- Return
- the number of elements erased.
- Parameters
key
: the key for the entry to Erase
-
class
const_iter
¶ Inherits from cppmicroservices::any_map::iterator_base
Public Types
-
using
reference
= any_map::const_reference¶
-
using
pointer
= any_map::const_pointer¶
-
using
iterator
= const_iter¶
-
using
-
class
iter
¶ Inherits from cppmicroservices::any_map::iterator_base
Public Types