ArchiveElement defines the serialization API. More...
#include <Valuable/Archive.hpp>
Public Types | |
| typedef Valuable::ArchiveIterator | Iterator |
| Child iterator for ArchiveElement. | |
Public Member Functions | |
| void | add (const ArchiveElement &element) |
| Adds a new child element. More... | |
| void | add (const QString &name, const QString &value) |
| Writes a new named attribute, name should be unique along this object. More... | |
| ArchiveElement (std::shared_ptr< ArchiveElementImpl > impl=std::shared_ptr< ArchiveElementImpl >()) | |
| Constructs a new element with given implementation. More... | |
| Iterator | children () const |
| Returns the child iterator to children of this class. More... | |
| QString | get (const QString &name) const |
| Reads a named attribute. More... | |
| QString | get () const |
| Reads the element contents. More... | |
| bool | isNull () const |
| Is this a NULL element, created by the default constructor. More... | |
| QString | name () const |
| Reads the element name. More... | |
| void | set (const QString &s) |
| Writes the element contents. More... | |
| void | setName (const QString &name) |
| Sets the element name. More... | |
| const DOMElement * | xml () const |
| If the implementation is actually a XMLArchiveElement, return the wrapped DOMElement. More... | |
ArchiveElement defines the serialization API.
The (de)serialize() methods should use this interface to actually read/write data. The actual implementation is provided by instance of ArchiveElementImpl, so this same class can be used and copied freely without caring about underlying serialization format.
For one object, the element can write the object name, it's contents, any number of named attributes (key/value pairs), and any number of child objects. It can respectively read the name, contents, attributes by name, and iterate over all child objects. Every backend should implement this kind of data structure.
There is also special "NULL" or "empty" element, that is usually used in case of errors or similar. It can be created by using the default ArchiveElement constructor.
| Valuable::ArchiveElement::ArchiveElement | ( | std::shared_ptr< ArchiveElementImpl > | impl = std::shared_ptr< ArchiveElementImpl >() | ) |
Constructs a new element with given implementation.
| impl | Serialization implementation to use. If implementation is null, the whole ArchiveElement is "NULL" element. |
| void Valuable::ArchiveElement::add | ( | const ArchiveElement & | element | ) |
Adds a new child element.
| element | New child element |
| void Valuable::ArchiveElement::add | ( | const QString & | name, |
| const QString & | value | ||
| ) |
Writes a new named attribute, name should be unique along this object.
| name | Name of the attribute |
| value | Value of the attribute |
| Iterator Valuable::ArchiveElement::children | ( | ) | const |
Returns the child iterator to children of this class.
| QString Valuable::ArchiveElement::get | ( | const QString & | name | ) | const |
Reads a named attribute.
| name | Name of the attribute to read |
| QString Valuable::ArchiveElement::get | ( | ) | const |
Reads the element contents.
| bool Valuable::ArchiveElement::isNull | ( | ) | const |
Is this a NULL element, created by the default constructor.
| QString Valuable::ArchiveElement::name | ( | ) | const |
Reads the element name.
| void Valuable::ArchiveElement::set | ( | const QString & | s | ) |
Writes the element contents.
| s | New contents of the element |
| void Valuable::ArchiveElement::setName | ( | const QString & | name | ) |
Sets the element name.
| name | The new name of the element |
| const DOMElement* Valuable::ArchiveElement::xml | ( | ) | const |
If the implementation is actually a XMLArchiveElement, return the wrapped DOMElement.
This function is provided only for keeping backwards compatibility.