A template chunk class. More...
#include <Radiant/ConfigReader.hpp>
Public Types | |
|
typedef std::multimap< QString, T >::const_iterator | const_iterator |
| Constant iterator for traversing all elements. | |
|
typedef std::multimap< QString, T >::iterator | iterator |
| Iterator for traversing all elements. | |
Public Member Functions | |
| void | addChunk (const QString &id, const ChunkT< T > &v) |
| Adds a new child node to this chunk. More... | |
| iterator | begin () |
| Iterator to the first element. More... | |
| const_iterator | begin () const |
| Iterator to the first element. More... | |
| const std::multimap< QString, ChunkT< T > > * | chunks () const |
| Get the map of chunks. More... | |
| ChunkT () | |
| Creates an empty configuration chunk. | |
| ChunkT (const ChunkT ©) | |
| Copy constructor. More... | |
| void | clear () |
| Empties this chunk. | |
| bool | contains (const QString &id) const |
| Check if this chunk contains an element with given id. More... | |
| bool | containsVariant (const QString &variantName) const |
| Check if at least one variant with given name exists. More... | |
| void | dump (std::ostream &os, int indent=0) const |
| Dump chunk into stream May be specialized at each level. More... | |
| iterator | end () |
| Iterator to the after-the-end element. More... | |
| const_iterator | end () const |
| Iterator to the after-the-end element. More... | |
| T | get (const QString &id) const |
| Gets an element from the chunk. More... | |
| T | get (const QString &id, const QString &alternateId) const |
| Gets an element from the chunk. More... | |
| const ChunkT< T > & | getChunk (const QString &id) const |
| Gets a child chunk. More... | |
| bool | isEmpty () const |
| Check if the chunk is empty. More... | |
| int | numberOf (const QString &id) const |
| Returns the number of elements with given id/tag. More... | |
| ChunkT & | operator= (const ChunkT ©) |
| Copy a chunk with assignment. More... | |
| void | override (const QString &id, const T &v) |
| Adds an element to the chunk, erasing any elements with identical id After calling this method, the chunk will contain only one element this this id. More... | |
| void | set (const QString &id, const T &v) |
| Adds an element to the chunk. More... | |
| void | setClearFlag (bool clearF) |
| Sets the flag to inform whether an old value should be removed before defining a new. More... | |
| size_t | size () const |
| Number of elements. More... | |
| ~ChunkT () | |
| Destructor. | |
Static Public Member Functions | |
| static const QString & | getName (iterator &it) |
| Gets the name (id) from an iterator. More... | |
| static const QString & | getName (const_iterator &it) |
| Gets the name (id) from a constant iterator. More... | |
| static T & | getType (iterator &it) |
| Gets the data element from an iterator. More... | |
| static const T & | getType (const_iterator &it) |
| Gets the data element from an constant iterator. More... | |
A template chunk class.
A chunk contains elements that are named with (text string) identifiers. A chunk may contain multiple elements with the same identifier. These classes can be nested easily. Usually the two default levels are enough. A practical example:
| T | Type of things contained in Chunk |
|
inline |
Copy constructor.
| copy | Chunk to copy |
| void Radiant::ChunkT< T >::addChunk | ( | const QString & | id, |
| const ChunkT< T > & | v | ||
| ) |
Adds a new child node to this chunk.
| id | Id of the added chunk |
| v | Chunk to add |
|
inline |
Iterator to the first element.
|
inline |
Iterator to the first element.
|
inline |
Get the map of chunks.
| bool Radiant::ChunkT< T >::contains | ( | const QString & | id | ) | const |
Check if this chunk contains an element with given id.
| id | Id to check |
|
inline |
Check if at least one variant with given name exists.
| variantName | Name to search |
| void Radiant::ChunkT< T >::dump | ( | std::ostream & | os, |
| int | indent = 0 |
||
| ) | const |
Dump chunk into stream May be specialized at each level.
| os | output stream |
| indent | text indent for formatting |
|
inline |
Iterator to the after-the-end element.
|
inline |
Iterator to the after-the-end element.
| T Radiant::ChunkT< T >::get | ( | const QString & | id | ) | const |
Gets an element from the chunk.
| id | element id |
| T Radiant::ChunkT< T >::get | ( | const QString & | id, |
| const QString & | alternateId | ||
| ) | const |
Gets an element from the chunk.
| id | the primary id to search for |
| alternateId | if the primary id does not match, alternate is used |
| const ChunkT< T > & Radiant::ChunkT< T >::getChunk | ( | const QString & | id | ) | const |
Gets a child chunk.
If child with given id does not exist this returns proxy chunk.
| id | Id of the queried chunk |
|
inlinestatic |
Gets the name (id) from an iterator.
| it | Iterator to inspect |
|
inlinestatic |
Gets the name (id) from a constant iterator.
| it | Iterator to inspect |
|
inlinestatic |
Gets the data element from an iterator.
| it | Iterator to inspect |
|
inlinestatic |
Gets the data element from an constant iterator.
| it | Iterator to inspect |
|
inline |
Check if the chunk is empty.
| int Radiant::ChunkT< T >::numberOf | ( | const QString & | id | ) | const |
Returns the number of elements with given id/tag.
| id | Id to query |
|
inline |
Copy a chunk with assignment.
| copy | Chunk to assign to this |
| void Radiant::ChunkT< T >::override | ( | const QString & | id, |
| const T & | v | ||
| ) |
Adds an element to the chunk, erasing any elements with identical id After calling this method, the chunk will contain only one element this this id.
| id | id to override |
| v | chunk to override with |
| void Radiant::ChunkT< T >::set | ( | const QString & | id, |
| const T & | v | ||
| ) |
Adds an element to the chunk.
If there are other elements with the same id before, then
this element is added among those.
| id | element id |
| v | chunk to add |
| void Radiant::ChunkT< T >::setClearFlag | ( | bool | clearF | ) |
Sets the flag to inform whether an old value should be removed before defining a new.
| clearF | Are the old values removed when defining new value with same id |
|
inline |
Number of elements.