The Dirtchamber
A mixed reality testing environment for real-time global illumination algorithms
Public Member Functions | List of all members
dune::serializer Class Reference

Seralizer to read/write Dune objects from/into JSON/XML. More...

#include <serializer.h>

Public Member Functions

void save (const tstring &filename)
 Save the current key-value's into a file specified by filename.
 
void load (const tstring &filename)
 Load key-value pairs from a file specified by filename.
 
template<typename T >
get (const tstring &key) const
 Get a value from a specified key. More...
 
template<typename T >
void put (const tstring &key, const T &value)
 Add a new key-value pair or overwrite an existing key with a new value. More...
 

Detailed Description

Seralizer to read/write Dune objects from/into JSON/XML.

This class manages a map of key-value pairs of tstring objects and can read or write them to XML files. Keys can be structured into subkeys by dividing them with dots. For instace, the hierarchy

foo { bar { baz }, bar1 { baz } }

can be expressed with the following keys

foo.bar.baz

foo.bar1.baz

The serializer is used to save information about Dune objects into files. This enables loading program configurations.

Member Function Documentation

template<typename T >
T dune::serializer::get ( const tstring &  key) const
inline

Get a value from a specified key.

Fetch a value from the storage and return it as type T.

Template Parameters
TThe type of the parameter.
Parameters
keyThe key specifying the value.
Returns
The requested value.
Exceptions
exceptionThe key does not exist.

Referenced by dune::operator>>(), and operator>>().

template<typename T >
void dune::serializer::put ( const tstring &  key,
const T &  value 
)
inline

Add a new key-value pair or overwrite an existing key with a new value.

Add a value of type T to the storage. If the key already exists, the value is simply replaced.

Template Parameters
TThe type of the parameter.
Parameters
keyThe key specifying the value.
valueThe value.

Referenced by dune::operator<<(), and operator<<().


The documentation for this class was generated from the following files: