MeVisLab Toolbox Reference
|
Class for writing object data to a stream. More...
#include <mlAbstractPersistenceStream.h>
Public Member Functions | |
~AbstractPersistenceOutputStream () override=default | |
void | startStructWithVersion (int version, const char *name=nullptr) |
start a versioned struct | |
template<typename T > | |
void | write (const std::vector< T > &values, const char *name=nullptr) |
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=nullptr) |
Write float vectors like vec3f to the stream. | |
template<typename T , size_t n> | |
void | write (const TVectorNDBase< T, n > &value, const char *name=nullptr) |
Write integer vectors like ImageVector to the stream. | |
template<typename T , size_t n> | |
void | write (const FloatingPointMatrix< T, n > &value, const char *name=nullptr) |
Write float matrices like mat4 to the stream. | |
virtual void | writeObject (const Base *const obj, const char *name=nullptr) |
Write a Base object to the stream. | |
virtual void | writeData (const void *data, size_t len, const char *name=nullptr)=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=nullptr) |
Write primitive values to the stream. | |
void | write (MLint32 value, const char *name=nullptr) |
void | write (MLuint32 value, const char *name=nullptr) |
void | write (MLint64 value, const char *name=nullptr) |
void | write (MLuint64 value, const char *name=nullptr) |
void | write (MLfloat value, const char *name=nullptr) |
void | write (MLdouble value, const char *name=nullptr) |
void | write (const std::string &value, const char *name=nullptr) |
void | write (const char *value, const char *name=nullptr) |
Public Member Functions inherited from ml::AbstractPersistenceStream | |
void | startList (const char *name=nullptr, const char *xmlItemName="Item", bool xmlSuppressScope=false) |
Start a new list of values in the data stream, must be ended with endList(). | |
void | endList () |
End reading/writing of the list. | |
void | startStruct (const char *name=nullptr) |
Start a new struct of values in the data stream, must be ended with endStruct(). | |
void | endStruct () |
End reading/writing of struct values. | |
virtual bool | isBinary () const =0 |
Is the stream in a binary format? (otherwise in a readable text format) | |
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. | |
void | nameCheck (const char *name) override |
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)unique id for each pointer value - currently unused. | |
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 |
Protected Member Functions inherited from ml::AbstractPersistenceStream | |
AbstractPersistenceStream () | |
virtual | ~AbstractPersistenceStream () |
bool | isInList () const |
Check if the stream is currently in "list" mode. Otherwise it is in "struct" mode. | |
size_t | nestingDepth () const |
return depth of nesting stack (created by startList/startStruct), used to check nesting rules | |
virtual void | internalError (const char *msg, const char *arg=nullptr) |
Log an internal error. Usually called to indicate wrong usage of interface. | |
virtual void | startListImpl (const char *name, const char *xmlItemName, bool xmlSuppressScope)=0 |
Abstract methods called by above methods, need to be implemented in derived classes. | |
virtual void | endListImpl ()=0 |
virtual void | startStructImpl (const char *name)=0 |
virtual void | endStructImpl ()=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 120 of file mlAbstractPersistenceStream.h.
|
overridedefault |
|
inlineprotected |
Definition at line 192 of file mlAbstractPersistenceStream.h.
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)
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.
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.
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure virtual |
base type name
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure virtual |
persistence version
Implemented in ml::XMLPersistenceOutputStream.
void ml::AbstractPersistenceOutputStream::startStructWithVersion | ( | int | version, |
const char * | name = nullptr ) |
start a versioned struct
|
virtual |
Write primitive values to the stream.
Note: the default implementation writes bools as MLint32 - binary formats might want to be more efficient
|
inline |
Definition at line 141 of file mlAbstractPersistenceStream.h.
References write().
Referenced by write().
|
inline |
Write float matrices like mat4 to the stream.
Definition at line 171 of file mlAbstractPersistenceStream.h.
References ml::FloatingPointMatrix< VectorT, size >::getValuesToPtr(), and mlrange_cast().
|
inline |
Write float vectors like vec3f to the stream.
Definition at line 155 of file mlAbstractPersistenceStream.h.
References mlrange_cast().
void ml::AbstractPersistenceOutputStream::write | ( | const std::string & | value, |
const char * | name = nullptr ) |
|
inline |
Write vectors of primitive values to the stream.
Currently supported are MLint32, MLuint32, MLint64, MLuint64, MLfloat and MLdouble
Definition at line 147 of file mlAbstractPersistenceStream.h.
|
inline |
Write integer vectors like ImageVector to the stream.
Definition at line 163 of file mlAbstractPersistenceStream.h.
References ml::TVectorNDBase< CompIntType, NumDim >::array, and mlrange_cast().
|
pure virtual |
Write binary data to stream.
Implemented in ml::XMLPersistenceOutputStream.
|
virtual |
Write a Base object to the stream.
This uses the Base::writeTo() method of the object and the methods setObjectType() and setObjectVersion().
|
protectedpure virtual |
Abstract writing method that needs to be implemented by derived classes.
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure virtual |
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure virtual |
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure 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.
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure virtual |
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure virtual |
Implemented in ml::XMLPersistenceOutputStream.
|
protectedpure virtual |
Implemented in ml::XMLPersistenceOutputStream.