ML Reference
|
Class for writing object data to a stream. More...
#include <mlAbstractPersistenceStream.h>
Public Member Functions | |
~AbstractPersistenceOutputStream () | |
void | startStructWithVersion (int version, const char *name=NULL) |
start a versioned struct | |
template<typename T > | |
void | write (const std::vector< T > &values, const char *name=NULL) |
Write vectors of primitive values to the stream. | |
template<typename T , size_t n, class DataContainer > | |
void | write (const FloatingPointVector< T, n, DataContainer > &value, const char *name=NULL) |
Write float vectors like vec3f to the stream. | |
template<typename T , size_t n> | |
void | write (const TVectorNDBase< T, n > &value, const char *name=NULL) |
Write integer vectors like ImageVector to the stream. | |
template<typename T , size_t n> | |
void | write (const FloatingPointMatrix< T, n > &value, const char *name=NULL) |
Write float matrices like mat4 to the stream. | |
virtual void | writeObject (const Base *const obj, const char *name=NULL) |
Write a Base object to the stream. | |
virtual void | writeData (const void *data, size_t len, const char *name=NULL)=0 |
Write binary data to stream. | |
virtual bool | isValidElementName (const char *name) |
check if name is valid for use with persistence entries (by default this checks if the name is valid for use as a XML tag, but implementations may relax - or tighten - this check) | |
virtual void | write (bool value, const char *name=NULL) |
Write primitive values to the stream. | |
void | write (MLint32 value, const char *name=NULL) |
void | write (MLuint32 value, const char *name=NULL) |
void | write (MLint64 value, const char *name=NULL) |
void | write (MLuint64 value, const char *name=NULL) |
void | write (MLfloat value, const char *name=NULL) |
void | write (MLdouble value, const char *name=NULL) |
void | write (const std::string &value, const char *name=NULL) |
void | write (const char *value, const char *name=NULL) |
Protected Member Functions | |
AbstractPersistenceOutputStream () | |
virtual void | writeString (const char *name, const std::string &value)=0 |
Abstract writing method that needs to be implemented by derived classes. | |
virtual void | nameCheck (const char *name) |
overriden to perform additional check in Debug mode if name is suitable for the persistence format (uses isValidElementName), prints an error if not | |
virtual void | setObjectID (int id)=0 |
Implementation of Base object persistence, set attribute on currently open struct (implementation hint: these can be stored unnamed, if they are read or not is always deduced from the current state of the persistence stream) | |
virtual void | setObjectType (const char *type)=0 |
base type name | |
virtual void | setObjectVersion (int version)=0 |
persistence version | |
virtual void | writeValues (const char *name, const MLint32 *values, size_t n, bool fixedList)=0 |
Abstract writing methods that need to be implemented by derived classes. | |
virtual void | writeValues (const char *name, const MLuint32 *values, size_t n, bool fixedList)=0 |
virtual void | writeValues (const char *name, const MLint64 *values, size_t n, bool fixedList)=0 |
virtual void | writeValues (const char *name, const MLuint64 *values, size_t n, bool fixedList)=0 |
virtual void | writeValues (const char *name, const MLfloat *values, size_t n, bool fixedList)=0 |
virtual void | writeValues (const char *name, const MLdouble *values, size_t n, bool fixedList)=0 |
Class for writing object data to a stream.
This class has write methods for the types bool, MLint32, MLuint32, MLint64, MLuint64, float, double, std::string and all vector and matrix types from MLLinearAlgebra. You can also write binary data (with writeData()) and Base objects (with writeObject()) to the stream.
Data can be organized in sub-structures or in lists. Data items usually have to be given a name, unless they are list items, in which case it is forbidden to give a name. Have a look at the startStruct()/endStruct() startList()/endList() methods of AbstractPersistenceStream on how to start/end new scopes.
Definition at line 114 of file mlAbstractPersistenceStream.h.
ml::AbstractPersistenceOutputStream::~AbstractPersistenceOutputStream | ( | ) | [inline] |
Definition at line 117 of file mlAbstractPersistenceStream.h.
ml::AbstractPersistenceOutputStream::AbstractPersistenceOutputStream | ( | ) | [inline, protected] |
Definition at line 186 of file mlAbstractPersistenceStream.h.
virtual bool ml::AbstractPersistenceOutputStream::isValidElementName | ( | const char * | name | ) | [virtual] |
check if name is valid for use with persistence entries (by default this checks if the name is valid for use as a XML tag, but implementations may relax - or tighten - this check)
virtual void ml::AbstractPersistenceOutputStream::nameCheck | ( | const char * | name | ) | [protected, virtual] |
overriden to perform additional check in Debug mode if name is suitable for the persistence format (uses isValidElementName), prints an error if not
Reimplemented from ml::AbstractPersistenceStream.
virtual void ml::AbstractPersistenceOutputStream::setObjectID | ( | int | id | ) | [protected, pure virtual] |
Implementation of Base object persistence, set attribute on currently open struct (implementation hint: these can be stored unnamed, if they are read or not is always deduced from the current state of the persistence stream)
unique id for each pointer value - currently unused
virtual void ml::AbstractPersistenceOutputStream::setObjectType | ( | const char * | type | ) | [protected, pure virtual] |
base type name
virtual void ml::AbstractPersistenceOutputStream::setObjectVersion | ( | int | version | ) | [protected, pure virtual] |
persistence version
void ml::AbstractPersistenceOutputStream::startStructWithVersion | ( | int | version, |
const char * | name = NULL |
||
) |
start a versioned struct
void ml::AbstractPersistenceOutputStream::write | ( | MLuint32 | value, |
const char * | name = NULL |
||
) |
void ml::AbstractPersistenceOutputStream::write | ( | MLdouble | value, |
const char * | name = NULL |
||
) |
void ml::AbstractPersistenceOutputStream::write | ( | const std::string & | value, |
const char * | name = NULL |
||
) |
virtual void ml::AbstractPersistenceOutputStream::write | ( | bool | value, |
const char * | name = NULL |
||
) | [virtual] |
Write primitive values to the stream.
Note: the default implementation writes bools as MLint32 - binary formats might want to be more efficient
void ml::AbstractPersistenceOutputStream::write | ( | MLint64 | value, |
const char * | name = NULL |
||
) |
void ml::AbstractPersistenceOutputStream::write | ( | const char * | value, |
const char * | name = NULL |
||
) | [inline] |
Definition at line 135 of file mlAbstractPersistenceStream.h.
References write().
Referenced by write().
void ml::AbstractPersistenceOutputStream::write | ( | const std::vector< T > & | values, |
const char * | name = NULL |
||
) | [inline] |
Write vectors of primitive values to the stream.
Currently supported are MLint32, MLuint32, MLint64, MLuint64, MLfloat and MLdouble
Definition at line 141 of file mlAbstractPersistenceStream.h.
References ml::AbstractPersistenceStream::nameCheck().
void ml::AbstractPersistenceOutputStream::write | ( | const FloatingPointMatrix< T, n > & | value, |
const char * | name = NULL |
||
) | [inline] |
Write float matrices like mat4 to the stream.
Definition at line 165 of file mlAbstractPersistenceStream.h.
References ml::FloatingPointMatrix< VectorT, size >::getValuesToPtr(), and ml::AbstractPersistenceStream::nameCheck().
void ml::AbstractPersistenceOutputStream::write | ( | MLuint64 | value, |
const char * | name = NULL |
||
) |
void ml::AbstractPersistenceOutputStream::write | ( | MLfloat | value, |
const char * | name = NULL |
||
) |
void ml::AbstractPersistenceOutputStream::write | ( | const FloatingPointVector< T, n, DataContainer > & | value, |
const char * | name = NULL |
||
) | [inline] |
Write float vectors like vec3f to the stream.
Definition at line 149 of file mlAbstractPersistenceStream.h.
References ml::AbstractPersistenceStream::nameCheck().
void ml::AbstractPersistenceOutputStream::write | ( | const TVectorNDBase< T, n > & | value, |
const char * | name = NULL |
||
) | [inline] |
Write integer vectors like ImageVector to the stream.
Definition at line 157 of file mlAbstractPersistenceStream.h.
References ml::TVectorNDBase< CompIntType, NumDim >::array, and ml::AbstractPersistenceStream::nameCheck().
void ml::AbstractPersistenceOutputStream::write | ( | MLint32 | value, |
const char * | name = NULL |
||
) |
virtual void ml::AbstractPersistenceOutputStream::writeData | ( | const void * | data, |
size_t | len, | ||
const char * | name = NULL |
||
) | [pure virtual] |
Write binary data to stream.
virtual void ml::AbstractPersistenceOutputStream::writeObject | ( | const Base *const | obj, |
const char * | name = NULL |
||
) | [virtual] |
Write a Base object to the stream.
This uses the Base::writeTo() method of the object and the methods setObjectType() and setObjectVersion().
virtual void ml::AbstractPersistenceOutputStream::writeString | ( | const char * | name, |
const std::string & | value | ||
) | [protected, pure virtual] |
Abstract writing method that needs to be implemented by derived classes.
virtual void ml::AbstractPersistenceOutputStream::writeValues | ( | const char * | name, |
const MLuint64 * | values, | ||
size_t | n, | ||
bool | fixedList | ||
) | [protected, pure virtual] |
virtual void ml::AbstractPersistenceOutputStream::writeValues | ( | const char * | name, |
const MLint64 * | values, | ||
size_t | n, | ||
bool | fixedList | ||
) | [protected, pure virtual] |
virtual void ml::AbstractPersistenceOutputStream::writeValues | ( | const char * | name, |
const MLuint32 * | values, | ||
size_t | n, | ||
bool | fixedList | ||
) | [protected, pure virtual] |
virtual void ml::AbstractPersistenceOutputStream::writeValues | ( | const char * | name, |
const MLdouble * | values, | ||
size_t | n, | ||
bool | fixedList | ||
) | [protected, pure virtual] |
virtual void ml::AbstractPersistenceOutputStream::writeValues | ( | const char * | name, |
const MLfloat * | values, | ||
size_t | n, | ||
bool | fixedList | ||
) | [protected, pure virtual] |
virtual void ml::AbstractPersistenceOutputStream::writeValues | ( | const char * | name, |
const MLint32 * | values, | ||
size_t | n, | ||
bool | fixedList | ||
) | [protected, pure virtual] |
Abstract writing methods that need to be implemented by derived classes.
fixedList tells the stream if the number of elements to write is fixed (and known when reading) or if it needs to be stored in the stream.