Obtain human-readable and XML-usable names for arbitrarily-complicated C++ types.
More...
|
(Note that these are not member functions.)
|
std::string | demangle (const char *name) |
| Attempt to demangle a type name as returned by typeid.name(), with the result hopefully suitable for meaningful display to a human. More...
|
|
std::string | canonicalizeTypeName (std::string &&demangledTypeName) |
| Given a compiler-dependent demangled type name string as returned by SimTK::demangle(), attempt to form a canonicalized representation that will be the same for any compiler. More...
|
|
std::string | canonicalizeTypeName (const std::string &demangledTypeName) |
| Same, but takes an lvalue reference so has to copy the input. More...
|
|
std::string | encodeTypeNameForXML (std::string &&canonicalizedTypeName) |
| Given a canonicalized type name, produce a modified version that is better-suited to use as an XML attribute. More...
|
|
std::string | encodeTypeNameForXML (const std::string &niceTypeName) |
| Same, but takes an lvalue reference so has to copy the input. More...
|
|
std::string | decodeXMLTypeName (std::string &&xmlTypeName) |
| Given a type name that was encoded for XML by SimTK::encodeTypeNameForXML(), restore it to its canonicalized form. More...
|
|
std::string | decodeXMLTypeName (const std::string &xmlTypeName) |
| Same, but takes an lvalue reference so has to copy the input. More...
|
|
template<class T>
struct SimTK::NiceTypeName< T >
Obtain human-readable and XML-usable names for arbitrarily-complicated C++ types.
Three methods name()
, namestr()
, and xmlstr()
are provided giving respectively the compiler-dependent output from typeid(T).name()
, a canonicalized human-readable string, and the canonicalized string with XML-forbidden angle brackets replaced by curly braces. The default implementation is usable for most types, but if you don't like the result you can specialize to provide nicer names. For example, you may prefer SimTK::Vec3 to SimTK::Vec<3,double,1>.
- Warning
- Don't expect usable names for types that are defined in an anonymous namespace or for function-local types. Names will still be produced but they won't be unique and won't necessarily be compiler-independent.
The output of namestr()
is typically used for error messages and testing; xmlstr()
is used for type tags in XML for use in deserializing.