51 string::size_type i = desc.find(split);
52 if (i == string::npos)
53 throw KeyvalException(
"Bad syntax! keyval should be of the form 'key" + split +
"=value', found '" + desc +
"'.");
54 key = desc.substr(0, i);
55 val = desc.substr(i+1);
60 auto_ptr<StringTokenizer> st;
66 vector<string> tokens;
75 if (tokens.size() == 0)
76 throw KeyvalException(
"Invalid syntax, found '=' without argument name.");
78 throw KeyvalException(
"Invalid syntax, found '=' without argument value.");
82 tokens[tokens.size() - 1] +=
"=" + nextToken;
86 tokens.push_back(token);
89 for (vector<string>::iterator it = tokens.begin(); it != tokens.end(); it++)
91 singleKeyval(*it, key, val);
100 string::size_type begin = desc.find_first_of(
"(");
101 string::size_type end = desc.find_last_of(
")");
103 if (begin == string::npos && end == string::npos)
109 if (begin == string::npos && end != string::npos)
110 throw KeyvalException(
"Bad keyval procedure, missing opening parenthesis.");
111 if (begin == string::npos && end != string::npos)
112 throw KeyvalException(
"Bad keyval procedure, missing closing parenthesis.");
115 throw KeyvalException(
"Bad keyval procedure, extra characters after closing parenthesis: " + desc.substr(end + 1));
118 multipleKeyvals(desc.substr(begin + 1, end - begin - 1), args);
This class allows to perform a correspondence analysis.
bool hasMoreToken() const
Tell if some tokens are still available.
const std::string & nextToken()
Get the next available token. If no token is availbale, throw an Exception.
static bool isEmpty(const std::string &s)
Tell if a string is empty.
static std::string removeSurroundingWhiteSpaces(const std::string &s)
Remove all white spaces characters at the beginning and the end of a string.
static std::string removeFirstWhiteSpaces(const std::string &s)
Remove all white spaces characters at the beginning of a string.
Exception thrown by the Keyval parser.
An improved tokenizer for strings.