Serial-TCP/IPbridge
1.0
|
Configuration parser. More...
#include <config_parser.h>
Classes | |
class | ParsingError |
This exception is thrown if there is an error during parsing. More... | |
Public Types | |
typedef std::map< std::string, std::string > | ParsedConfig |
Option -> values mapping. More... | |
Static Public Member Functions | |
static ParsedConfig | parse (const std::string &rawConfig) |
Parses a configuration from the selected string. More... | |
Private Member Functions | |
ConfigParser () | |
ConfigParser (const ConfigParser &) | |
ConfigParser & | operator= (const ConfigParser &) |
~ConfigParser () | |
Static Private Member Functions | |
static bool | isValidOptionChar (char c) |
Checks whether the selected character is a valid part of an option name. More... | |
static bool | isValidValueChar (char c) |
Checks whether the selected character is a valid part of an option value. More... | |
Configuration parser.
This class is used to parse a configuration string that is in format:
option1 value1
option2 value2
Comments are not be parsed. Option values must be separated from the option name by whitespaces and are parsed until an end of line ('
'). This means that each option-value pair must be ended with a new line. Option names can contain only alphanumeric characters and the following characters: '_', '-'. Option values can contain any characters except '
'.
If there are more than one option with the same name, only the last value of this option will be taken into account.
Static helper class (aka "library class").
typedef std::map<std::string, std::string> ConfigParser::ParsedConfig |
Option -> values mapping.
|
private |
|
private |
|
private |
|
staticprivate |
Checks whether the selected character is a valid part of an option name.
c | Character to be checked. |
|
staticprivate |
Checks whether the selected character is a valid part of an option value.
c | Character to be checked. |
|
private |
|
static |
Parses a configuration from the selected string.
rawConfig | The string from which the configuration will be parsed. |
See class description for more info about the configuration format. If there is an error during parsing, ParsingError will be thrown.
Meets the strong guarantee of exception safety.