bpp-core3
3.0.0
|
Tools to deal with the keyval syntax. More...
#include <Bpp/Text/KeyvalTools.h>
Public Member Functions | |
KeyvalTools () | |
virtual | ~KeyvalTools () |
Static Public Member Functions | |
static void | singleKeyval (const std::string &desc, std::string &key, std::string &val, const std::string &split="=") |
Split a string into a key and a value (General purpose function). More... | |
static void | multipleKeyvals (const std::string &desc, std::map< std::string, std::string > &keyvals, const std::string &split=",", bool nested=true) |
Split a string into several keys and corresponding values (General purpose function). More... | |
static std::string | changeKeyvals (const std::string &desc, const std::map< std::string, std::string > &newkeyvals, const std::string &split=",", bool nested=true) |
Change several keys to new corresponding values (General purpose function). More... | |
static void | parseProcedure (const std::string &desc, std::string &name, std::map< std::string, std::string > &args) |
Parse (not recursively) a procedure string. More... | |
Tools to deal with the keyval syntax.
This class contains method to deal with parameter=value syntax procedure. A keyval procedure takes the form
where 'p' are parameter names, and 'v' are the corresponding values. These values can be nested keyval procedures.
Definition at line 39 of file KeyvalTools.h.
bpp::KeyvalTools::KeyvalTools | ( | ) |
|
virtual |
|
static |
Change several keys to new corresponding values (General purpose function).
desc | [in] A string descibing the keyval, with format key1=val1,key2=val2,etc (space are considered normal character, that's up to you to deal with that afterwards!). |
newkeyvals | [in] contains the text of the keys to be changed and their new corresponding values. If a key is not in desc, it is not added. |
split | [in] The keyval delimiter. The default is a coma, but a space character can be used for instance. |
nested | [in] Tell if nested keyval procedures are expected. |
KeyvalException | If the syntax describing the keyval is not correct. |
Definition at line 63 of file KeyvalTools.cpp.
References bpp::StringTokenizer::hasMoreToken(), bpp::TextTools::isEmpty(), bpp::StringTokenizer::nextToken(), bpp::TextTools::removeFirstWhiteSpaces(), and bpp::TextTools::removeSurroundingWhiteSpaces().
|
static |
Split a string into several keys and corresponding values (General purpose function).
desc | [in] A string descibing the keyval, with format key1=val1,key2=val2,etc (space are considered normal character, that's up to you to deal with that afterward!). |
keyvals | [out] Will contain the text of the keys and their corresponding values. |
split | [in] The keyval delimiter.the default is a coma, but a space character can be used for instance. |
nested | [in] Tell if nested keyval procedures are expected. |
KeyvalException | If the syntax describing the keyval is not correct. |
Definition at line 23 of file KeyvalTools.cpp.
References bpp::StringTokenizer::hasMoreToken(), bpp::StringTokenizer::nextToken(), and bpp::TextTools::removeSurroundingWhiteSpaces().
Referenced by bpp::NumCalcApplicationTools::getVector().
|
static |
Parse (not recursively) a procedure string.
desc | [in] A string descibing the keyval procedure. |
name | [out] Outputs the name of the procedure. |
args | [out] Fills a map with all keys and values for parameters. |
KeyvalException | If the description is invalid (one parenthesis is missing for instance). |
Definition at line 137 of file KeyvalTools.cpp.
References bpp::TextTools::isEmpty(), and bpp::TextTools::removeFirstWhiteSpaces().
Referenced by bpp::BppODiscreteDistributionFormat::readDiscreteDistribution().
|
static |
Split a string into a key and a value (General purpose function).
desc | [in] A string descibing the keyval, with format key=val (space are considered normal character, that's up to you to deal with that afterward!). |
key | [out] Will contain the text of the key. |
val | [out] Will contain the text of the value. |
split | [in] The delimiter. Default is '=' but ':' can be used. |
KeyvalException | If the syntax describing the keyval is not correct. |
Definition at line 14 of file KeyvalTools.cpp.