Orxonox: orxonox::SubString Class Reference

# orxonox::SubString Class Reference

A class that can load one string and split it in multipe ones. More...

`#include <src/util/SubString.h>`

List of all members.

## 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

## Detailed Description

A class that can load one string and split it in multipe ones.

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.

## Member Enumeration Documentation

enum orxonox::SubString::SPLIT_LINE_STATE

An enumerator for the State the Parser is in.

Enumerator:

  SL_NORMAL | Normal state.
  SL_ESCAPE | After an escape character.
  SL_SAFEMODE | In safe mode (between "" mostly).
  SL_SAFEESCAPE | In safe mode with the internal escape character, that escapes even the savemode character.
  SL_COMMENT | In Comment mode.
  SL_PARENTHESES | Between parentheses (usually '(' and ')').
  SL_PARENTHESESESCAPE | Between parentheses with the internal escape character, that escapes even the closing paranthesis character.

## Constructor & Destructor Documentation

orxonox::SubString::SubString | ( |  | ) |

default constructor

Referenced by operator+(), and subSet().

orxonox::SubString::SubString | ( | const std::string & | string,
|  | char | delimiter = `','` |
| ) |  |  |

create a SubString from

Parameters:

  | string | the String to Split
  | delimiter | the Character at which to split string (delimiter)

References split().

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.

Parameters:

  | 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.

Parameters:

  | argc,: | the Arguments Count.
  | argv,: | Argument Values.

References bInSafemode, and strings.

orxonox::SubString::SubString | ( | const SubString & | subString | ) | `[inline]`

create a Substring as a copy of another one.

Parameters:

  | subString | the SubString to copy.

orxonox::SubString::SubString | ( | const SubString & | subString,
|  | unsigned int | subSetBegin |
| ) |  |  |

creates a SubSet of a SubString.

Parameters:

  | 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.

Parameters:

  | 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

## Member Function Documentation

SubString& orxonox::SubString::append | ( | const SubString | subString | ) | `[inline]`

added for convenience

Parameters:

  | subString | the String to append

Returns:
  appended String.

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.

Parameters:

  | subString | the SubString to compare against this one.
  | length | how many entries to compare. (from 0 to length)

Returns:
  true if the Stored Strings match

References bInSafemode, size(), and strings.

bool orxonox::SubString::compare | ( | const SubString & | subString | ) | const

comparator.

Parameters:

  | subString | the SubString to compare against this one.

Returns:
  true if the Stored Strings match

void orxonox::SubString::debug | ( |  | ) | const

Some nice debug information about this SubString.

References strings.

bool orxonox::SubString::empty | ( |  | ) | const`[inline]`

Returns true if the SubString is empty.

Referenced by join().

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.

Parameters:

  | i | the i'th String

bool orxonox::SubString::isInSafemode | ( | unsigned int | i | ) | const`[inline]`

Returns true if the token is in safemode.

Parameters:

  | 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.

Parameters:

  | delimiter | the String between the subStrings.

Returns:
  the joined String.

References empty(), and strings.

Referenced by orxonox::ConfigValueContainer::callFunctionWithIndex(), orxonox::CommandEvaluation::complete(), and orxonox::CommandEvaluation::execute().

SubString orxonox::SubString::operator+ | ( | const SubString & | subString | ) | const

append operator

Parameters:

  | subString | the String to append.

Returns:
  a SubString where this and subString are appended.

References SubString().

SubString & orxonox::SubString::operator+= | ( | const SubString & | subString | ) |

append operator.

Parameters:

  | subString | append subString to this SubString.

Returns:
  this substring appended with subString

References bInSafemode, isInSafemode(), size(), and strings.

SubString & orxonox::SubString::operator= | ( | const SubString & | subString | ) |

stores the Value of subString in this SubString

Parameters:

  | subString | will be copied into this String.

Returns:
  this SubString.

References bInSafemode, and strings.

bool orxonox::SubString::operator== | ( | const SubString & | subString | ) | const

comparator.

Parameters:

  | subString | the SubString to compare against this one.

Returns:
  true if the Stored Strings match

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.

Parameters:

  | 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.

Parameters:

  | 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.

Parameters:

  | 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.

Parameters:

  | 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.

Returns:
  SPLIT_LINE_STATE the parser was in when returning

This is the Actual Splitting Algorithm from Clemens Wacha Supports delimiters, escape characters, ignores special characters between safemode_char and between comment_char and linend '
'.

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.

Parameters:

  | subSetBegin | the beginning to
  | subSetEnd | the end of the SubSet to select (if bigger than subString.size() it will be downset.)

Returns:
  the SubSet

This function is added for your convenience, and does the same as SubString::SubString(const SubString& subString, unsigned int subSetBegin)

References SubString().

SubString orxonox::SubString::subSet | ( | unsigned int | subSetBegin | ) | const

creates a SubSet of a SubString.

Parameters:

  | subSetBegin | the beginning to the end

Returns:
  the SubSet

This function is added for your convenience, and does the same as SubString::SubString(const SubString& subString, unsigned int subSetBegin)

References SubString().

Referenced by orxonox::ConfigValueContainer::callFunctionWithIndex(), orxonox::CommandEvaluation::complete(), and orxonox::CommandEvaluation::execute().

## Member Data Documentation

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.

The documentation for this class was generated from the following files:

- src/util/SubString.h
- src/util/SubString.cc