Simbody
3.7
|
Obtain human-readable and XML-usable names for arbitrarily-complicated C++ types. More...
Static Public Member Functions | |
static const char * | name () |
The default implementation of name() here returns the raw result from `typeid(T). More... | |
static const std::string & | namestr () |
The default implementation of namestr() attempts to return a nicely demangled and canonicalized type name on all platforms, using the SimTK::demangle() and SimTK::canonicalizeTypeName() methods. More... | |
static const std::string & | xmlstr () |
The default implementation of xmlstr() takes the output of namestr() and invokes SimTK::encodeTypeNameForXML() on it. More... | |
Related Functions | |
(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... | |
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>.
The output of namestr()
is typically used for error messages and testing; xmlstr()
is used for type tags in XML for use in deserializing.
|
inlinestatic |
The default implementation of name() here returns the raw result from `typeid(T).
name()` which will be fast but may be a mangled name in some compilers (gcc and clang included).
|
inlinestatic |
The default implementation of namestr() attempts to return a nicely demangled and canonicalized type name on all platforms, using the SimTK::demangle() and SimTK::canonicalizeTypeName() methods.
This is an expensive operation but is only done once.
|
inlinestatic |
|
related |
Attempt to demangle a type name as returned by typeid.name(), with the result hopefully suitable for meaningful display to a human.
Behavior is compiler-dependent.
|
related |
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.
Unnecessary spaces and superfluous keywords like "class" and "struct" are removed. The namestr()
method of NiceTypeName<T> uses this function to produce a human-friendly type name that is the same on any platform. The input argument is left empty.
|
related |
Same, but takes an lvalue reference so has to copy the input.
|
related |
Given a canonicalized type name, produce a modified version that is better-suited to use as an XML attribute.
This means replacing the angle brackets with curly braces to avoid trouble. The input argument is left empty.
|
related |
Same, but takes an lvalue reference so has to copy the input.
|
related |
Given a type name that was encoded for XML by SimTK::encodeTypeNameForXML(), restore it to its canonicalized form.
This means replacing curly braces by angle brackets. The input argument is left empty.
|
related |
Same, but takes an lvalue reference so has to copy the input.