YGP::ParseSequence Class Reference

Class to parse series of ParseObjects (sequences). More...

Inherits YGP::ParseObject.

Inherited by YGP::CBParseSequence, YGP::OFParseSequence< T >, and YGP::ParseSelection.

List of all members.

Public Types

enum  { MAX_MIN_ERROR = ParseObject::LAST, INVALID_LIST, LAST }

Public Member Functions

 ParseSequence (ParseObject *apObjectList[], const char *description, unsigned int max=1, unsigned int min=1, bool skipWhitespace=true)
 ParseSequence (const ParseSequence &other)
virtual ~ParseSequence ()
ParseSequenceoperator= (const ParseSequence &other)
Accessing values
unsigned int getMaxCard () const
unsigned int getMinCard () const
void setMaxCard (unsigned int val)
void setMinCard (unsigned int val)

Protected Member Functions

virtual int checkIntegrity () const
virtual int doParse (Xistream &stream, bool optional) throw (YGP::ParseError)

Protected Attributes

ParseObject ** ppList
unsigned int maxCard
unsigned int minCard


Detailed Description

Class to parse series of ParseObjects (sequences).

A sequence is only considered parsed successfully, if all of its elements are parsed successfully (in the order specified by the sequence).

Errors while parsing cause a soft error (meaning parsing can be continued) only for the first element; errors for further elements cause hard errors (which are not recoverable and parsing is ended).

The found()-method gets the name of the sequence passed als first parameter and the number of found entries as second.

See ParseObject for a general description of the parser.


Constructor & Destructor Documentation

YGP::ParseSequence::ParseSequence ( ParseObject apObjectList[],
const char *  description,
unsigned int  max = 1,
unsigned int  min = 1,
bool  skipWhitespace = true 
)

Constructor; sets the neccessary data of this object.

Parameters:
apObjectList NULL-terminated array of pointers to objects to parse
description Description of the object (what it parses)
max Maximal cardinality, how often can the object be parsed
min Minimal cardinality, how often must the object be parsed
skipWhitespace Flag if whitespaces should bS are skipped
Precondition:
apObjectList != NULL && !ParseObjectcheckIntegrity ()

YGP::ParseSequence::ParseSequence ( const ParseSequence other  ) 

Copy-constructor.

Parameters:
other Object to clone

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

Destructor.


Member Function Documentation

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

Checks the constraints of the object.

Returns:
int Status; 0 OK

Reimplemented from YGP::ParseObject.

int YGP::ParseSequence::doParse ( Xistream stream,
bool  optional 
) throw (YGP::ParseError) [protected, virtual]

Tries to parse the objects of the sequence from the stream, as long as every object reports PARSE_OK.

It is a soft error (PARSE_ERROR) if the minimal cardinality is not fullfilled. If parsing is not optional and/or the error is not recoverable (< 0), an exception (std::string) is thrown.

Parameters:
stream Source from which to read
optional Flag, if object must be found
Returns:
int PARSE_OK if selection found; PARSE_ERROR if not
Exceptions:
YGP::ParseError In case of a not recoverable error

Implements YGP::ParseObject.

Reimplemented in YGP::ParseSelection.

unsigned int YGP::ParseSequence::getMaxCard (  )  const [inline]

Returns the maximal cardinality for this object.

unsigned int YGP::ParseSequence::getMinCard (  )  const [inline]

Returns the minimal cardinality for this object.

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

Assignment-operator.

Parameters:
other Object to clone
Returns:
ParseSequence& Reference to this

void YGP::ParseSequence::setMaxCard ( unsigned int  val  )  [inline]

Sets the maximal cardinality for this object.

void YGP::ParseSequence::setMinCard ( unsigned int  val  )  [inline]

Sets the minimal cardinality for this object.


Member Data Documentation

unsigned int YGP::ParseSequence::maxCard [protected]

Maximal cardinality of the sequence.

unsigned int YGP::ParseSequence::minCard [protected]

Minimal cardinality of the sequence.

Pointer to array of objects in the sequence.


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