Public Member Functions | |
AssignmentParse (const std::string &assignments) | |
~AssignmentParse () | |
AssignmentParse & | operator= (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 = '\\' |
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.
YGP::AssignmentParse::AssignmentParse | ( | const std::string & | assignments | ) | [inline] |
Constructor; from the string to analyse.
YGP::AssignmentParse::~AssignmentParse | ( | ) |
Destructor.
void YGP::AssignmentParse::escapeQuotes | ( | std::string & | value | ) | [static] |
Escapes all quote-characters inside a string.
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.
Next
node (empty string at end) 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 (\).
key | Name of key | |
value | Value of key |
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 (\).
key | Name of key | |
value | Value of key | |
length | Length of value; if -1 value must be zero-terminated |
AssignmentParse& YGP::AssignmentParse::operator= | ( | const std::string & | newAssignment | ) | [inline] |
Assignment operator; from the string to analyse.
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 (;).