Functions | |
template<> | |
std::string | to_string< bool > (const bool &flag) |
booleans are better represented by "true" and "false" than by 1 and 0. | |
template<> | |
bool | string_to< bool > (const std::string &str, bool &foo) |
booleans are converted by string matching: "true", "True", "TRUE", "on", "On", or "ON" yield a true boolean, whereas "false", "False", "FALSE", "off", "Off", or "OFF" yield a false boolean. | |
bool | splitstring (string const &input, char separator, string &head, string &tail) |
template<typename Foo> | |
std::string | to_string (const Foo &foo) |
convert "anything" to a string by using its output operator | |
template<typename Foo> | |
bool | string_to (const std::string &str, Foo &foo) |
convert a string to "something" based on its input operator | |
template<typename Foo> | |
bool | string_to_bool (const std::string &str, Foo &foo) |
very useful for booleans that are encoded as char, int, short, or other integer formats. | |
bool | splitstring (std::string const &input, char separator, std::string &head, std::string &tail) |
Split a string at the first occurrence of a separator, and store the two portions in head and tail. | |
template<typename tokenlist_t> | |
size_t | tokenize (std::string const &input, char separator, tokenlist_t &output) |
For any tokenlist_t that accepts push_back(string const &) and can return its size(). | |
template<typename tokenlist_t, typename value_t> | |
bool | token_to (tokenlist_t const &tokenlist, size_t index, value_t &value) |
For any tokenlist_t whose operator[]() returns a string const & and which can return its size(). |
bool sfl::splitstring | ( | std::string const & | input, | |
char | separator, | |||
std::string & | head, | |||
std::string & | tail | |||
) |
Split a string at the first occurrence of a separator, and store the two portions in head and tail.
For example, "head:tail_or:whatever::comes:then" with separator ':' will yield "head" and "tail_or:whatever::comes:then". The same string split along '_' would yield "head:tail" and "or:whatever::comes:then".
Note that it's OK to pass the same instance as input and tail, but DO NOT pass the head twice.
for (int ii(1); ii < argc; ++ii) { string head; string tail(argv[ii]); while (splitstring(tail, ':', head, tail)) cout << head << "\n"; cout << head << "\n"; }
bool sfl::splitstring | ( | string const & | input, | |
char | separator, | |||
string & | head, | |||
string & | tail | |||
) |
bool sfl::string_to | ( | const std::string & | str, | |
Foo & | foo | |||
) | [inline] |
convert a string to "something" based on its input operator
Definition at line 75 of file strutil.hpp.
Referenced by string_to_bool(), and token_to().
bool sfl::string_to< bool > | ( | const std::string & | str, | |
bool & | foo | |||
) | [inline] |
booleans are converted by string matching: "true", "True", "TRUE", "on", "On", or "ON" yield a true boolean, whereas "false", "False", "FALSE", "off", "Off", or "OFF" yield a false boolean.
Anything else results in a failure (and foo is not touched).
bool sfl::string_to_bool | ( | const std::string & | str, | |
Foo & | foo | |||
) | [inline] |
very useful for booleans that are encoded as char, int, short, or other integer formats.
It sets them to 1 if string_to<bool> yields true, or to 0 if string_to<bool> yields false, but doesn't touch foo if string_to<bool> failed.
Definition at line 97 of file strutil.hpp.
References string_to().
std::string sfl::to_string | ( | const Foo & | foo | ) | [inline] |
convert "anything" to a string by using its output operator
Definition at line 63 of file strutil.hpp.
Referenced by jspace::_recurse_create_bare_tao_tree_info(), jspace::GoalControllerBase::init(), jspace::mapNodesToIDs(), and jspace::GoalControllerBase::setGoal().
std::string sfl::to_string< bool > | ( | const bool & | flag | ) | [inline] |
booleans are better represented by "true" and "false" than by 1 and 0.
bool sfl::token_to | ( | tokenlist_t const & | tokenlist, | |
size_t | index, | |||
value_t & | value | |||
) | [inline] |
For any tokenlist_t whose operator[]() returns a string const & and which can return its size().
Definition at line 154 of file strutil.hpp.
References string_to().
size_t sfl::tokenize | ( | std::string const & | input, | |
char | separator, | |||
tokenlist_t & | output | |||
) | [inline] |
For any tokenlist_t that accepts push_back(string const &) and can return its size().
Definition at line 139 of file strutil.hpp.
References splitstring().