Inherits YGP::ParseObject.
Inherited by YGP::OFParseAttomic< INISection >, YGP::OFParseAttomic< ISectionParser >, YGP::CBParseAttomic, YGP::OFParseAttomic< T >, YGP::ParseExact, YGP::ParseText, and YGP::ParseToText.
Public Member Functions | |
ParseAttomic (const char *value, const char *description, unsigned int max=1, unsigned int min=1, bool skipWhitespace=true, bool reportData=true) | |
ParseAttomic (const ParseAttomic &other) | |
virtual | ~ParseAttomic () |
ParseAttomic & | operator= (const ParseAttomic &other) |
Accessing values | |
const char * | getValue () const |
unsigned int | getMaxCard () const |
unsigned int | getMinCard () const |
void | setMaxCard (unsigned int val) |
void | setMinCard (unsigned int val) |
void | setValue (const char *value) |
Protected Types | |
enum | { MAX_MIN_ERROR = ParseObject::LAST, NO_VALUE, LAST } |
Protected Member Functions | |
virtual int | checkIntegrity () const |
virtual int | checkValue (char ch) |
virtual int | doParse (Xistream &stream, bool optional) throw (YGP::ParseError) |
Protected Attributes | |
const char * | pValue |
unsigned int | maxCard |
unsigned int | minCard |
The pValue parameter has the following semantic:
A parsed character is valid if it occures in the pValue-list, where the backslash (\) escapes the next charater to the following meaning:
The members maxCard
and minCard
specify how many characters the object can or must have. If there are less matching characters parsed, the object is considered as not found; after reaching the upper border, parsing is stopped for this object.
skipWhitespace
does exactly that, after an object was parsed successfully.
The parameter reportData
specifies, if the parsed data should be stored and passed via the found-method. Setting to false disables also putting back previously parsed data, so only do that, if parsing always succeeds and you don't care about the parsed contents!
See ParseObject for a general description of the parser.
anonymous enum [protected] |
YGP::ParseAttomic::ParseAttomic | ( | const char * | value, | |
const char * | description, | |||
unsigned int | max = 1 , |
|||
unsigned int | min = 1 , |
|||
bool | skipWhitespace = true , |
|||
bool | reportData = true | |||
) |
Constructor; sets the neccessary data of this object.
value | List of valid characters (see class description) | |
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 trailing whitespaces should be skipped after sucessfully parsing the object | |
reportData | Flag if parsed data should be stored and reported via the virtual found method |
YGP::ParseAttomic::ParseAttomic | ( | const ParseAttomic & | other | ) |
Copy-constructor.
other | Object to clone |
YGP::ParseAttomic::~ParseAttomic | ( | ) | [virtual] |
Destructor.
int YGP::ParseAttomic::checkIntegrity | ( | ) | const [protected, virtual] |
Checks if this object is in a valid state.
Reimplemented from YGP::ParseObject.
Reimplemented in YGP::ParseExact, and YGP::ParseUpperExact.
int YGP::ParseAttomic::checkValue | ( | char | ch | ) | [protected, virtual] |
Checks if the passed character is valid according to pValue.
Valid are all characters specified in pValue. If pValue
contains a backslash (\) the next character has a special meaning:
0
: ch is valid if it is the zero-character (\0)ch | Char to check |
Reimplemented in YGP::ParseText, YGP::ParseTextEsc, YGP::ParseQuoted, YGP::ParseQuotedEsc, YGP::ParseExact, and YGP::ParseUpperExact.
int YGP::ParseAttomic::doParse | ( | Xistream & | stream, | |
bool | optional | |||
) | throw (YGP::ParseError) [protected, virtual] |
Tries to parse the object from the stream, as long as checkValue() reports the input as valid (or as to ignore, by returning -1).
Returns PARSE_OK
if data matching the object is found (and the callback does not report something different).
It is a soft error (PARSE_ERROR
) if the minimal cardinality is not fullfilled. If parsing is optional or the error is recoverable (> 0), the parsed data is pushed back into the stream and PARSE_ERROR
is returned. If parsing is not optional and the error is not recoverable (< 0), an exception (std::string) is thrown.
stream | Source from which to read | |
optional | Flag, if node must be found |
YGP::ParseError | In case of a not recoverable error |
Implements YGP::ParseObject.
Reimplemented in YGP::ParseToText.
unsigned int YGP::ParseAttomic::getMaxCard | ( | ) | const [inline] |
Returns the maximal cardinality for this object.
unsigned int YGP::ParseAttomic::getMinCard | ( | ) | const [inline] |
Returns the minimal cardinality for this object.
const char* YGP::ParseAttomic::getValue | ( | ) | const [inline] |
Returns the valid values for this object.
ParseAttomic & YGP::ParseAttomic::operator= | ( | const ParseAttomic & | other | ) |
void YGP::ParseAttomic::setMaxCard | ( | unsigned int | val | ) | [inline] |
Sets the valid values for this object.
void YGP::ParseAttomic::setMinCard | ( | unsigned int | val | ) | [inline] |
Sets the maximal cardinality for this object.
void YGP::ParseAttomic::setValue | ( | const char * | value | ) | [inline] |
Sets the minimal cardinality for this object.
unsigned int YGP::ParseAttomic::maxCard [protected] |
Maximal cardinality of the object.
unsigned int YGP::ParseAttomic::minCard [protected] |
Minimal cardinality of the object.
const char* YGP::ParseAttomic::pValue [protected] |
Pointer to the valid values.