ML Reference
ml::AbstractPersistenceInputStream Class Reference

Class for reading object data from a stream. More...

#include <mlAbstractPersistenceStream.h>

Inheritance diagram for ml::AbstractPersistenceInputStream:
ml::AbstractPersistenceStream

List of all members.

Public Member Functions

 ~AbstractPersistenceInputStream ()
int startStructWithVersion (const char *name=NULL)
 start a struct, returns version of struct (0 if not given)
template<typename T >
void read (std::vector< T > &values, const char *name=NULL)
 Read vectors of primitive values from the stream.
template<typename T , size_t n, class DataContainer >
void read (FloatingPointVector< T, n, DataContainer > &value, const char *name=NULL)
 Read float vectors like vec3f from the stream.
template<typename T , size_t n>
void read (TVectorNDBase< T, n > &value, const char *name=NULL)
 Read integer vectors like ImageVector from the stream.
template<typename T , size_t n>
void read (FloatingPointMatrix< T, n > &value, const char *name=NULL)
 Read float matrices like mat4 from the stream.
template<typename T >
void readOptional (T &value, const T &defaultValue, const char *name=NULL)
 Perform optional reading for all above methods.
virtual BasereadObject (const char *name=NULL)
 Read Base object from stream.
virtual void readData (std::string &value, const char *name=NULL)=0
 Same as above for binary data (std::string misused as binary data container)
bool hasNextInStruct (std::string &name)
 Returns true if there is another element in the current struct scope, and if so then sets name to its name.
bool isNextInStruct (const char *name)
 Check if an item with the given name comes next in the stream.
bool hasNextListItem ()
 Check if there is another item in the current list.
void versionCheck (const char *className, int objectVersion, int storedVersion)
 print a warning if the storedVersion is greater than the objectVersion
virtual void read (bool &value, const char *name=NULL)
 Read primitive values from the stream.
void read (MLint32 &value, const char *name=NULL)
void read (MLuint32 &value, const char *name=NULL)
void read (MLint64 &value, const char *name=NULL)
void read (MLuint64 &value, const char *name=NULL)
void read (MLfloat &value, const char *name=NULL)
void read (MLdouble &value, const char *name=NULL)
void read (std::string &value, const char *name=NULL)

Protected Member Functions

 AbstractPersistenceInputStream ()
virtual bool hasNextInStructImpl (std::string &name)=0
 Check if an item with the given name comes next in the stream.
virtual bool hasNextListItemImpl ()=0
 Check if there is another item in the current list.
virtual void readString (const char *name, std::string &value)=0
 Abstract reading method that needs to be implemented by derived classes.
virtual void formatError (const std::string &msg)
 indicate format error, by default throw exception
virtual bool getObjectID (int &id)=0
 Implementation of Base object persistence, get attribute of currently open struct.
virtual bool getObjectType (std::string &type)=0
 base type name
virtual bool getObjectVersion (int &version)=0
 persistence version
virtual void readValues (const char *name, size_t expected, std::vector< MLint32 > &values)=0
 Abstract reading methods that need to be implemented by derived classes.
virtual void readValues (const char *name, size_t expected, std::vector< MLuint32 > &values)=0
virtual void readValues (const char *name, size_t expected, std::vector< MLint64 > &values)=0
virtual void readValues (const char *name, size_t expected, std::vector< MLuint64 > &values)=0
virtual void readValues (const char *name, size_t expected, std::vector< MLfloat > &values)=0
virtual void readValues (const char *name, size_t expected, std::vector< MLdouble > &values)=0

Detailed Description

Class for reading object data from a stream.

This class has read methods for the types bool, MLint32, MLuint32, MLint64, MLuint64, float, double, std::string and all vector and matrix types from MLLinearAlgebra. You can also read binary data (with readData()) and Base objects (with readObject()) from the stream.

You can use the readOptional() methods if an data item need not exist on the stream, but this is for convenience, you can always check with isNextInStruct() (for structure scopes) or hasNextListItem() (for list scopes) if the next item in the stream is like you expect. There is also the hasNextInStruct() method for getting the next item's name in a structure scope.

Definition at line 232 of file mlAbstractPersistenceStream.h.


Constructor & Destructor Documentation

ml::AbstractPersistenceInputStream::~AbstractPersistenceInputStream ( ) [inline]

Definition at line 235 of file mlAbstractPersistenceStream.h.

ml::AbstractPersistenceInputStream::AbstractPersistenceInputStream ( ) [inline, protected]

Definition at line 332 of file mlAbstractPersistenceStream.h.


Member Function Documentation

virtual void ml::AbstractPersistenceInputStream::formatError ( const std::string &  msg) [protected, virtual]

indicate format error, by default throw exception

virtual bool ml::AbstractPersistenceInputStream::getObjectID ( int &  id) [protected, pure virtual]

Implementation of Base object persistence, get attribute of currently open struct.

get unique id of object - currently unused

virtual bool ml::AbstractPersistenceInputStream::getObjectType ( std::string &  type) [protected, pure virtual]

base type name

virtual bool ml::AbstractPersistenceInputStream::getObjectVersion ( int &  version) [protected, pure virtual]

persistence version

bool ml::AbstractPersistenceInputStream::hasNextInStruct ( std::string &  name)

Returns true if there is another element in the current struct scope, and if so then sets name to its name.

virtual bool ml::AbstractPersistenceInputStream::hasNextInStructImpl ( std::string &  name) [protected, pure virtual]

Check if an item with the given name comes next in the stream.

The stream is guaranteed to be in a "struct" scope.

bool ml::AbstractPersistenceInputStream::hasNextListItem ( )

Check if there is another item in the current list.

The stream must be in a "list" scope.

virtual bool ml::AbstractPersistenceInputStream::hasNextListItemImpl ( ) [protected, pure virtual]

Check if there is another item in the current list.

The stream is guaranteed to be in a "list" scope.

bool ml::AbstractPersistenceInputStream::isNextInStruct ( const char *  name)

Check if an item with the given name comes next in the stream.

The stream must be in a "struct" scope.

void ml::AbstractPersistenceInputStream::read ( MLdouble value,
const char *  name = NULL 
)
virtual void ml::AbstractPersistenceInputStream::read ( bool &  value,
const char *  name = NULL 
) [virtual]

Read primitive values from the stream.

Note: the default implementation reads bools as MLint32 - binary formats might want to be more efficient

void ml::AbstractPersistenceInputStream::read ( std::string &  value,
const char *  name = NULL 
)
void ml::AbstractPersistenceInputStream::read ( MLuint32 value,
const char *  name = NULL 
)
void ml::AbstractPersistenceInputStream::read ( MLint64 value,
const char *  name = NULL 
)
template<typename T >
void ml::AbstractPersistenceInputStream::read ( std::vector< T > &  values,
const char *  name = NULL 
) [inline]

Read vectors of primitive values from the stream.

Currently supported are MLint32, MLuint32, MLint64, MLuint64, MLfloat and MLdouble

Definition at line 257 of file mlAbstractPersistenceStream.h.

References ml::AbstractPersistenceStream::nameCheck().

template<typename T , size_t n, class DataContainer >
void ml::AbstractPersistenceInputStream::read ( FloatingPointVector< T, n, DataContainer > &  value,
const char *  name = NULL 
) [inline]

Read float vectors like vec3f from the stream.

Definition at line 265 of file mlAbstractPersistenceStream.h.

References ml::AbstractPersistenceStream::nameCheck().

void ml::AbstractPersistenceInputStream::read ( MLint32 value,
const char *  name = NULL 
)
template<typename T , size_t n>
void ml::AbstractPersistenceInputStream::read ( TVectorNDBase< T, n > &  value,
const char *  name = NULL 
) [inline]

Read integer vectors like ImageVector from the stream.

Definition at line 277 of file mlAbstractPersistenceStream.h.

References ml::AbstractPersistenceStream::nameCheck().

void ml::AbstractPersistenceInputStream::read ( MLuint64 value,
const char *  name = NULL 
)
template<typename T , size_t n>
void ml::AbstractPersistenceInputStream::read ( FloatingPointMatrix< T, n > &  value,
const char *  name = NULL 
) [inline]

Read float matrices like mat4 from the stream.

Definition at line 289 of file mlAbstractPersistenceStream.h.

References ml::AbstractPersistenceStream::nameCheck(), and ml::FloatingPointMatrix< VectorT, size >::setValuesFromPtr().

void ml::AbstractPersistenceInputStream::read ( MLfloat value,
const char *  name = NULL 
)
virtual void ml::AbstractPersistenceInputStream::readData ( std::string &  value,
const char *  name = NULL 
) [pure virtual]

Same as above for binary data (std::string misused as binary data container)

virtual Base* ml::AbstractPersistenceInputStream::readObject ( const char *  name = NULL) [virtual]

Read Base object from stream.

This uses the Base::readFrom() method of the object. Returns NULL if no object is given under name.

template<typename T >
void ml::AbstractPersistenceInputStream::readOptional ( T &  value,
const T &  defaultValue,
const char *  name = NULL 
) [inline]

Perform optional reading for all above methods.

If the item is not contained in the stream, the given default value is assigned.

Definition at line 300 of file mlAbstractPersistenceStream.h.

virtual void ml::AbstractPersistenceInputStream::readString ( const char *  name,
std::string &  value 
) [protected, pure virtual]

Abstract reading method that needs to be implemented by derived classes.

virtual void ml::AbstractPersistenceInputStream::readValues ( const char *  name,
size_t  expected,
std::vector< MLint32 > &  values 
) [protected, pure virtual]

Abstract reading methods that need to be implemented by derived classes.

If expected size is 0, the returned list may have any size, otherwise exactly that number of elements are returned (or an exception is thrown).

virtual void ml::AbstractPersistenceInputStream::readValues ( const char *  name,
size_t  expected,
std::vector< MLuint32 > &  values 
) [protected, pure virtual]
virtual void ml::AbstractPersistenceInputStream::readValues ( const char *  name,
size_t  expected,
std::vector< MLdouble > &  values 
) [protected, pure virtual]
virtual void ml::AbstractPersistenceInputStream::readValues ( const char *  name,
size_t  expected,
std::vector< MLfloat > &  values 
) [protected, pure virtual]
virtual void ml::AbstractPersistenceInputStream::readValues ( const char *  name,
size_t  expected,
std::vector< MLuint64 > &  values 
) [protected, pure virtual]
virtual void ml::AbstractPersistenceInputStream::readValues ( const char *  name,
size_t  expected,
std::vector< MLint64 > &  values 
) [protected, pure virtual]
int ml::AbstractPersistenceInputStream::startStructWithVersion ( const char *  name = NULL)

start a struct, returns version of struct (0 if not given)

void ml::AbstractPersistenceInputStream::versionCheck ( const char *  className,
int  objectVersion,
int  storedVersion 
)

print a warning if the storedVersion is greater than the objectVersion


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