Lumiera  0.pre.03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
format-obj.hpp File Reference

Go to the source code of this file.


Simple functions to represent objects, for debugging and diagnostics.

The helpers provided here are rather commonplace, but written in a way as to incur only modest header inclusion load. It should be OK to use these even on widely used interface headers.

  • util::toString() performs a failsafe to-String conversion, thereby preferring a built-in conversion operator, falling back to a lexical conversion (boost) or just a unmangled and simplified type string as default.
  • util::typedString() combines this with a always visible type display
  • lib::meta::demangleCxx() uses the built-in compiler support to translate a mangled type-ID (as given by typeid(TY).name()) into a readable, fully qualified C++ type name. This is only supported for GNU compatible compilers.
is it possible to stash away the boost::lexical_cast behind a custom facade, the way we did it for boost::format? This would reduce inclusion cost...
See also
frontend for boost::format, printf-style

Definition in file format-obj.hpp.

#include "lib/symbol.hpp"
#include "lib/meta/trait.hpp"
#include <boost/lexical_cast.hpp>


singleton  basic_ostream< Char >
 STL class.
struct  char_traits< C >
struct  StringConv< bool >
struct  StringConv< double >
 explicit specialisation to control precision of double values. More...
struct  StringConv< float >
struct  StringConv< SP, show_SmartPointer< SP > >
struct  StringConv< X, enable_LexicalConversion< X > >


using ostream = basic_ostream< char, char_traits< char >>


string demangleCxx (Literal rawName)
 Fallback type-ID: More...
string humanReadableTypeID (lib::Literal)
 pretty-print an internal C++ type representation More...
string primaryTypeComponent (lib::Literal)
 extract core name component from a raw type spec More...
string sanitisedFullTypeName (lib::Literal)
 build a sanitised ID from full type name More...
ostream & showAddr (std::ostream &, void const *addr)
 preconfigured format for pretty-printing of addresses More...
string showAddr (void const *addr) noexcept
 pretty-print an address as hex-suffix More...
string showDouble (double) noexcept
 pretty-print a double in fixed-point format More...
string showFloat (float val) noexcept
string showSize (size_t val) noexcept
template<typename TY >
std::string toString (TY const &val) noexcept
 get some string representation of any object, reliably. More...
template<typename TY >
std::string typedString (TY const &val) noexcept
 indicate type and possibly a (custom) conversion to string More...


 Implementation namespace for support and library code.