ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
dbgtypedemangler.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2025 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
7#include "alib_precompile.hpp"
8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
10#endif
11#if ALIB_C20_MODULES
12 module;
13#endif
14// ====================================== Global Fragment ======================================
15#include "alib/alib.inl"
16#if ALIB_DEBUG && !DOXYGEN
17# if defined(__GNUC__) || defined(__clang__)
18# include <cxxabi.h>
19# include <cassert>
20# endif
21# include <cstdlib>
22# if defined(_WIN32)
23# include <cstring>
24# endif
25#endif
26// =========================================== Module ==========================================
27#if ALIB_C20_MODULES
28 module ALib.Lang;
29#else
30# include "ALib.Lang.H"
31#endif
32// ====================================== Implementation =======================================
33
34// #################################################################################################
35// Type De-mangling
36// #################################################################################################
37#if ALIB_DEBUG && !DOXYGEN
38namespace alib::lang {
39
40 #if defined(__GNUC__) || defined(__clang__)
41 DbgTypeDemangler::DbgTypeDemangler( const std::type_info& typeInfo )
42 {
43 int status;
44 name= abi::__cxa_demangle( typeInfo.name(), nullptr, nullptr, &status);
45 assert( status==0 || !name );
46 if ((failed= (name==nullptr)))
47 name= "<DbgTypeDemangler Error>";
48 }
49
51 { if (!failed) std::free(static_cast<void*>( const_cast<char*>(name) ) ); }
52
53 #else
54 lang::DbgTypeDemangler::DbgTypeDemangler( const type_info& typeInfo )
55 {
56 name= typeInfo.name();
57 if (std::strncmp( name, "class ", 6) == 0)
58 name+= 6;
59 }
60 #endif
61
62 const char* DbgTypeDemangler::Get() { return name; }
63
64} // namespace [alib::lang}
65
66#endif // ALIB_DEBUG && !DOXYGEN
ALIB_DLL ~DbgTypeDemangler()
Destructor.
ALIB_DLL const char * Get()
ALIB_DLL DbgTypeDemangler(const std::type_info &typeInfo)
bool failed
If true, demangling failed.
const char * name
The translated name.
void typeInfo(AString &target, const detail::VTable *vtable, const String &indent, bool srcIsPointer, bool srcIsStringType, bool srcIsUnboxableStringType, bool isValueTypeCustomized, bool isPointerTypeCustomized, bool fitsToPlaceholder, bool copyConstructible, bool triviallyDestructible, bool isUnboxable)