libcrn
3.9.5
A document image processing library
|
#include <CRNMap.h>
Public Types | |
using | iterator = std::map< String, SObject >::iterator |
iterator on the contents of the container More... | |
using | const_iterator = std::map< String, SObject >::const_iterator |
const_iterator on the contents of the container More... | |
using | reverse_iterator = std::map< String, SObject >::reverse_iterator |
reverse_iterator on the contents of the container More... | |
using | const_reverse_iterator = std::map< String, SObject >::const_reverse_iterator |
const_reverse_iterator on the contents of the container More... | |
using | pair = std::pair< const crn::String, SObject > |
A (key, value) pair. More... | |
Public Member Functions | |
Map () | |
Default constructor. More... | |
virtual | ~Map () override |
Destructor. More... | |
Map (const Map &other) | |
Map & | operator= (const Map &other) |
Map (Map &&)=default | |
Map & | operator= (Map &&)=default |
size_t | Size () const noexcept |
Returns the number of data objects in the map. More... | |
bool | IsEmpty () const noexcept |
Tests if the map is empty. More... | |
SObject & | operator[] (const String &s) |
Returns an object from index. No constraint check is performed if the reference is used as a lvalue. More... | |
SObject | Get (const String &s) |
Returns an object from index or nullptr if inexistent. More... | |
SCObject | Get (const String &s) const |
Returns an object from index or nullptr if inexistent. More... | |
void | Set (const String &key, SObject value) |
Sets a value for a key with constraints check. More... | |
void | Remove (const String &key) |
Removes an element (safe) More... | |
void | Remove (const SObject &obj) |
Removes an element (safe) More... | |
void | Remove (iterator it) |
Removes an element (safe) More... | |
void | Remove (iterator first, iterator end_) |
Removes an element (safe) More... | |
void | Clear () noexcept |
Empties the map. More... | |
iterator | begin () |
Returns an iterator to the first element. More... | |
iterator | end () |
Returns an iterator after the last element. More... | |
iterator | Find (const String &key) |
Returns an iterator to a specific key. More... | |
const_iterator | begin () const |
Returns a const iterator to the first element. More... | |
const_iterator | end () const |
Returns a const iterator after the last element. More... | |
const_iterator | cbegin () const |
Returns a const iterator to the first element. More... | |
const_iterator | cend () const |
Returns a const iterator after the last element. More... | |
const_iterator | Find (const String &key) const |
Returns a const_iterator to a specific key. More... | |
reverse_iterator | rbegin () |
Returns a reverse iterator to the last element. More... | |
reverse_iterator | rend () |
Returns a reverse iterator before the first element. More... | |
const_reverse_iterator | rbegin () const |
Returns a const reverse iterator to the last element. More... | |
const_reverse_iterator | rend () const |
Returns a const reverse iterator before the first element. More... | |
std::set< String > | GetKeys () const |
Returns all keys. More... | |
String | FirstKey () const |
Returns the first (lowest) key. More... | |
String | LastKey () const |
Returns the last (greatest) key. More... | |
void | Swap (Map &other) noexcept |
Swaps contents with another map. More... | |
std::map< String, SObject > | Std ()&& |
void | Deserialize (xml::Element &el) |
Reads from an XML node if applicable. More... | |
xml::Element | Serialize (xml::Element &parent) const |
Dumps to an XML node if applicable. More... | |
void | Load (const Path &fname) |
void | Save (const Path &fname) const |
Map (xml::Element &el) | |
![]() | |
virtual | ~Object ()=default |
using crn::Map::const_iterator = std::map<String, SObject>::const_iterator |
const_iterator on the contents of the container
using crn::Map::const_reverse_iterator = std::map<String, SObject>::const_reverse_iterator |
using crn::Map::iterator = std::map<String, SObject>::iterator |
using crn::Map::pair = std::pair<const crn::String, SObject> |
using crn::Map::reverse_iterator = std::map<String, SObject>::reverse_iterator |
|
default |
Default constructor.
Default constructor
[in] | protos | the mandatory protocols for the contents |
|
overridevirtualdefault |
Destructor.
Destructor
Map::Map | ( | const Map & | other | ) |
Definition at line 41 of file CRNMap.cpp.
|
default |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void Map::Deserialize | ( | xml::Element & | el | ) |
Reads from an XML node if applicable.
Unsafe load
ExceptionProtocol | the content of the map is not serializable |
ExceptionInvalidArgument | not a Map |
[in] | el | the element to load |
Definition at line 187 of file CRNMap.cpp.
|
inline |
|
inline |
|
inline |
Returns a const_iterator to a specific key.
String Map::FirstKey | ( | ) | const |
Returns the first (lowest) key.
Returns the first (lowest) key
Definition at line 250 of file CRNMap.cpp.
SObject Map::Get | ( | const String & | s | ) |
Returns an object from index or nullptr if inexistent.
Retrieves an object from key
[in] | s | the key |
Definition at line 61 of file CRNMap.cpp.
SCObject Map::Get | ( | const String & | s | ) | const |
Returns an object from index or nullptr if inexistent.
Retrieves an object from key
[in] | s | the key |
Definition at line 76 of file CRNMap.cpp.
std::set< String > Map::GetKeys | ( | ) | const |
Returns all keys.
Returns all keys
Definition at line 236 of file CRNMap.cpp.
|
inlinenoexcept |
String Map::LastKey | ( | ) | const |
Returns the last (greatest) key.
Returns the last (greatest) key
Definition at line 263 of file CRNMap.cpp.
void Map::Load | ( | const Path & | fname | ) |
Definition at line 282 of file CRNMap.cpp.
Definition at line 47 of file CRNMap.cpp.
|
inline |
|
inline |
|
inline |
void Map::Remove | ( | const String & | key | ) |
Removes an element (safe)
Remove an object from the container by key
ExceptionNotFound | key not found |
[in] | key | the key |
Definition at line 104 of file CRNMap.cpp.
void Map::Remove | ( | const SObject & | obj | ) |
Removes an element (safe)
Remove an object from the container by pointer
ExceptionNotFound | object not found |
[in] | obj | a pointer to the object to remove |
Definition at line 117 of file CRNMap.cpp.
void Map::Remove | ( | iterator | it | ) |
Removes an element (safe)
Removes an element (safe)
ExceptionDomain | invalid iterator |
[in] | it | an iterator to the element to remove |
Definition at line 135 of file CRNMap.cpp.
Removes an element (safe)
Removes a list of elements (safe)
ExceptionDomain | invalid first iterator |
ExceptionInvalidArgument | invalid range |
[in] | first | the first element to remove |
[in] | end_ | the element after the last element to remove |
Definition at line 152 of file CRNMap.cpp.
|
inline |
|
inline |
void Map::Save | ( | const Path & | fname | ) | const |
Definition at line 293 of file CRNMap.cpp.
xml::Element Map::Serialize | ( | xml::Element & | parent | ) | const |
Dumps to an XML node if applicable.
Unsafe save
ExceptionProtocol | the content of the map is not serializable |
[in] | parent | the parent element to which we will add the new element |
Definition at line 220 of file CRNMap.cpp.
void Map::Set | ( | const String & | key, |
SObject | value | ||
) |
Sets a value for a key with constraints check.
Adds an object
[in] | key | the key of the object to add |
[in] | value | the object to add |
Definition at line 92 of file CRNMap.cpp.
|
inlinenoexcept |
|
noexcept |
Swaps contents with another map.
Swaps contents with another map
[in] | other | the map to swap with |
Definition at line 277 of file CRNMap.cpp.