1 #ifndef __DUNE_ACFEM_COMMON_TYPESTRING_HH__
2 #define __DUNE_ACFEM_COMMON_TYPESTRING_HH__
16 # warning Pretty-printing of class-names will not work, C++ demangler not available.
30 std::string cvString(T&& t)
33 if (std::is_lvalue_reference<T>::value) {
36 if (std::is_rvalue_reference<T>::value) {
39 if (std::is_pointer<T>::value) {
42 if (std::is_const<T>::value) {
49 std::string demangle(T&& t)
52 auto *cname =
typeid(std::forward<T>(t)).name();
54 auto *demangled = abi::__cxa_demangle(cname, 0, 0, &status);
56 auto name = std::string(demangled);
59 name = std::string(
"Don't know how to generate pretty type-names with this compiler.");
69 TypeString(
const std::decay_t<T>* arg =
nullptr,
bool isRValueRef =
false)
74 auto *demangled = abi::__cxa_demangle(
name, 0, 0, &status);
76 std::clog <<
"*** Unable to demangle symbol(" << status <<
")" << std::endl
78 <<
"***" << std::endl;
81 name_ = std::string(demangled);
83 name_ = name_.substr(0, name_.size() - strlen(
" const*"));
84 if (std::is_rvalue_reference<T>::value) {
86 }
else if (std::is_lvalue_reference<T>::value) {
89 if (std::is_const<std::remove_reference_t<T> >::value) {
93 name_ = std::string(
"Don't know how to generate pretty type-names with this compiler.");
97 :
TypeString(&arg, std::is_rvalue_reference<decltype(arg)>::value)
106 std::string
name(
bool postProcess =
true)
const
112 result = std::regex_replace(result, std::regex(
"ACFem::|Dune::|Fem::|Expressions::|MPL::|FunctionExpressions::|GridFunction::|std::|Tensor::|TypedValue::|PDEModel::|ModelInstrospection::|[(]anonymous namespace[)]::|impl::|__[0-9]+::|(>)(,( )void)+(>)|, void"),
"$1$3$4");
115 result = std::regex_replace(result, std::regex(
"([0-9]+)[uU]?[lL]?"),
"$1");
118 result = std::regex_replace(result, std::regex(
"AdaptiveLeafGridPart<(ALUGrid)<([0-9]), ([0-9]), [(]ALUGridElementType[)]0, [(]ALUGridRefinementType[)]0, ALUGridMPIComm>, [(]PartitionIteratorType[)][0-9]+, (false|true)>"),
"$1<$2,$3>");
121 result = std::regex_replace(result,
122 std::regex(
"LagrangeDiscreteFunctionSpace<FunctionSpace<double, double, ([0-9]+), ([0-9]+)>,.+?, ([0-9]+), CachingStorage>"),
123 "LagrangeSpace<$3, <$1,$2> >");
150 auto typeString(
bool stripNameSpaces =
true,
const std::remove_reference_t<T>* arg =
nullptr)
152 return TypeString<T>{}.name(stripNameSpaces);
A class constructing the name of another type.
Definition: typestring.hh:67
std::string name(bool postProcess=true) const
If implemented for the current compiler return the name of the given type.
Definition: typestring.hh:106
auto typeString(T &&t, bool stripNameSpaces=true)
Generator for TypeString.
Definition: typestring.hh:144