YGP::ParseObject Class Reference

Classes to parse objects and sequences of objects from a stream. More...

Inherited by YGP::ParseAttomic, YGP::ParseEOF, YGP::ParseSequence, and YGP::ParseSkip.

List of all members.

Public Types

enum  errors { PARSE_OK = 0, PARSE_ERROR = 1, PARSE_CB_ERROR = 2, PARSE_CB_ABORT = -1 }

Public Member Functions

 ParseObject (const char *description, bool skipWhitespace=true)
 ParseObject (const ParseObject &other)
virtual ~ParseObject ()
ParseObjectoperator= (const ParseObject &other)
const char * getDescription () const
void setDescription (const char *desc)
void setSkipWS (bool skipWhitespace)
int parse (Xistream &stream) throw (YGP::ParseError)
virtual int doParse (Xistream &stream, bool optional)=0
virtual int found (const char *pFoundValue, unsigned int)

Static Public Member Functions

static void skipWS (Xistream &stream)
static void freeBuffer ()

Protected Types

enum  objStatus { OK = 0, NO_DESCRIPTION, LAST }

Protected Member Functions

virtual int checkIntegrity () const

Protected Attributes

bool skip


Detailed Description

Classes to parse objects and sequences of objects from a stream.

If an object is found it is possible to perform an action for this event.

There are 3 kind of parsing objects: Attomic ones, which enables the parsing of some kind of data; special ones, to perform special tasks and sequences to "glue" together a set of objects.

The following attomic objects exists:

The following special objects exists:

The following sequences exists:

All of these classes exists in 3 variants:

       virtual int found (const char* pFoundValue, unsigned int);
       

       typedef int (*PARSECALLBACK)(const char*, unsigned int);
       

       typedef int (T::*PTCALLBACK)(const char*, unsigned int);
       

Any of this functions must return the following values (which specifies how the parsing should be continued):

If possible use the error-values in the ParseObject::errors enum.

Attention:
The passed const char*-pointers are only stored and not copied, so ensure that they are valid during the lifetime of each parse-object!
Note:
The parser is principally reentrent. Just take care that not two threads parse the same object at the same time (either by implementing some kind of access control or by creating the objects separately in both threads).
Base-class for parsing objects

Member Enumeration Documentation

Possible error values for the callbacks.

Enumerator:
PARSE_OK  Parsing of the object was OK.
PARSE_ERROR  Parsing of the object failed.
PARSE_CB_ERROR  The object was parsed successfully, but the callback returned an (recoverable) error.
PARSE_CB_ABORT  The object was parsed successfully, but the callback returned an (unrecoverable) error.

enum YGP::ParseObject::objStatus [protected]

Possible errors of checkIntegrity.


Constructor & Destructor Documentation

YGP::ParseObject::ParseObject ( const char *  description,
bool  skipWhitespace = true 
)

Constructor The description must be valid during the LIFETIME (OR AT LEAST the usage) of the object!

Parameters:
description Description of the object (what it parses)
skipWhitespace Flag if trailing whitespaces should be skipped after sucessfully parsing the object
Precondition:
description valid ASCIIZ string != NULL

YGP::ParseObject::ParseObject ( const ParseObject other  ) 

Copy-constructor.

Parameters:
other Object to clone

YGP::ParseObject::~ParseObject (  )  [virtual]

Destructor.


Member Function Documentation

int YGP::ParseObject::checkIntegrity (  )  const [protected, virtual]

Checks the constraints of the object.

Returns:
int Status; 0 OK

Reimplemented in YGP::ParseAttomic, YGP::ParseExact, YGP::ParseUpperExact, and YGP::ParseSequence.

virtual int YGP::ParseObject::doParse ( Xistream stream,
bool  optional 
) [pure virtual]

Method to actual parse the object.

Implemented in YGP::ParseEOF, YGP::ParseSkip, YGP::ParseAttomic, YGP::ParseToText, YGP::ParseSequence, and YGP::ParseSelection.

int YGP::ParseObject::found ( const char *  pFoundValue,
unsigned int   
) [virtual]

void YGP::ParseObject::freeBuffer (  )  [static]

Frees the buffer internally used while parsing.

Remarks:
Don't delete the buffer while parsing (inside a callback)!

const char* YGP::ParseObject::getDescription (  )  const [inline]

Returns the description of the object.

ParseObject & YGP::ParseObject::operator= ( const ParseObject other  ) 

Assignment-operator.

Parameters:
other Object to clone
Returns:
Reference to this

int YGP::ParseObject::parse ( Xistream stream  )  throw (YGP::ParseError) [inline]

Tries to parse the object; See parseObject() for a detailed description.

void YGP::ParseObject::setDescription ( const char *  desc  )  [inline]

Sets the description for the object.

void YGP::ParseObject::setSkipWS ( bool  skipWhitespace  )  [inline]

If skipWhitespace is true, trailing whitespaces are skipped.

void YGP::ParseObject::skipWS ( Xistream stream  )  [static]

Skips all whitespace characters (blank, tabulator, carriage return and line feed) from the current position in the passed stream (if the object.

Parameters:
stream Source from which to read


Member Data Documentation

bool YGP::ParseObject::skip [protected]

Flag, if whitespaces should be skipped.


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

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:27 2009 by doxygen 1.5.8