mc_rtc::io Namespace Reference

Functions

template<typename Container , typename std::enable_if<!std::is_arithmetic< typename Container::value_type >::value, int >::type = 0>
std::string to_string (const Container &c, const std::string &delimiter=", ")
 
template<typename Container , typename std::enable_if< std::is_arithmetic< typename Container::value_type >::value, int >::type = 0>
std::string to_string (const Container &c, const std::string &delimiter=", ", const unsigned precision=std::numeric_limits< typename Container::value_type >::digits10)
 Variant of to_string that converts numeric types to string. More...
 
template<typename Container , typename Callback , typename std::enable_if<!std::is_convertible< Callback, std::string >::value, int >::type = 0>
std::string to_string (const Container &c, Callback &&get_value, const std::string &delimiter=", ")
 

Function Documentation

◆ to_string() [1/3]

template<typename Container , typename Callback , typename std::enable_if<!std::is_convertible< Callback, std::string >::value, int >::type = 0>
std::string mc_rtc::io::to_string ( const Container &  c,
Callback &&  get_value,
const std::string &  delimiter = ", " 
)

Converts a container to a string

Example:

const auto availabeRobots = mc_rtc::io::to_string(robots(), [](const mc_rbdyn::Robot & r) -> const std::string & {
*return r.name(); });
Template Parameters
ContainerAn iterable container whose unerlying type is convertible to std::string. The container must define Container::value_type.
Parameters
cContainer to convert
get_valueLambda or functor that converts a single element from the container (of type Container::value_type) to std::string
Returns
A string of all the container elements.

◆ to_string() [2/3]

template<typename Container , typename std::enable_if<!std::is_arithmetic< typename Container::value_type >::value, int >::type = 0>
std::string mc_rtc::io::to_string ( const Container &  c,
const std::string &  delimiter = ", " 
)

Converts a container to a string

Template Parameters
ContainerA container whose underlying type is convertible to std::string. The container must define Container::value_type.
Parameters
cContainer to convert
delimiterSeparator between the elements. By default they are coma-separated
Returns
A string of all the container elements.

◆ to_string() [3/3]

template<typename Container , typename std::enable_if< std::is_arithmetic< typename Container::value_type >::value, int >::type = 0>
std::string mc_rtc::io::to_string ( const Container &  c,
const std::string &  delimiter = ", ",
const unsigned  precision = std::numeric_limits<typename Container::value_type>::digits10 
)

Variant of to_string that converts numeric types to string.

Parameters
precisionNumber of digits to keep. The default precision corresponds to the number of decimal digits that can be represented without change.
mc_rtc::io::to_string
std::string to_string(const Container &c, const std::string &delimiter=", ")
Definition: io_utils.h:31
mc_rbdyn::Robot
Definition: Robot.h:62
mc_rbdyn::Robot::name
const std::string & name() const