sfl Namespace Reference

For code copy-pasted from the Sunflower mobile robot library. More...


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


Detailed Description

For code copy-pasted from the Sunflower mobile robot library.

Function Documentation

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";
     }

Returns:
true if there is more to be extracted, allowing you to easily tokenize a string. But see also tokenize() which does just that.

bool sfl::splitstring ( string const &  input,
char  separator,
string &  head,
string &  tail 
)

Definition at line 67 of file strutil.cpp.

Referenced by tokenize().

template<typename Foo>
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().

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

template<typename Foo>
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().

Here is the call graph for this function:

template<typename Foo>
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().

template<>
std::string sfl::to_string< bool > ( const bool &  flag  )  [inline]

booleans are better represented by "true" and "false" than by 1 and 0.

template<typename tokenlist_t, typename value_t>
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().

Here is the call graph for this function:

template<typename tokenlist_t>
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().

Here is the call graph for this function:


Generated on Fri Aug 26 01:35:50 2011 for Stanford Whole-Body Control Framework by  doxygen 1.5.4