YGP::AssignmentParse Class Reference

Class to parse a single assignment. More...

List of all members.

Public Member Functions

 AssignmentParse (const std::string &assignments)
 ~AssignmentParse ()
AssignmentParseoperator= (const std::string &newAssignment)
std::string getNextNode () throw (std::exception)
Accessing the values of the actual part; only valid after calling getNextNode
std::string getActKey () const
std::string getActValue () const

Static Public Member Functions

static void escapeQuotes (std::string &value)
Building entries
static std::string makeAssignment (const char *key, const char *value, size_t length=-1)
static std::string makeAssignment (const char *key, const std::string &value)

Static Public Attributes

static const char SEPARATOR = ';'
static const char EQUALSIGN = '='
static const char QUOTE = '"'
static const char ESCAPE = '\\'


Detailed Description

Class to parse a single assignment.

The single assignments are separated with a semicolon (;) and look like key=value or key="value".

Quoted values can still contain the quotes, if they are escaped by a leading backslash (\).

Empty assignments are silently ignored.


Constructor & Destructor Documentation

YGP::AssignmentParse::AssignmentParse ( const std::string &  assignments  )  [inline]

Constructor; from the string to analyse.

YGP::AssignmentParse::~AssignmentParse (  ) 

Destructor.


Member Function Documentation

void YGP::AssignmentParse::escapeQuotes ( std::string &  value  )  [static]

Escapes all quote-characters inside a string.

Parameters:
value String to check (and change)

std::string YGP::AssignmentParse::getNextNode (  )  throw (std::exception)

Returns the next assignment-statement.

If the value of the assignment is quoted, all quotes (") inside the value must be escaped with a backslash (\). These characters are removed by this function.

Returns:
Next node (empty string at end)
Exceptions:
YGP::ParseError describing error if node doesn't contain a valid assignment

std::string YGP::AssignmentParse::makeAssignment ( const char *  key,
const std::string &  value 
) [static]

Makes an assignment-statement with quoted value.

Every quote (") inside the value is escaped with a backslash (\).

Parameters:
key Name of key
value Value of key
Returns:
std::string Created assignment
Precondition:
key is an ASCIIZ-string

std::string YGP::AssignmentParse::makeAssignment ( const char *  key,
const char *  value,
size_t  length = -1 
) [static]

Makes an assignment-statement with quoted value.

Every quote (") inside the value is escaped with a backslash (\).

Parameters:
key Name of key
value Value of key
length Length of value; if -1 value must be zero-terminated
Returns:
std::string Created assignment
Precondition:
key is a valid pointer to length bytes or zero-terminated

AssignmentParse& YGP::AssignmentParse::operator= ( const std::string &  newAssignment  )  [inline]

Assignment operator; from the string to analyse.


Member Data Documentation

const char YGP::AssignmentParse::EQUALSIGN = '=' [static]

Character separating the "key" from the "value"; the equal sign (=).

const char YGP::AssignmentParse::ESCAPE = '\\' [static]

Character which escapes a quote inside a quoted value; the backslash (\).

const char YGP::AssignmentParse::QUOTE = '"' [static]

Character which might quote the value; the quote (").

const char YGP::AssignmentParse::SEPARATOR = ';' [static]

Character separating the entries - the semicolon (;).


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