Inherits YGP::ParseObject.
Inherited by YGP::CBParseSequence, YGP::OFParseSequence< T >, and YGP::ParseSelection.
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 () |
ParseSequence & | operator= (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 |
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.
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.
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 |
YGP::ParseSequence::ParseSequence | ( | const ParseSequence & | other | ) |
Copy-constructor.
other | Object to clone |
YGP::ParseSequence::~ParseSequence | ( | ) | [virtual] |
Destructor.
int YGP::ParseSequence::checkIntegrity | ( | ) | const [protected, virtual] |
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.
stream | Source from which to read | |
optional | Flag, if object must be found |
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 | ) |
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.
unsigned int YGP::ParseSequence::maxCard [protected] |
Maximal cardinality of the sequence.
unsigned int YGP::ParseSequence::minCard [protected] |
Minimal cardinality of the sequence.
ParseObject** YGP::ParseSequence::ppList [protected] |
Pointer to array of objects in the sequence.