Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Some implementation helpers for simple object display.
This file provides some basic implementation functions, which can be called from a generic front-end (header). The reason we stash away some functions into an implementation unit is to keep the include overhead low, which helps to reduce both code size and compilation time. The functions here perform some formatting tasks commonly used from debugging and diagnostics code, both to investigate object contents and show types and addresses. They are referred from our [lightweight string converter](util::StringConv), but also from the util::toString() function and more common formatting utils.
Definition in file format-obj.cpp.
#include "lib/error.hpp"
#include "lib/format-obj.hpp"
#include "lib/ios-savepoint.hpp"
#include "lib/unique-malloc-owner.hpp"
#include "lib/symbol.hpp"
#include "lib/util.hpp"
#include <limits>
#include <iomanip>
#include <sstream>
#include <string>
#include <regex>
Macros | |
#define | TYP_EXP "[\\w<>\\(\\):,\\s]+" |
Functions | |
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 | |
string | sanitisedSymbol (std::string const &) |
condense a string and retain only valid identifiers More... | |
ostream & | showAdr (std::ostream &, void const *addr) |
preconfigured format for pretty-printing of addresses More... | |
string | showAdr (void const *addr) noexcept |
pretty-print an address as hex-suffix | |
string | showComplete (double) noexcept |
show enough decimal digits to represent every distinct value | |
string | showComplete (float val) noexcept |
string | showComplete (f128 val) noexcept |
string | showDecimal (double) noexcept |
show maximum reproducible decimal representation | |
string | showDecimal (float val) noexcept |
string | showDecimal (f128 val) noexcept |
string | showDouble (double) noexcept |
pretty-print a double in (rounded) fixed-point format More... | |
string | showFloat (float val) noexcept |
template<typename F > | |
string | showFloatingPoint (F val, size_t precision) noexcept |
string | showHash (size_t hash, uint showBytes=8) noexcept |
renders the size_t in hex, optionally only trailing bytes | |
string | showSize (size_t val) noexcept |
Variables | |
const string | BOOL_FALSE_STR = "false" |
const string | BOOL_TRUE_STR = "true" |
const string | BOTTOM_INDICATOR = "⟂" |
const size_t | DIAGNOSTICS_ADDRESS_SUFFIX_LEN = 4 |
show only this amount of trailing bytes from an address | |
const auto | DIAGNOSTICS_DOUBLE_PRECISION = 8 |
const auto | DIAGNOSTICS_FLOAT_PRECISION = 5 |
const string | FAILURE_INDICATOR = "↯" |
const string | FUNCTION_INDICATOR = "Function" |
template<typename F > | |
constexpr size_t | PRECISION_COMPLETE = std::numeric_limits<F>::max_digits10 |
decimal digits require tod represent each different floating-point value | |
template<typename F > | |
constexpr size_t | PRECISION_DECIMAL = std::numeric_limits<F>::digits10 |
maximum decimal digits able to pass through a round trip without value change | |
const string | VOID_INDICATOR = "void" |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
std::string demangleCxx | ( | Literal | rawName | ) |
Fallback type-ID:
reverse the effect of C++ name mangling.
Definition at line 159 of file format-obj.cpp.
References lib::meta::demangleCxx().
Referenced by lib::meta::demangleCxx(), lib::meta::humanReadableTypeID(), and lib::meta::primaryTypeComponent().
std::string humanReadableTypeID | ( | Literal | rawType | ) |
pretty-print an internal C++ type representation
const
, &
or *
, however, the typical usage from within util::typeStr() is arranged in a way to absorb these adornments by the way the template signatures are definedstd::regex_replace
Definition at line 190 of file format-obj.cpp.
References lib::meta::demangleCxx(), and lib::meta::humanReadableTypeID().
Referenced by lib::meta::humanReadableTypeID(), and lib::meta::sanitisedFullTypeName().
std::string primaryTypeComponent | ( | Literal | rawType | ) |
extract core name component from a raw type spec
::
Definition at line 268 of file format-obj.cpp.
References lib::meta::demangleCxx(), lib::meta::primaryTypeComponent(), and lib::meta::typeStr().
Referenced by lib::meta::primaryTypeComponent().
std::string sanitisedSymbol | ( | std::string const & | ) |
condense a string and retain only valid identifiers
Definition at line 313 of file format-obj.cpp.
References lib::meta::sanitisedSymbol().
Referenced by lib::meta::sanitisedSymbol().
|
noexcept |
pretty-print a double in (rounded) fixed-point format
0.1
(which can not be represented as binary floats) Definition at line 360 of file format-obj.cpp.
References util::showDouble().
Referenced by util::showDouble().
std::ostream & showAdr | ( | ostream & | stream, |
void const * | addr | ||
) |
preconfigured format for pretty-printing of addresses
Definition at line 385 of file format-obj.cpp.
References util::showAdr().
Referenced by util::showAdr().