All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Valuable::Archive Class Referenceabstract

Abstract class that defines an interface that allows working with elements. More...

#include <Valuable/Archive.hpp>

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

Public Member Functions

 Archive (unsigned int options=DEFAULTS)
 Creates a new Archive and initializes the SerializationOptions with given options. More...
 
virtual ArchiveElement createElement (const QString &name)=0
 Create a new element with correct implementation. More...
 
virtual bool readFromFile (const QString &filename)=0
 Reads the archive from a file. More...
 
virtual bool readFromMem (const QByteArray &buffer)=0
 
virtual ArchiveElement root () const =0
 Query the root element. More...
 
virtual void setRoot (const ArchiveElement &element)=0
 Sets the root element. More...
 
virtual bool writeToFile (const QString &filename) const =0
 Writes the archive to file. More...
 
virtual bool writeToMem (QByteArray &buffer) const =0
 Write the archive to memory buffer. More...
 
virtual DOMDocumentxml ()
 If this is actually a XMLArchive, return the wrapped DOMDocument. 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.
 

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

Abstract class that defines an interface that allows working with elements.

Different kinds of backends (XML, binary, etc..) should inherit from this class. There always should be an Archive-implementation and an ArchiveElementImpp-implementation, that are designed to work together.

Every time Serializable objects are being serialized, the recursive serialize() calls will have one Archive object as a parameter. It keeps the serialization state and options with the help of SerializationOptions.

Archive has one "root" ArchiveElement, that may have child elements.

Constructor & Destructor Documentation

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

Creates a new Archive and initializes the SerializationOptions with given options.

Parameters
optionsBitmask of SerializationOptions::Options

Member Function Documentation

virtual ArchiveElement Valuable::Archive::createElement ( const QString &  name)
pure virtual

Create a new element with correct implementation.

Parameters
nameName of the element.
Returns
The created element

Implemented in Valuable::XMLArchive.

virtual bool Valuable::Archive::readFromFile ( const QString &  filename)
pure virtual

Reads the archive from a file.

Parameters
filenameAbsolute or relative filepath
Returns
True on success

Implemented in Valuable::XMLArchive.

virtual ArchiveElement Valuable::Archive::root ( ) const
pure virtual

Query the root element.

Returns
The root element

Implemented in Valuable::XMLArchive.

virtual void Valuable::Archive::setRoot ( const ArchiveElement element)
pure virtual

Sets the root element.

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

Implemented in Valuable::XMLArchive.

virtual bool Valuable::Archive::writeToFile ( const QString &  filename) const
pure virtual

Writes the archive to file.

Parameters
filenameAbsolute or relative filepath
Returns
True on success

Implemented in Valuable::XMLArchive.

virtual bool Valuable::Archive::writeToMem ( QByteArray &  buffer) const
pure virtual

Write the archive to memory buffer.

Parameters
bufferThe output buffer where the archive is written
Returns
True if writing succeeds

Implemented in Valuable::XMLArchive.

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

If this is actually a XMLArchive, return the wrapped DOMDocument.

Returns
Default implementation returns NULL.

Reimplemented in Valuable::XMLArchive.