libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
crn::Map Class Reference

Data map class. More...

#include <CRNMap.h>

+ Inheritance diagram for crn::Map:
+ Collaboration diagram for crn::Map:

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)
 
Mapoperator= (const Map &other)
 
 Map (Map &&)=default
 
Mapoperator= (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< StringGetKeys () 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)
 
- Public Member Functions inherited from crn::Object
virtual ~Object ()=default
 

Detailed Description

Data map class.

Author
Yann LEYDIER
Date
April 2007
Version
0.3

Definition at line 42 of file CRNMap.h.

Member Typedef Documentation

using crn::Map::const_iterator = std::map<String, SObject>::const_iterator

const_iterator on the contents of the container

Definition at line 93 of file CRNMap.h.

const_reverse_iterator on the contents of the container

Definition at line 113 of file CRNMap.h.

using crn::Map::iterator = std::map<String, SObject>::iterator

iterator on the contents of the container

Definition at line 72 of file CRNMap.h.

using crn::Map::pair = std::pair<const crn::String, SObject>

A (key, value) pair.

Definition at line 120 of file CRNMap.h.

using crn::Map::reverse_iterator = std::map<String, SObject>::reverse_iterator

reverse_iterator on the contents of the container

Definition at line 106 of file CRNMap.h.

Constructor & Destructor Documentation

Map::Map ( )
default

Default constructor.

Default constructor

Parameters
[in]protosthe mandatory protocols for the contents
Map::~Map ( )
overridevirtualdefault

Destructor.

Destructor

Map::Map ( const Map other)

Definition at line 41 of file CRNMap.cpp.

crn::Map::Map ( Map &&  )
default
crn::Map::Map ( xml::Element el)
inline

Definition at line 146 of file CRNMap.h.

Member Function Documentation

iterator crn::Map::begin ( )
inline

Returns an iterator to the first element.

Definition at line 86 of file CRNMap.h.

const_iterator crn::Map::begin ( ) const
inline

Returns a const iterator to the first element.

Definition at line 95 of file CRNMap.h.

const_iterator crn::Map::cbegin ( ) const
inline

Returns a const iterator to the first element.

Definition at line 99 of file CRNMap.h.

const_iterator crn::Map::cend ( ) const
inline

Returns a const iterator after the last element.

Definition at line 101 of file CRNMap.h.

void crn::Map::Clear ( )
inlinenoexcept

Empties the map.

Definition at line 83 of file CRNMap.h.

void Map::Deserialize ( xml::Element el)

Reads from an XML node if applicable.

Unsafe load

Exceptions
ExceptionProtocolthe content of the map is not serializable
ExceptionInvalidArgumentnot a Map
Parameters
[in]elthe element to load
Returns
true if success, false else

Definition at line 187 of file CRNMap.cpp.

iterator crn::Map::end ( )
inline

Returns an iterator after the last element.

Definition at line 88 of file CRNMap.h.

const_iterator crn::Map::end ( ) const
inline

Returns a const iterator after the last element.

Definition at line 97 of file CRNMap.h.

iterator crn::Map::Find ( const String key)
inline

Returns an iterator to a specific key.

Definition at line 90 of file CRNMap.h.

const_iterator crn::Map::Find ( const String key) const
inline

Returns a const_iterator to a specific key.

Definition at line 103 of file CRNMap.h.

String Map::FirstKey ( ) const

Returns the first (lowest) key.

Returns the first (lowest) key

Returns
the first (lowest) key or empty string if the map is empty

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

Parameters
[in]sthe key
Returns
a pointer to the object or nullptr if key not found

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

Parameters
[in]sthe key
Returns
a pointer to the object or nullptr if key not found

Definition at line 76 of file CRNMap.cpp.

std::set< String > Map::GetKeys ( ) const

Returns all keys.

Returns all keys

Returns
a vector of keys

Definition at line 236 of file CRNMap.cpp.

bool crn::Map::IsEmpty ( ) const
inlinenoexcept

Tests if the map is empty.

Definition at line 58 of file CRNMap.h.

String Map::LastKey ( ) const

Returns the last (greatest) key.

Returns the last (greatest) key

Returns
the last (greatest) key or empty string if the map is empty

Definition at line 263 of file CRNMap.cpp.

void Map::Load ( const Path fname)

Definition at line 282 of file CRNMap.cpp.

Map & Map::operator= ( const Map other)

Definition at line 47 of file CRNMap.cpp.

Map& crn::Map::operator= ( Map &&  )
default
SObject& crn::Map::operator[] ( const String s)
inline

Returns an object from index. No constraint check is performed if the reference is used as a lvalue.

Warning
No constraint check is performed if the reference is used as a lvalue.

Definition at line 63 of file CRNMap.h.

reverse_iterator crn::Map::rbegin ( )
inline

Returns a reverse iterator to the last element.

Definition at line 108 of file CRNMap.h.

const_reverse_iterator crn::Map::rbegin ( ) const
inline

Returns a const reverse iterator to the last element.

Definition at line 115 of file CRNMap.h.

void Map::Remove ( const String key)

Removes an element (safe)

Remove an object from the container by key

Exceptions
ExceptionNotFoundkey not found
Parameters
[in]keythe 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

Exceptions
ExceptionNotFoundobject not found
Parameters
[in]obja 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)

Exceptions
ExceptionDomaininvalid iterator
Parameters
[in]itan iterator to the element to remove

Definition at line 135 of file CRNMap.cpp.

void Map::Remove ( iterator  first,
iterator  end_ 
)

Removes an element (safe)

Removes a list of elements (safe)

Exceptions
ExceptionDomaininvalid first iterator
ExceptionInvalidArgumentinvalid range
Parameters
[in]firstthe first element to remove
[in]end_the element after the last element to remove
Returns
true if success, false else

Definition at line 152 of file CRNMap.cpp.

reverse_iterator crn::Map::rend ( )
inline

Returns a reverse iterator before the first element.

Definition at line 110 of file CRNMap.h.

const_reverse_iterator crn::Map::rend ( ) const
inline

Returns a const reverse iterator before the first element.

Definition at line 117 of file CRNMap.h.

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

Exceptions
ExceptionProtocolthe content of the map is not serializable
Parameters
[in]parentthe parent element to which we will add the new element
Returns
The newly created 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

Parameters
[in]keythe key of the object to add
[in]valuethe object to add

Definition at line 92 of file CRNMap.cpp.

size_t crn::Map::Size ( ) const
inlinenoexcept

Returns the number of data objects in the map.

Definition at line 56 of file CRNMap.h.

std::map<String, SObject> crn::Map::Std ( )
inline

Definition at line 132 of file CRNMap.h.

void Map::Swap ( Map other)
noexcept

Swaps contents with another map.

Swaps contents with another map

Parameters
[in]otherthe map to swap with

Definition at line 277 of file CRNMap.cpp.


The documentation for this class was generated from the following files: