last update 20 Sep 2009 |
#include <cvrIoHandler.h>
Public Member Functions | |
ioHandler () | |
ioHandler (const ioHandler &other) | |
virtual | ~ioHandler () |
ioHandler & | copy (const ioHandler &other) |
virtual const std::string & | name () const =0 |
virtual ioHandler * | clone () const =0 |
virtual ioHandler * | newInstance () 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_ |
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.
cvr::ioHandler::ioHandler | ( | ) |
Default constructor.
cvr::ioHandler::ioHandler | ( | const ioHandler & | other | ) |
Copy constructor.
virtual cvr::ioHandler::~ioHandler | ( | ) | [virtual] |
Destructor.
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.
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] |
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] |
virtual bool cvr::ioHandler::read | ( | short & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | unsigned long & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | long & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | bool & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | ubyte & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | byte & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | char & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | unsigned int & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | int & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | float & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | double & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::read | ( | std::string & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::readBegin | ( | ) | [virtual] |
virtual bool cvr::ioHandler::readDataSeparator | ( | ) | [pure virtual] |
virtual bool cvr::ioHandler::readEnd | ( | ) | [virtual] |
virtual bool cvr::ioHandler::readKeyValueSeparator | ( | ) | [pure virtual] |
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.
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.
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] |
virtual bool cvr::ioHandler::write | ( | const short & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const unsigned long & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const long & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const bool | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const ubyte & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const byte & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const char & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const unsigned int & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const int | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const float & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const double & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const char * | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::write | ( | const std::string & | data | ) | [pure virtual] |
virtual bool cvr::ioHandler::writeBegin | ( | ) | [virtual] |
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] |
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.
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.
data | The symbol to be written |
Implemented in cvr::lispStreamHandler.
int cvr::ioHandler::level_ [protected] |
begin() nesting level