YGP::ParseAttomic Class Reference

Class to parse an attomic value; Base-class of all attomic values. More...

Inherits YGP::ParseObject.

Inherited by YGP::OFParseAttomic< INISection >, YGP::OFParseAttomic< ISectionParser >, YGP::CBParseAttomic, YGP::OFParseAttomic< T >, YGP::ParseExact, YGP::ParseText, and YGP::ParseToText.

List of all members.

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 ()
ParseAttomicoperator= (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


Detailed Description

Class to parse an attomic value; Base-class of all attomic values.

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.


Member Enumeration Documentation

anonymous enum [protected]

Possible errors of checkIntegrity.

Enumerator:
MAX_MIN_ERROR  Maximal cardinality is below minimal one.
NO_VALUE  Object contains no valid values.


Constructor & Destructor Documentation

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.

Parameters:
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
Precondition:
!checkIntegrity ()

YGP::ParseAttomic::ParseAttomic ( const ParseAttomic other  ) 

Copy-constructor.

Parameters:
other Object to clone

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

Destructor.


Member Function Documentation

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

Checks if this object is in a valid state.

Returns:
int Status; 0 OK

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:

  • 9: ch is valid if it is a digit
  • A: ch is valid if it is alphabetic
  • X: ch is valid if it is alphanumeric
  • ' ' (blank): ch is valid if it is a white-space
  • 0: ch is valid if it is the zero-character (\0)
  • \: ch is valid if it is the back-slash (\) itself
  • r: ch is valid if it is carriage-return (\r)
  • n: ch is valid if it is line-feed (\n)
  • *: ch is always valid.
    • Else: ch is valid if it equal to this char
      Parameters:
      ch Char to check
      Returns:
      int Result; 1 if ch valid, -1 if it should be just ignored. Else 0

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.

Parameters:
stream Source from which to read
optional Flag, if node must be found
Exceptions:
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  ) 

Assignment-operator.

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

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.


Member Data Documentation

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.


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