Orxonox
0.0.5 Codename: Arcturus
|
A helper class to split a string into several tokens. More...
Go to the source code of this file.
Classes | |
class | orxonox::SubString |
A class that splits a string into multiple tokens using different options. More... | |
Namespaces | |
orxonox | |
Die Wagnis Klasse hat die folgenden Aufgaben: | |
A helper class to split a string into several tokens.
The class SubString can be used to split an std::string into multiple tokens, using a delimiter. SubString allows different options, for example to remove whitespaces around the delimiters or different safe-mode chars, like quotation marks and braces.
You can access the tokens of the SubString using the [] operator like an array. SubString also supports to join the tokens (or a subset of the tokens) again using join(). It's even possible to get a subset of the SubString as another SubString using subSet().
Example:
The output of this code is:
The string was split using the delimiter " ". A string between quotation mark is not split, the same holds for strings between '{' and '}'. Note how the quotation marks and the braces were removed from the tokens, because the corresponding argument is 'true'.
Also note that the comma after "test" in token 3 is still there - it is neither part of the delimiters SubString::WhiteSpaces nor part of the delimiterNeighbours parameter, so it remains a part of the token.