![]() |
Safir SDK Core
|
Container class for dictionaries of key value pairs. More...
#include <Safir/Dob/Typesystem/DictionaryContainer.h>
Public Types | |
typedef KeyT | KeyType |
typedef ValT | ValueContainerType |
typedef ValueContainerType::ContainedType | ContainedType |
typedef std::map< KeyType, ValueContainerType > | StorageType |
typedef StorageType::const_iterator | const_iterator |
typedef StorageType::iterator | iterator |
typedef StorageType::value_type | value_type |
Public Member Functions | |
DictionaryContainer () | |
Default Constructor. | |
bool | IsNull () const override |
Is the container set to null? | |
void | SetNull () override |
Set the container to null. | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
iterator | find (const KeyType &key) |
const_iterator | find (const KeyType &key) const |
size_t | size () const override |
Get the size of the dictionary, i.e number of contained keys. | |
bool | empty () const override |
Check if dictionary is empty. | |
size_t | count (const KeyType &key) const |
ValueContainerType & | operator[] (const KeyType &key) |
ValueContainerType & | at (const KeyType &key) |
Like operator[], but throws std::out_of_range if key is not in dictionary. | |
const ValueContainerType & | at (const KeyType &key) const |
Like operator[], but throws std::out_of_range if key is not in dictionary. | |
bool | IsChanged () const override |
IsChanged - Check if the dictionary has changed. | |
void | SetChanged (const bool changed) override |
SetChanged - Set the change state of the dictionary. | |
void | clear () |
clear - Clear the dictionary, i.e remove all keys/values. | |
void | Insert (const KeyType &key, const ContainedType &val) |
size_t | erase (const KeyType &key) |
void | Copy (const ContainerBase &that) override |
Copy - Copy all the members from "that" into "this". | |
Reflection part. | |
These methods allow applications to manipulate the members of objects without having been compiled against it. There should be no reason for most applications to use these methods. | |
const ContainerBase & | GetValueContainerAt (const size_t index) const override |
Const version of GetValueContainerAt() | |
ContainerBase & | GetValueContainerAt (const size_t index) override |
Get the container of the value at a particular position in the dictionary. | |
![]() | |
DictionaryContainerBase () | |
Default Constructor. | |
bool | IsChangedHere () const |
Is the change flag in the container set? | |
void | SetChangedHere (const bool changed) |
Set the change flag in the container. | |
template<class KeyT > | |
ContainerBase & | InsertNull (const KeyT &key) |
Adds a new key to the dictionary and return the value container. | |
template<class KeyT > | |
const KeyT & | GetKeyAt (const size_t index) const |
Get the key at a particular position in the dictionary. | |
![]() | |
constexpr | ContainerBase () |
Default Constructor. | |
constexpr | ContainerBase (const ContainerBase &)=default |
Copy constructor. | |
virtual | ~ContainerBase () |
Virtual destructor. | |
Protected Member Functions | |
ContainerBase & | InsertNullInternal (const void *key, const std::type_info &typeInfo) override |
const void * | GetKeyAtInternal (const size_t index) const override |
![]() | |
ContainerBase & | operator= (const ContainerBase &other) |
Copy assignment operator. | |
Additional Inherited Members | |
![]() | |
bool | m_bIsChanged |
The variable containing the change flag. | |
Container class for dictionaries of key value pairs.
A dictionary is a collection of values that can dynamically grow or shrink in size. The whole container has a change flag that will automatically be set when values are added, removed or changed.
typedef StorageType::const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::const_iterator |
typedef ValueContainerType::ContainedType Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::ContainedType |
typedef StorageType::iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::iterator |
typedef KeyT Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::KeyType |
typedef std::map<KeyType, ValueContainerType> Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::StorageType |
typedef StorageType::value_type Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::value_type |
typedef ValT Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::ValueContainerType |
Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::DictionaryContainer | ( | ) |
Default Constructor.
Construct a container that is not changed and not null.
ValueContainerType & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at | ( | const KeyType & | key | ) |
Like operator[], but throws std::out_of_range if key is not in dictionary.
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at().
const ValueContainerType & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at | ( | const KeyType & | key | ) | const |
Like operator[], but throws std::out_of_range if key is not in dictionary.
Const version
References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at().
iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::begin | ( | ) |
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Copy().
const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::begin | ( | ) | const |
void Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::clear | ( | ) |
clear - Clear the dictionary, i.e remove all keys/values.
After a call to clear the dictionary will be empty and hence it will be null too.
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Copy(), and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::SetNull().
|
overridevirtual |
Copy - Copy all the members from "that" into "this".
Types must be the same for this to work!
that | [in] - The object to copy into this. |
Note: if types are not compatible the behaviour is undefined.
Implements Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::begin(), Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::clear(), Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::end(), and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
size_t Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::count | ( | const KeyType & | key | ) | const |
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::erase().
|
overridevirtual |
Check if dictionary is empty.
Implements Safir::Dob::Typesystem::DictionaryContainerBase.
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::IsNull().
iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::end | ( | ) |
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Copy().
const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::end | ( | ) | const |
size_t Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::erase | ( | const KeyType & | key | ) |
References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::count(), and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::find | ( | const KeyType & | key | ) |
const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::find | ( | const KeyType & | key | ) | const |
|
overrideprotectedvirtual |
Implements Safir::Dob::Typesystem::DictionaryContainerBase.
References __WFILE__, and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::size().
|
overridevirtual |
Const version of GetValueContainerAt()
Implements Safir::Dob::Typesystem::DictionaryContainerBase.
References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt().
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt().
|
overridevirtual |
Get the container of the value at a particular position in the dictionary.
Note that the order of keys in the dictionary is not guaranteed. This is not a particularly "cheap" way of accessing the contents of a dictionary. Much better to use the iterators in the implementing class.
index | an index between 0 and size(). |
Implements Safir::Dob::Typesystem::DictionaryContainerBase.
References __WFILE__, and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::size().
void Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Insert | ( | const KeyType & | key, |
const ContainedType & | val ) |
|
overrideprotectedvirtual |
Implements Safir::Dob::Typesystem::DictionaryContainerBase.
References __WFILE__, and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
|
overridevirtual |
IsChanged - Check if the dictionary has changed.
Reimplemented from Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
|
overridevirtual |
Is the container set to null?
Implements Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::empty().
ValueContainerType & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::operator[] | ( | const KeyType & | key | ) |
|
overridevirtual |
SetChanged - Set the change state of the dictionary.
changed | [in] - If true, the dictionary is set to changed, it is set to not changed. |
Reimplemented from Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
|
overridevirtual |
Set the container to null.
Implements Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::clear().
|
overridevirtual |
Get the size of the dictionary, i.e number of contained keys.
Implements Safir::Dob::Typesystem::DictionaryContainerBase.
Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetKeyAtInternal(), and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt().