OpenSim Moco  0.4.0
Classes
String and logging utilities

Easily format and log messages; intended for internal use by Moco. More...

Classes

struct  OpenSim::make_printable_return< T >
 Return type for make_printable() More...
 
struct  OpenSim::make_printable_return< std::string >
 Specialization for std::string. More...
 
class  OpenSim::StreamFormat
 This class stores the formatting of a stream and restores that format when the StreamFormat is destructed. More...
 

Filling in a string with variables.

template<typename T >
make_printable_return< T >::type OpenSim::make_printable (const T &x)
 Convert to types that can be printed with sprintf() (vsnprintf()). More...
 
template<>
make_printable_return< std::string >::type OpenSim::make_printable (const std::string &x)
 Specialization for std::string.
 
OSIMMOCO_API std::string OpenSim::format_c (const char *,...)
 Format a char array using (C interface; mainly for internal use).
 
template<typename... Types>
std::string OpenSim::format (const std::string &formatString, Types... args)
 Format a string in the style of sprintf. More...
 
template<typename... Types>
void OpenSim::printMessage (const std::string &formatString, Types... args)
 Print a formatted string to std::cout. More...
 

Detailed Description

Easily format and log messages; intended for internal use by Moco.

Function Documentation

◆ format()

template<typename... Types>
std::string OpenSim::format ( const std::string &  formatString,
Types...  args 
)

Format a string in the style of sprintf.

For example, the code format("%s %d and %d yields %d", "adding", 2, 2, 4) will produce "adding 2 and 2 yields 4".

Examples:
exampleCustomImplicitAuxiliaryDynamics.cpp.

◆ make_printable()

template<typename T >
make_printable_return<T>::type OpenSim::make_printable ( const T &  x)
inline

Convert to types that can be printed with sprintf() (vsnprintf()).

The generic template does not alter the type.

◆ printMessage()

template<typename... Types>
void OpenSim::printMessage ( const std::string &  formatString,
Types...  args 
)

Print a formatted string to std::cout.

A newline is not included, but the stream is flushed.