CVR-Lib last update 20 Sep 2009

cvr::ioHandler Class Reference
[Storable Interface]

Input/output handlers. More...

#include <cvrIoHandler.h>

Inheritance diagram for cvr::ioHandler:

Inheritance graph
[legend]
Collaboration diagram for cvr::ioHandler:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ioHandler ()
 ioHandler (const ioHandler &other)
virtual ~ioHandler ()
ioHandlercopy (const ioHandler &other)
virtual const std::string & name () const =0
virtual ioHandlerclone () const =0
virtual ioHandlernewInstance () const =0
virtual void use (std::ostream &aStream)=0
virtual void use (std::istream &aStream)=0
virtual bool writeBegin ()
virtual bool writeEnd ()
virtual bool readBegin ()
virtual bool readEnd ()
virtual bool writeSymbol (const std::string &data)=0
virtual bool writeComment (const std::string &data)=0
virtual bool writeComment (const char *data)=0
virtual bool readSymbol (std::string &data)=0
virtual bool trySymbol (const std::string &data)=0
virtual bool tryBegin ()=0
virtual bool tryEnd ()=0
virtual bool writeSpaces (const int s=1)=0
virtual bool writeEOL ()=0
virtual bool writeKeyValueSeparator ()=0
virtual bool writeDataSeparator ()=0
virtual bool readKeyValueSeparator ()=0
virtual bool readDataSeparator ()=0
virtual const int & getLevel () const
virtual bool restoreLevel ()=0
virtual void resetLevel (const int theLevel=0)
virtual void appendContextStatus () const
Write methods for standard types
virtual bool write (const std::string &data)=0
virtual bool write (const char *data)=0
virtual bool write (const double &data)=0
virtual bool write (const float &data)=0
virtual bool write (const int data)=0
virtual bool write (const unsigned int &data)=0
virtual bool write (const char &data)=0
virtual bool write (const byte &data)=0
virtual bool write (const ubyte &data)=0
virtual bool write (const bool data)=0
virtual bool write (const long &data)=0
virtual bool write (const unsigned long &data)=0
virtual bool write (const short &data)=0
virtual bool write (const unsigned short &data)=0
Write methods for symbol-data pairs
virtual bool write (const std::string &name, const std::string &data)
virtual bool write (const std::string &name, const char *data)
virtual bool write (const std::string &name, const double &data)
virtual bool write (const std::string &name, const float &data)
virtual bool write (const std::string &name, const int data)
virtual bool write (const std::string &name, const unsigned int &data)
virtual bool write (const std::string &name, const char &data)
virtual bool write (const std::string &name, const byte &data)
virtual bool write (const std::string &name, const ubyte &data)
virtual bool write (const std::string &name, const bool data)
virtual bool write (const std::string &name, const long &data)
virtual bool write (const std::string &name, const unsigned long &data)
virtual bool write (const std::string &name, const short &data)
virtual bool write (const std::string &name, const unsigned short &data)
Read methods for standard types
virtual bool read (std::string &data)=0
virtual bool read (double &data)=0
virtual bool read (float &data)=0
virtual bool read (int &data)=0
virtual bool read (unsigned int &data)=0
virtual bool read (char &data)=0
virtual bool read (byte &data)=0
virtual bool read (ubyte &data)=0
virtual bool read (bool &data)=0
virtual bool read (long &data)=0
virtual bool read (unsigned long &data)=0
virtual bool read (short &data)=0
virtual bool read (unsigned short &data)=0
Read methods for symbol-data pairs
virtual bool read (const std::string &name, std::string &data)
virtual bool read (const std::string &name, double &data)
virtual bool read (const std::string &name, float &data)
virtual bool read (const std::string &name, int &data)
virtual bool read (const std::string &name, unsigned int &data)
virtual bool read (const std::string &name, char &data)
virtual bool read (const std::string &name, byte &data)
virtual bool read (const std::string &name, ubyte &data)
virtual bool read (const std::string &name, bool &data)
virtual bool read (const std::string &name, long &data)
virtual bool read (const std::string &name, unsigned long &data)
virtual bool read (const std::string &name, short &data)
virtual bool read (const std::string &name, unsigned short &data)

Protected Attributes

int level_


Detailed Description

Input/output handlers.

The ioHandler classes offer an abstract interface for the functor parameters and other cvr::ioObject classes to read() and write() them in different formats.

The CVR-Libstandard ioHandler is the cvr::lispStreamHandler, which uses a LISP-similar syntax to write and read data from streams. To save space and time while serializing objects, you can use the cvr::binaryStreamHandler.

All ioHandlers are used as wrappers for std::istreams or std::ostreams objects. Therefore, the abstract interface provides the virtual methods use() to indicate which stream has to be used.


Constructor & Destructor Documentation

cvr::ioHandler::ioHandler (  ) 

Default constructor.

cvr::ioHandler::ioHandler ( const ioHandler other  ) 

Copy constructor.

virtual cvr::ioHandler::~ioHandler (  )  [virtual]

Destructor.


Member Function Documentation

virtual void cvr::ioHandler::appendContextStatus (  )  const [virtual]

Append contextual information.

This function should help the users to find errors in their files. It just inserts some contextual information into the status string to help localizing wrong data.

It is useful for streams that can be edited by hand, because the users will make errors!

The default behaviour does nothing.

Reimplemented in cvr::lispStreamHandler.

virtual ioHandler* cvr::ioHandler::clone (  )  const [pure virtual]

Returns a pointer to a clone of this functor.

Implements cvr::object.

Implemented in cvr::lispStreamHandler.

ioHandler& cvr::ioHandler::copy ( const ioHandler other  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

virtual const int& cvr::ioHandler::getLevel (  )  const [virtual]

Return the actual nesting level for begins and ends.

Example

 ioHandler_childClass h; // h is an ioHandler of a childClass
                         // this could be for example a lispStreamHandler
 int i;
 i = h.getLevel(); // returns 0;
 h.writeBegin();
 i = h.getLevel(); // returns 1;
 h.writeBegin();
 i = h.getLevel(); // returns 2;
 h.writeEnd();
 i = h.getLevel(); // returns 1;
 h.writeEnd();
 i = h.getLevel(); // returns 0;

virtual const std::string& cvr::ioHandler::name (  )  const [pure virtual]

Returns the name of this class.

Implements cvr::object.

Implemented in cvr::lispStreamHandler.

virtual ioHandler* cvr::ioHandler::newInstance (  )  const [pure virtual]

Returns a pointer to a new instance of the dynamic class type.

Implements cvr::object.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( const std::string &  name,
unsigned short &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
short &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
unsigned long &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
long &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
bool &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
ubyte data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
byte data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
char &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
unsigned int &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
int &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
float &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
double &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( const std::string &  name,
std::string &  data 
) [virtual]

Read symbol-data pair.

virtual bool cvr::ioHandler::read ( unsigned short &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( short &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( unsigned long &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( long &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( bool &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( ubyte data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( byte data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( char &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( unsigned int &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( int &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( float &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( double &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::read ( std::string &  data  )  [pure virtual]

Read standard type.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::readBegin (  )  [virtual]

Read the begin token or tokens.

Reimplemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::readDataSeparator (  )  [pure virtual]

Read inter-data separator token.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::readEnd (  )  [virtual]

Read the end token or tokens.

Reimplemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::readKeyValueSeparator (  )  [pure virtual]

Read key/value separator token.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::readSymbol ( std::string &  data  )  [pure virtual]

Read a std::string as a symbol token.

A symbol must not contain special characters or spaces. Only letters and numbers are allowed, and the first character must be a letter.

Parameters:
data the symbol readed will be left here

Implemented in cvr::lispStreamHandler.

virtual void cvr::ioHandler::resetLevel ( const int  theLevel = 0  )  [virtual]

Usually this member is needed by reinitialization routines to set the begin/end nesting level to zero.

virtual bool cvr::ioHandler::restoreLevel (  )  [pure virtual]

Restore all the information in the handler taken in the actual level.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::tryBegin (  )  [pure virtual]

Try to read the begin token from the handler.

If present, returns true and the token is removed from the handler, if not present returns false and leaves the handle as it was before calling this member...

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::tryEnd (  )  [pure virtual]

Try to read the end token from the handler.

If present, returns true and the token is removed from the handler, if not present returns false and leaves the handle as it was before calling this member...

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::trySymbol ( const std::string &  data  )  [pure virtual]

Try to read the given symbol from the handler.

If present, returns true and the token is removed from the handler, if not present returns false and leaves the handle as it was before calling this member...

A symbol must not contain special characters or spaces. Only letters and numbers are allowed, and the first character must be a letter.

Parameters:
data the symbol to be readed

Implemented in cvr::lispStreamHandler.

virtual void cvr::ioHandler::use ( std::istream &  aStream  )  [pure virtual]

Indicate the input stream to be used.

Calling this method you will reinitialize the state of the parser (see also clear()).

Implemented in cvr::lispStreamHandler.

virtual void cvr::ioHandler::use ( std::ostream &  aStream  )  [pure virtual]

Indicate the output stream to be used.

Calling this method you will reinitialize the state of the parser (see also clear()).

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const unsigned short &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const short &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const unsigned long &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const long &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const bool  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const ubyte data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const byte data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const char &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const unsigned int &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const int  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const float &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const double &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const char *  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const std::string &  name,
const std::string &  data 
) [virtual]

Write symbol-data pair.

virtual bool cvr::ioHandler::write ( const unsigned short &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const short &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const unsigned long &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const long &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const bool  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const ubyte data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const byte data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const char &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const unsigned int &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const int  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const float &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const double &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const char *  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::write ( const std::string &  data  )  [pure virtual]

Write standard types.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeBegin (  )  [virtual]

Write the begin token or tokens.

Reimplemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeComment ( const char *  data  )  [pure virtual]

Write comment writes the input data without any preprocessing, just ensuring that the comment format is given.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeComment ( const std::string &  data  )  [pure virtual]

Write comment writes the input data without any preprocessing, just ensuring that the comment format is given.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeDataSeparator (  )  [pure virtual]

Write inter-data separator.

The data-separator token separates data elements in a data list or array

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeEnd (  )  [virtual]

Write the end token or tokens.

Reimplemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeEOL (  )  [pure virtual]

Write end-of-line token The EOL are tokes that will be ignored by reading.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeKeyValueSeparator (  )  [pure virtual]

Write key/value separator.

The key/value separator is the token which will separate a symbol from its value in a symbol-data-pair.

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeSpaces ( const int  s = 1  )  [pure virtual]

Write spaces (default value 1) The spaces are tokes that will be ignored by reading.

Parameters:
s the number of space-tokens to be written

Implemented in cvr::lispStreamHandler.

virtual bool cvr::ioHandler::writeSymbol ( const std::string &  data  )  [pure virtual]

Write a std::string as a symbol token.

A symbol must not contain special characters or spaces. Only letters and numbers are allowed, and the first character must be a letter.

Parameters:
data The symbol to be written

Implemented in cvr::lispStreamHandler.


Member Data Documentation

int cvr::ioHandler::level_ [protected]

begin() nesting level


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

Generated on Sun Sep 20 22:08:55 2009 for CVR-Lib by Doxygen 1.5.8