#include <src/util/SubString.h>
Public Types | |
enum | SPLIT_LINE_STATE { SL_NORMAL, SL_ESCAPE, SL_SAFEMODE, SL_SAFEESCAPE, SL_COMMENT, SL_PARENTHESES, SL_PARENTHESESESCAPE } |
An enumerator for the State the Parser is in. More... | |
Public Member Functions | |
SubString & | append (const SubString subString) |
added for convenience | |
const std::string & | back () const |
Returns the back of the StringList. | |
bool | compare (const SubString &subString, unsigned int length) const |
comparator. | |
bool | compare (const SubString &subString) const |
comparator. | |
void | debug () const |
Some nice debug information about this SubString. | |
bool | empty () const |
Returns true if the SubString is empty. | |
const std::string & | front () const |
Returns the front of the StringList. | |
const std::vector< std::string > & | getAllStrings () const |
Returns all Strings as std::vector. | |
const std::string & | getString (unsigned int i) const |
Returns the i'th string from the subset of Strings. | |
bool | isInSafemode (unsigned int i) const |
Returns true if the token is in safemode. | |
std::string | join (const std::string &delimiter=" ") const |
joins together all Strings of this Substring. | |
SubString | operator+ (const SubString &subString) const |
append operator | |
SubString & | operator+= (const SubString &subString) |
append operator. | |
SubString & | operator= (const SubString &subString) |
stores the Value of subString in this SubString | |
bool | operator== (const SubString &subString) const |
comparator. | |
const std::string & | operator[] (unsigned int i) const |
Returns the i'th string from the subset of Strings. | |
void | pop_back () |
removes the back of the strings list. | |
unsigned int | size () const |
Returns the count of Strings stored in this substring. | |
unsigned int | split (const std::string &string, const std::string &delimiters, const std::string &delimiterNeighbours="", bool emptyEntries=false, char escapeChar='\\', bool removeExcapeChar=true, char safemode_char= '"', bool removeSafemodeChar = true, char openparenthesis_char = '(', char closeparenthesis_char = ')', bool removeParenthesisChars = true, char comment_char = '\0') |
Splits a String into multiple splitters. | |
unsigned int | split (const std::string &string="", char delimiter= ',') |
Split the String at. | |
SubString | subSet (unsigned int subSetBegin, unsigned int subSetEnd) const |
creates a SubSet of a SubString. | |
SubString | subSet (unsigned int subSetBegin) const |
creates a SubSet of a SubString. | |
SubString (const SubString &subString, unsigned int subSetBegin, unsigned int subSetEnd) | |
creates a SubSet of a SubString. | |
SubString (const SubString &subString, unsigned int subSetBegin) | |
creates a SubSet of a SubString. | |
SubString (const SubString &subString) | |
create a Substring as a copy of another one. | |
SubString (unsigned int argc, const char **argv) | |
creates a Substring from a count and values set. | |
SubString (const std::string &string, const std::string &delimiters, const std::string &delimiterNeighbours="", bool emptyEntries=false, char escapeChar='\\', bool removeEscapeChar=true, char safemode_char= '"', bool removeSafemodeChar = true, char openparenthesis_char = '(', char closeparenthesis_char = ')', bool removeParenthesisChars = true, char comment_char = '\0') | |
Splits a String into multiple splitters. | |
SubString (const std::string &string, char delimiter= ',') | |
create a SubString from | |
SubString () | |
default constructor | |
~SubString () | |
removes the object from memory | |
Static Public Member Functions | |
static SPLIT_LINE_STATE | splitLine (std::vector< std::string > &ret, std::vector< bool > &bInSafemode, const std::string &line, const std::string &delimiters=SubString::WhiteSpaces, const std::string &delimiterNeighbours="", bool emptyEntries=false, char escape_char= '\\', bool removeExcapeChar=true, char safemode_char= '"', bool removeSafemodeChar = true, char openparenthesis_char = '(', char closeparenthesis_char = ')', bool removeParenthesisChars = true, char comment_char = '\0', SPLIT_LINE_STATE start_state = SL_NORMAL) |
splits line into tokens and stores them in ret. | |
Static Public Attributes | |
static const SubString | NullSubString = SubString() |
static const std::string | WhiteSpaces = " \n\t" |
An empty String. | |
static const std::string | WhiteSpacesWithComma = " \n\t," |
Helper that gets you a String consisting of all WhiteSpaces and the Comma. | |
Private Attributes | |
std::vector< bool > | bInSafemode |
std::vector< std::string > | strings |
strings produced from a single string splitted in multiple strings |
SubString is a very Powerfull way to create a SubSet from a String It can be used, to Split strings append them and join them again.
An enumerator for the State the Parser is in.
orxonox::SubString::SubString | ( | ) |
orxonox::SubString::SubString | ( | const std::string & | string, | |
char | delimiter = ',' | |||
) |
orxonox::SubString::SubString | ( | const std::string & | string, | |
const std::string & | delimiters, | |||
const std::string & | delimiterNeighbours = "" , |
|||
bool | emptyEntries = false , |
|||
char | escapeChar = '\\' , |
|||
bool | removeEscapeChar = true , |
|||
char | safemode_char = '"' , |
|||
bool | removeSafemodeChar = true , |
|||
char | openparenthesis_char = '(' , |
|||
char | closeparenthesis_char = ')' , |
|||
bool | removeParenthesisChars = true , |
|||
char | comment_char = '\0' | |||
) |
Splits a String into multiple splitters.
string | the String to split | |
delimiters | multiple set of characters at what to split. (delimiters) | |
delimiterNeighbours | neighbours of the delimiters, that will be erased only when near a delimiter. | |
emptyEntries | If empty entries should be allewed or removed. | |
escapeChar | The Escape Character that overrides splitters commends and so on... | |
safemode_char | within these characters splitting won't happen | |
comment_char | the Comment character. |
References bInSafemode, splitLine(), and strings.
orxonox::SubString::SubString | ( | unsigned int | argc, | |
const char ** | argv | |||
) |
creates a Substring from a count and values set.
argc,: | the Arguments Count. | |
argv,: | Argument Values. |
References bInSafemode, and strings.
orxonox::SubString::SubString | ( | const SubString & | subString | ) | [inline] |
orxonox::SubString::SubString | ( | const SubString & | subString, | |
unsigned int | subSetBegin | |||
) |
creates a SubSet of a SubString.
subString | the SubString to take a set from. | |
subSetBegin | the beginning to the end |
References bInSafemode, isInSafemode(), size(), and strings.
orxonox::SubString::SubString | ( | const SubString & | subString, | |
unsigned int | subSetBegin, | |||
unsigned int | subSetEnd | |||
) |
creates a SubSet of a SubString.
subString | the SubString to take a Set from | |
subSetBegin | the beginning to the end | |
subSetEnd | the end of the SubSet (max subString.size() will be checked internaly) |
References bInSafemode, isInSafemode(), size(), and strings.
orxonox::SubString::~SubString | ( | ) |
removes the object from memory
added for convenience
subString | the String to append |
const std::string& orxonox::SubString::back | ( | ) | const [inline] |
Returns the back of the StringList.
bool orxonox::SubString::compare | ( | const SubString & | subString, | |
unsigned int | length | |||
) | const |
comparator.
subString | the SubString to compare against this one. | |
length | how many entries to compare. (from 0 to length) |
References bInSafemode, size(), and strings.
bool orxonox::SubString::compare | ( | const SubString & | subString | ) | const |
comparator.
subString | the SubString to compare against this one. |
void orxonox::SubString::debug | ( | ) | const |
bool orxonox::SubString::empty | ( | ) | const [inline] |
const std::string& orxonox::SubString::front | ( | ) | const [inline] |
Returns the front of the StringList.
const std::vector<std::string>& orxonox::SubString::getAllStrings | ( | ) | const [inline] |
Returns all Strings as std::vector.
const std::string& orxonox::SubString::getString | ( | unsigned int | i | ) | const [inline] |
Returns the i'th string from the subset of Strings.
i | the i'th String |
bool orxonox::SubString::isInSafemode | ( | unsigned int | i | ) | const [inline] |
Returns true if the token is in safemode.
i | the i'th token |
Referenced by operator+=(), and SubString().
std::string orxonox::SubString::join | ( | const std::string & | delimiter = " " |
) | const |
joins together all Strings of this Substring.
delimiter | the String between the subStrings. |
References empty(), and strings.
Referenced by orxonox::ConfigValueContainer::callFunctionWithIndex(), orxonox::CommandEvaluation::complete(), and orxonox::CommandEvaluation::execute().
append operator
subString | the String to append. |
References SubString().
append operator.
subString | append subString to this SubString. |
References bInSafemode, isInSafemode(), size(), and strings.
stores the Value of subString in this SubString
subString | will be copied into this String. |
References bInSafemode, and strings.
bool orxonox::SubString::operator== | ( | const SubString & | subString | ) | const |
comparator.
subString | the SubString to compare against this one. |
References bInSafemode, and strings.
const std::string& orxonox::SubString::operator[] | ( | unsigned int | i | ) | const [inline] |
Returns the i'th string from the subset of Strings.
i | the i'th String |
void orxonox::SubString::pop_back | ( | ) | [inline] |
removes the back of the strings list.
unsigned int orxonox::SubString::size | ( | ) | const [inline] |
Returns the count of Strings stored in this substring.
Referenced by orxonox::CommandLine::_parseFile(), orxonox::CommandExecutor::argumentsGiven(), orxonox::ConfigValueContainer::callFunctionWithIndex(), compare(), orxonox::CommandEvaluation::complete(), orxonox::Executor::evaluate(), orxonox::CommandEvaluation::evaluateParams(), orxonox::CommandEvaluation::execute(), orxonox::GraphicsManager::loadOgrePlugins(), operator+=(), orxonox::Button::parse(), orxonox::Game::requestStates(), SubString(), and orxonox::Namespace::XMLPort().
unsigned int orxonox::SubString::split | ( | const std::string & | string, | |
const std::string & | delimiters, | |||
const std::string & | delimiterNeighbours = "" , |
|||
bool | emptyEntries = false , |
|||
char | escapeChar = '\\' , |
|||
bool | removeExcapeChar = true , |
|||
char | safemode_char = '"' , |
|||
bool | removeSafemodeChar = true , |
|||
char | openparenthesis_char = '(' , |
|||
char | closeparenthesis_char = ')' , |
|||
bool | removeParenthesisChars = true , |
|||
char | comment_char = '\0' | |||
) |
Splits a String into multiple splitters.
string | the String to split | |
delimiters | multiple set of characters at what to split. (delimiters) | |
delimiterNeighbours,: | Neighbours to the Delimiters that will be erased too. | |
emptyEntries,: | If empty entries are added to the List of SubStrings | |
escapeChar | The Escape Character that overrides splitters commends and so on... | |
safemode_char | within these characters splitting won't happen | |
comment_char | the Comment character. |
References bInSafemode, splitLine(), and strings.
unsigned int orxonox::SubString::split | ( | const std::string & | string = "" , |
|
char | splitter = ',' | |||
) |
Split the String at.
string | where to split | |
splitter | delimiter. |
References bInSafemode, splitLine(), and strings.
Referenced by orxonox::CommandEvaluation::initialize(), orxonox::CommandExecutor::parse(), and SubString().
SubString::SPLIT_LINE_STATE orxonox::SubString::splitLine | ( | std::vector< std::string > & | ret, | |
std::vector< bool > & | bInSafemode, | |||
const std::string & | line, | |||
const std::string & | delimiters = SubString::WhiteSpaces , |
|||
const std::string & | delimiterNeighbours = "" , |
|||
bool | emptyEntries = false , |
|||
char | escape_char = '\\' , |
|||
bool | removeExcapeChar = true , |
|||
char | safemode_char = '"' , |
|||
bool | removeSafemodeChar = true , |
|||
char | openparenthesis_char = '(' , |
|||
char | closeparenthesis_char = ')' , |
|||
bool | removeParenthesisChars = true , |
|||
char | comment_char = '\0' , |
|||
SPLIT_LINE_STATE | start_state = SL_NORMAL | |||
) | [static] |
splits line into tokens and stores them in ret.
ret | the Array, where the Splitted strings will be stored in to the beginning of the current token is stored | |
line | the inputLine to split | |
delimiters | a String of Delimiters (here the input will be splitted) | |
delimiterNeighbours | Naighbours to the Delimitter, that will be removed if they are to the left or the right of a Delimiter. | |
emptyEntries,: | if empty Strings are added to the List of Strings. | |
escape_char,: | Escape carater (escapes splitters) | |
safemode_char,: | the beginning of the safemode is marked with this | |
removeSafemodeChar | removes the safemode_char from the beginning and the ending of a token | |
openparenthesis_char | the beginning of a safemode is marked with this | |
closeparenthesis_char | the ending of a safemode is marked with this | |
removeParenthesisChars | removes the parenthesis from the beginning and the ending of a token | |
comment_char,: | the beginning of a comment is marked with this: (until the end of a Line) | |
start_state,: | the Initial state on how to parse the String. |
FINISH
FINISH
FINISH
FINISH
References SL_COMMENT, SL_ESCAPE, SL_NORMAL, SL_PARENTHESES, SL_PARENTHESESESCAPE, SL_SAFEESCAPE, and SL_SAFEMODE.
Referenced by split(), and SubString().
SubString orxonox::SubString::subSet | ( | unsigned int | subSetBegin, | |
unsigned int | subSetEnd | |||
) | const |
creates a SubSet of a SubString.
subSetBegin | the beginning to | |
subSetEnd | the end of the SubSet to select (if bigger than subString.size() it will be downset.) |
References SubString().
SubString orxonox::SubString::subSet | ( | unsigned int | subSetBegin | ) | const |
creates a SubSet of a SubString.
subSetBegin | the beginning to the end |
References SubString().
Referenced by orxonox::ConfigValueContainer::callFunctionWithIndex(), orxonox::CommandEvaluation::complete(), and orxonox::CommandEvaluation::execute().
std::vector<bool> orxonox::SubString::bInSafemode [private] |
Referenced by compare(), operator+=(), operator=(), operator==(), split(), and SubString().
const SubString orxonox::SubString::NullSubString = SubString() [static] |
An Empty SubString
std::vector<std::string> orxonox::SubString::strings [private] |
strings produced from a single string splitted in multiple strings
Referenced by compare(), debug(), join(), operator+=(), operator=(), operator==(), split(), and SubString().
const std::string orxonox::SubString::WhiteSpaces = " \n\t" [static] |
An empty String.
Helper that gets you a String consisting of all White Spaces
Referenced by orxonox::ConfigValueContainer::callFunctionWithIndex(), orxonox::ConverterFallback< std::string, orxonox::ColourValue >::convert(), orxonox::ConverterFallback< std::string, orxonox::Quaternion >::convert(), orxonox::ConverterFallback< std::string, orxonox::Vector4 >::convert(), orxonox::ConverterFallback< std::string, orxonox::Vector3 >::convert(), orxonox::ConverterFallback< std::string, orxonox::Vector2 >::convert(), orxonox::Executor::evaluate(), orxonox::CommandEvaluation::initialize(), orxonox::Button::parse(), and orxonox::CommandExecutor::parse().
const std::string orxonox::SubString::WhiteSpacesWithComma = " \n\t," [static] |
Helper that gets you a String consisting of all WhiteSpaces and the Comma.