Strings

Functions having to do with string massaging/manipulation. More...

Files

file  demangle.h
 Demangle C++ typenames generated by the typeid() facility.
 
file  vsnprintf.h
 Architecture dependent memory-safe sprintf capability.
 

Functions

ARCH_API bool ArchDemangle (std::string *typeName)
 Demangle RTTI-generated type name. More...
 
ARCH_API std::string ArchGetDemangled (const std::string &typeName)
 Return demangled RTTI-generated type name. More...
 
ARCH_API std::string ArchGetDemangled (const char *typeName)
 Return demangled RTTI-generated type name. More...
 
std::string ArchGetDemangled (const std::type_info &typeInfo)
 Return demangled RTTI-generated type name. More...
 
std::string ArchGetDemangled (const std::type_index &typeIndex)
 Return demangled RTTI-generated type name. More...
 
template<typename T >
std::string ArchGetDemangled ()
 Return demangled RTTI generated-type name. More...
 
ARCH_API int ArchVsnprintf (char *str, size_t size, const char *format, va_list ap)
 Return the number of characters (not including the null character) necessary for a particular sprintf into a string. More...
 
ARCH_API std::string ArchStringPrintf (const char *fmt,...)
 Returns a string formed by a printf()-like specification. More...
 

Detailed Description

Functions having to do with string massaging/manipulation.

Function Documentation

◆ ArchDemangle()

ARCH_API bool ArchDemangle ( std::string *  typeName)

Demangle RTTI-generated type name.

Given a variable v, the construct typeid(v).name() returns the type-name of v; unfortunately, the returned type-name is sometimes extremely encoded (otherwise known as "mangled"). ArchDemangle parses the passed in type-name typeName into a readable form, and overwrites typeName. If typeName cannot be unmangled, the function returns false without altering typeName. Otherwise true is returned.

◆ ArchGetDemangled() [1/5]

ARCH_API std::string ArchGetDemangled ( const std::string &  typeName)

Return demangled RTTI-generated type name.

If typeName can be demangled, the function returns the demangled string; otherwise, the function returns the empty string.

See also
ArchDemangle()

◆ ArchGetDemangled() [2/5]

ARCH_API std::string ArchGetDemangled ( const char *  typeName)

Return demangled RTTI-generated type name.

See also
ArchDemangle() This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ArchGetDemangled() [3/5]

std::string ArchGetDemangled ( const std::type_info &  typeInfo)
inline

Return demangled RTTI-generated type name.

Returns the demangled name associated with typeInfo (i.e. typeInfo.name()).

See also
ArchDemangle() This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 80 of file demangle.h.

◆ ArchGetDemangled() [4/5]

std::string ArchGetDemangled ( const std::type_index &  typeIndex)
inline

Return demangled RTTI-generated type name.

Returns the demangled name associated with typeIndex (i.e. typeIndex.name()).

See also
ArchDemangle() This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 91 of file demangle.h.

◆ ArchGetDemangled() [5/5]

std::string ArchGetDemangled ( )
inline

Return demangled RTTI generated-type name.

Returns the demangled name of type T.

See also
ArchDemangle() This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 103 of file demangle.h.

◆ ArchStringPrintf()

ARCH_API std::string ArchStringPrintf ( const char *  fmt,
  ... 
)

Returns a string formed by a printf()-like specification.

ArchStringPrintf() is a memory-safe architecture-independent way of forming a string using printf()-like formatting. For example,

string formatMsg(const string& caller, int i, double val[])
{
return ArchStringPrintf("%s: val[%d] = %g\n", caller.c_str(), i, val[i]);
}

The function is safe only to the extent that the arguments match the formatting string. In particular, be careful to pass strings themselve into ArchStringPrintf() as in the above example (i.e. caller.c_str() as opposed to just passing caller).

◆ ArchVsnprintf()

ARCH_API int ArchVsnprintf ( char *  str,
size_t  size,
const char *  format,
va_list  ap 
)

Return the number of characters (not including the null character) necessary for a particular sprintf into a string.

ArchVsnprintf guarantees the C99 behavior of vsnprintf on all systems: it returns the number of bytes (not including the terminating null character) needed to actually print the requested string. If size indicates that str has enough capacity to hold the result, then the function actually prints into str.

You probably want to use the functionality of this call via TfStringPrintf().