All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Valuable::XMLArchive Class Reference

Wrapper for DOMDocument that implements the Archive interface. More...

#include <Valuable/XMLArchive.hpp>

Inheritance diagram for Valuable::XMLArchive:
Valuable::Archive Valuable::SerializationOptions

Public Member Functions

virtual ArchiveElement createElement (const QString &name)
 Create a new element with correct implementation. More...
 
bool readFromFile (const QString &filename)
 Read archive contents from a file. More...
 
bool readFromMem (const QByteArray &buffer)
 Read archive contents from a buffer. More...
 
ArchiveElement root () const
 Query the root element. More...
 
void setRoot (const ArchiveElement &element)
 Sets the root element. More...
 
bool writeToFile (const QString &filename) const
 Serialize archive as XML to a file. More...
 
bool writeToMem (QByteArray &buffer) const
 Serialize archive as XML to a buffer. More...
 
DOMDocumentxml ()
 Returns a pointer to wrapped DOMDocument. More...
 
 XMLArchive (unsigned int options=DEFAULTS)
 Creates a new DOMDocument. More...
 
virtual ~XMLArchive ()
 Deletes the DOMDocument.
 
- Public Member Functions inherited from Valuable::Archive
 Archive (unsigned int options=DEFAULTS)
 Creates a new Archive and initializes the SerializationOptions with given options. More...
 
virtual ~Archive ()
 Default destructor does nothing.
 
- Public Member Functions inherited from Valuable::SerializationOptions
bool checkFlags (Options flag)
 Check if given flag is enabled. More...
 
 SerializationOptions (unsigned int options=DEFAULTS)
 Construct an options object with given flags.
 
void setOptions (Options flags)
 Set the options for serialization.
 

Static Public Member Functions

static QString cleanElementName (QString name)
 Clean string so that it is a valid XML element name.
 

Additional Inherited Members

- Public Types inherited from Valuable::SerializationOptions
enum  Options {
  LAYER_DEFAULT = 1 << 0, LAYER_STYLE = 1 << 1, LAYER_USER = 1 << 2, LAYER_STYLE_IMPORTANT = 1 << 3,
  DEFAULTS = LAYER_USER, ONLY_CHANGED = LAYER_STYLE | LAYER_USER | LAYER_STYLE_IMPORTANT, EVERYTHING = LAYER_DEFAULT | LAYER_STYLE | LAYER_USER | LAYER_STYLE_IMPORTANT
}
 Serialization bitflags. More...
 
- Protected Attributes inherited from Valuable::SerializationOptions
unsigned int m_options
 Actual bitmask of flags.
 

Detailed Description

Wrapper for DOMDocument that implements the Archive interface.

All ArchiveElements use XMLArchiveElement implementation and are constructed in createElement.

Constructor & Destructor Documentation

Valuable::XMLArchive::XMLArchive ( unsigned int  options = DEFAULTS)

Creates a new DOMDocument.

Parameters
optionsBitmask of SerializationOptions::Options

Member Function Documentation

virtual ArchiveElement Valuable::XMLArchive::createElement ( const QString &  name)
virtual

Create a new element with correct implementation.

Parameters
nameName of the element.
Returns
The created element

Implements Valuable::Archive.

bool Valuable::XMLArchive::readFromFile ( const QString &  filename)
virtual

Read archive contents from a file.

Parameters
filenamefile to open
Returns
true if reading was successful

Implements Valuable::Archive.

bool Valuable::XMLArchive::readFromMem ( const QByteArray &  buffer)
virtual

Read archive contents from a buffer.

Parameters
bufferdata buffer to read the data from
Returns
true if reading was successful

Implements Valuable::Archive.

ArchiveElement Valuable::XMLArchive::root ( ) const
virtual

Query the root element.

Returns
The root element

Implements Valuable::Archive.

void Valuable::XMLArchive::setRoot ( const ArchiveElement element)
virtual

Sets the root element.

Parameters
elementNew element that should be set as a new root element

Implements Valuable::Archive.

bool Valuable::XMLArchive::writeToFile ( const QString &  filename) const
virtual

Serialize archive as XML to a file.

Parameters
filenamefile to open
Returns
true if writing was successful

Implements Valuable::Archive.

bool Valuable::XMLArchive::writeToMem ( QByteArray &  buffer) const
virtual

Serialize archive as XML to a buffer.

Parameters
bufferthat will be overwritten with the new data
Returns
true if writing was successful

Implements Valuable::Archive.

DOMDocument* Valuable::XMLArchive::xml ( )
virtual

Returns a pointer to wrapped DOMDocument.

Returns
The wrapped DOMDocument

Reimplemented from Valuable::Archive.