Simbody  3.7


Namespace-scope utility method SimTK::writeFormatted<T>() writes a value of type T to an output stream in a mildly formatted way depending on the type of container represented by T. More...

Functions

template<class T >
void SimTK::writeFormatted (std::ostream &o, const T &v)
 The default implementation of writeFormatted<T> converts the object to a String using the templatized String constructor, and then writes that string to the stream using String::operator<<(). More...
 

Detailed Description


Namespace-scope utility method SimTK::writeFormatted<T>() writes a value of type T to an output stream in a mildly formatted way depending on the type of container represented by T.

For the basic types this is the same as what you get from the templatized String<T>() constructor when given a value of type T. For containers like Array_ or Vector_, this method is specialized as part of the definition of that container. Usually the containers will surround their contents with some kind of brackets, and separate elements by commas.

Anything written by writeFormatted() can be read back in with readFormatted().

Function Documentation

◆ writeFormatted()

template<class T >
void SimTK::writeFormatted ( std::ostream &  o,
const T &  v 
)
inline

The default implementation of writeFormatted<T> converts the object to a String using the templatized String constructor, and then writes that string to the stream using String::operator<<().

This is suitable for use with any of the built-in and scalar SimTK types. Note that bool will be output "true" or "false" and non-finite floating point values are written as NaN, Inf, or -Inf as appropriate. Complex numbers will serialize as (real,imag).