Hash-map to query the meta-information of the registered fields. More...
#include <FieldMap.h>
Public Types | |
using | map_type = std::unordered_map< std::string, std::shared_ptr< FieldMetainfoImpl > > |
Type of the underlying hash-map. | |
using | value_type = map_type::value_type |
Type of an entry of the MetainfoMapImpl (std::pair<std::string, std::shared_ptr<FieldMetainfoImpl>> ) | |
using | key_type = map_type::key_type |
Type of the key (std::string ) i.e name of the fields. | |
using | mapped_type = map_type::mapped_type |
Type of the value (std::shared_ptr<FieldMetainfoImpl> ) | |
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 | |
FieldMap () | |
Default constructor (empty table) | |
FieldMap (const json::json jsonNode) | |
Construct from json. | |
FieldMap (const FieldMap &)=default | |
Copy constructor [deleted]. | |
FieldMap (FieldMap &&)=default | |
Move constructor. | |
FieldMap & | operator= (const FieldMap &)=default |
Copy assignment. | |
FieldMap & | operator= (FieldMap &&)=default |
Move assignment. | |
template<class StringType > | |
bool | hasField (StringType &&name) const noexcept |
Check if field with name name exists in the FieldMap. More... | |
template<class StringType > | |
iterator | findField (StringType &&name) noexcept |
Search the FieldMap for a field with name name and returns an iterator to it if found, otherwise returns an iterator to FieldMap::end. More... | |
template<class StringType > | |
const_iterator | findField (StringType &&name) const noexcept |
template<class StringType > | |
FieldMetainfoImpl & | getFieldMetainfoImplOf (StringType &&name) |
Get FieldMetainfoImpl of field name More... | |
template<class StringType > | |
const FieldMetainfoImpl & | getFieldMetainfoImplOf (StringType &&name) const |
template<class StringType > | |
std::shared_ptr< FieldMetainfoImpl > & | getFieldMetainfoImplPtrOf (StringType &&name) |
Get pointer to FieldMetainfoImpl of field name More... | |
template<class StringType > | |
const std::shared_ptr< FieldMetainfoImpl > & | getFieldMetainfoImplPtrOf (StringType &&name) const |
template<class StringType > | |
MetainfoMapImpl & | getMetainfoOf (StringType &&name) |
Get Metainfo of field with name name More... | |
template<class StringType > | |
const MetainfoMapImpl & | getMetainfoOf (StringType &&name) const |
template<class StringType > | |
std::vector< int > & | getDimsOf (StringType &&name) |
Get Dimensions of field with name name More... | |
template<class StringType > | |
const std::vector< int > & | getDimsOf (StringType &&name) const |
template<class StringType > | |
TypeID | getTypeOf (StringType &&name) const |
Get Type of field with name name More... | |
template<class StringType , typename... Args> | |
bool | insert (StringType &&key, Args &&... args) |
Insert a new field in the map. More... | |
std::size_t | size () const noexcept |
Returns the number of elements in the FieldMap. | |
bool | empty () const noexcept |
Returns a bool value indicating whether the FieldMap is empty. | |
void | clear () noexcept |
All the elements in the FieldMap 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 FieldMap. | |
const_iterator | begin () const noexcept |
iterator | end () noexcept |
Returns an iterator pointing to the past-the-end element in the FieldMap. | |
const_iterator | end () const noexcept |
void | swap (FieldMap &other) noexcept |
Swap with other. | |
bool | operator== (const FieldMap &right) const noexcept |
Test for equality. | |
bool | operator!= (const FieldMap &right) const noexcept |
Test for inequality. | |
json::json | toJSON () const |
Convert to JSON. | |
void | fromJSON (const json::json &jsonNode) |
Construct from JSON node. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const FieldMap &s) |
Convert to stream. | |
Hash-map to query the meta-information of the registered fields.
Definition at line 28 of file FieldMap.h.
|
inlinenoexcept |
Search the FieldMap for a field with name name
and returns an iterator to it if found, otherwise returns an iterator to FieldMap::end.
name | Name of the field |
FieldMap::end
Definition at line 85 of file FieldMap.h.
void serialbox::FieldMap::fromJSON | ( | const json::json & | jsonNode | ) |
Construct from JSON node.
Exception | JSON node is ill-formed |
Definition at line 31 of file FieldMap.cpp.
|
inline |
Get Dimensions of field with name name
name | Name of the field |
Definition at line 147 of file FieldMap.h.
|
inline |
Get FieldMetainfoImpl of field name
name | Name of the field |
Definition at line 99 of file FieldMap.h.
|
inline |
Get pointer to FieldMetainfoImpl of field name
name | Name of the field |
Definition at line 113 of file FieldMap.h.
|
inline |
Get Metainfo of field with name name
name | Name of the field |
Definition at line 133 of file FieldMap.h.
|
inline |
Get Type of field with name name
name | Name of the field |
Definition at line 167 of file FieldMap.h.
|
inlinenoexcept |
Check if field with name name
exists in the FieldMap.
name | Name of the field |
Definition at line 75 of file FieldMap.h.
|
inline |
Insert a new field in the map.
The field is inserted only if its name is not equivalent to the name of any other field already in the map (fields in a FieldMap are unique).
name | Name of the the new field |
Args | Arguments forwarded to the constructor of FieldMetainfoImpl |
Definition at line 183 of file FieldMap.h.