Archon::Utilities::ParseValues Namespace Reference

Basic value parsing. More...


Functions

bool parseBoolean (bool versatile, const char *s, const char *stop=0) throw (ParseException)
 Produce a boolean value from the contents of a string.
int parseInteger (bool acceptSign, const char *s, const char *stop=0) throw (ParseException)
 Produce an integer value from the contents of a string.
double parseDouble (const char *s, const char *stop=0) throw (ParseException)
 Produce a floating point value from the contents of a string.
string parseString (const char *s, const char *stop) throw (ParseException)
 Produce a non-empty string value from the contents of a string.


Detailed Description

Basic value parsing.

Todo:
These functions are not currently UNICODE enabled.

Todo:
All these functions should take generalized character iterator arguments in the STL spirit.


Function Documentation

bool Archon::Utilities::ParseValues::parseBoolean bool  versatile,
const char *  s,
const char *  stop = 0
throw (ParseException)
 

Produce a boolean value from the contents of a string.

Parameters:
versatile Set to true if you want to this function to recognize many forms of boolean values and not just 'true' and 'false'.
s Normally a pointer to a zero terminated string, but if 'stop' is specified (not null) a zero will be treated like any other character and thus the string can no longer and need no longer be zero terminated.
stop If specified (not null) consider all chars pointed to by {p: p>=s & p<stop} which mat include a number of zero characters.
The following regular expression denotes the class of accepted strings when versatile mode is not selected:

   /^(true|false)$/i

 

In versatile mode it becomes:

   /^(true|false|[0-9]+|y|n|yes|no|on|off)$/i

 

Note:
The 'i' suffix means ignore case.

Definition at line 49 of file parse_values.C.

References parseInteger().

Referenced by Archon::Utilities::Options::Parser< T >::parse().

double Archon::Utilities::ParseValues::parseDouble const char *  s,
const char *  stop = 0
throw (ParseException)
 

Produce a floating point value from the contents of a string.

Parameters:
s Normally a pointer to a zero terminated string, but if 'stop' is specified (not null) a zero will be treated like any other character and thus the string can no longer and need no longer be zero terminated.
stop If specified (not null) consider all chars pointed to by {p: p>=s & p<stop} which mat include a number of zero characters.
The following regular expression denotes the class of accepted strings:

   /^(\+|-)?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(e(\+|-)?[0-9]+)?$/i

 

Note:
The 'i' suffix means ignore case.

Definition at line 102 of file parse_values.C.

References parseInteger().

Referenced by Archon::Utilities::Options::Parser< T >::parse().

int Archon::Utilities::ParseValues::parseInteger bool  acceptSign,
const char *  s,
const char *  stop = 0
throw (ParseException)
 

Produce an integer value from the contents of a string.

Parameters:
acceptSign Set to true if you want to this function to recognize integers prefixed with a sign +/-.
s Normally a pointer to a zero terminated string, but if 'stop' is specified (not null) a zero will be treated like any other character and thus the string can no longer and need no longer be zero terminated.
stop If specified (not null) consider all chars pointed to by {p: p>=s & p<stop} which mat include a number of zero characters.
The following regular expression denotes the class of accepted strings when signs are not allowed:

   /^[0-9]+$/

 

When signs are allowed it becomes:

   /^(\+|-)?[0-9]+$/

 

Definition at line 71 of file parse_values.C.

Referenced by Archon::Utilities::Options::Parser< T >::parse(), parseBoolean(), and parseDouble().

string Archon::Utilities::ParseValues::parseString const char *  s,
const char *  stop
throw (ParseException)
 

Produce a non-empty string value from the contents of a string.

Parameters:
s Normally a pointer to a zero terminated string, but if 'stop' is specified (not null) a zero will be treated like any other character and thus the string can no longer and need no longer be zero terminated.
stop If specified (not null) consider all chars pointed to by {p: p>=s & p<stop} which mat include a number of zero characters.
The following regular expression denotes the class of accepted strings:

   /^.+$/

 

Definition at line 153 of file parse_values.C.


Generated on Sun Jul 30 22:58:11 2006 for Archon by  doxygen 1.4.4