template class Poco::Dynamic::Struct
Overview
Struct allows to define a named collection of Var objects. More…
#include <Struct.h> template <typename K> class Struct { public: // typedefs typedef std::map<K, Var> Data; typedef std::set<K> NameSet; typedef Data::iterator Iterator; typedef Data::const_iterator ConstIterator; typedef Struct<K>::Data::value_type ValueType; typedef Struct<K>::Data::size_type SizeType; typedef std::pair<typename Struct<K>::Iterator, bool> InsRetVal; typedef Poco::SharedPtr<Struct<K>> Ptr; // construction Struct(); Struct(const Data& val); template <typename T> Struct(const std::map<K, T>& val); // methods Var& operator[](const K& name); const Var& operator[](const K& name) const; bool contains(const K& name) const; Iterator find(const K& name); ConstIterator find(const K& name) const; Iterator end(); ConstIterator end() const; Iterator begin(); ConstIterator begin() const; template <typename T> InsRetVal insert( const K& key, const T& value ); InsRetVal insert(const ValueType& aPair); SizeType erase(const K& key); void erase(Iterator& it); bool empty() const; SizeType size() const; NameSet members() const; std::string toString(); };
Detailed Documentation
Struct allows to define a named collection of Var objects.
Construction
Struct()
Creates an empty Struct.
Struct(const Data& val)
Creates the Struct from the given value.
Methods
Var& operator[](const K& name)
Returns the Var with the given name, creates an entry if not found.
const Var& operator[](const K& name) const
Returns the Var with the given name, throws a NotFoundException if the data member is not found.
bool contains(const K& name) const
Returns true if the Struct contains a member with the given name.
Iterator find(const K& name)
Returns an iterator, pointing to the <name, Var> pair containing the element, or it returns end() if the member was not found.
ConstIterator find(const K& name) const
Returns a const iterator, pointing to the <name, Var> pair containing the element, or it returns end() if the member was not found.
Iterator end()
Returns the end iterator for the Struct.
ConstIterator end() const
Returns the end const iterator for the Struct.
Iterator begin()
Returns the begin iterator for the Struct.
ConstIterator begin() const
Returns the begin const iterator for the Struct.
template <typename T> InsRetVal insert( const K& key, const T& value )
Inserts a <name, Var> pair into the Struct, returns a pair containing the iterator and a boolean which indicates success or not (is true, when insert succeeded, false, when already another element was present, in this case Iterator points to that other element)
InsRetVal insert(const ValueType& aPair)
Inserts a <name, Var> pair into the Struct, returns a pair containing the iterator and a boolean which indicates success or not (is true, when insert succeeded, false, when already another element was present, in this case Iterator points to that other element)
SizeType erase(const K& key)
Erases the element if found, returns number of elements deleted.
void erase(Iterator& it)
Erases the element at the given position.
bool empty() const
Returns true if the Struct doesn’t contain any members.
SizeType size() const
Returns the number of members the Struct contains.
NameSet members() const
Returns a sorted collection containing all member names.