ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
boxing_debug.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_boxing of the \aliblong.
4///
5/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8#if ALIB_DEBUG_BOXING
9
10ALIB_EXPORT namespace alib::boxing {
11
12//==================================================================================================
13/// This namespace provides low- and high-level debug function for \alib_boxing_nl.<br>
14///
15/// To shorten custom type names, custom namespaces might be added to vector
16/// #"debug::RemovableNamespaces" before invoking a function.
17///
18/// \note
19/// Some of the functions are named with a non-capital letter which in \alib-types usually
20// indicates that they are \c protected or \c private.
21// These functions are "inner" functions used by the similar named capitalized functions.
22/// Their use is recommended, when writing custom "composite" debug-functions, as the various
23/// output parameters might be reused with subsequent invocations.
24///
25/// \par Availability
26/// This namespace is only available if the configuration macro #"ALIB_DEBUG_BOXING" is set.
27///
28/// \par
29/// The following functions are available independent of the \alibbuild.
30/// - #"GetKnownVTables"
31/// - #"GetKnownFunctionTypes"
32/// - #"GetSpecificFunctionTypes(const Box&)"
33/// - #"GetSpecificFunctionTypes(const detail::VTable*)"
34/// - #"getFunctionTypes"
35/// \par
36/// The following functions become available if module \alib_strings is included in the \alibbuild:
37/// - #"TypeName(const Box&)",
38/// - #"TypeName(const detail::VTable*)", and
39/// - #"RemoveNamespaces".
40///
41/// \par
42/// All other functions become available if the module \alib_format is included in the \alibbuild.
43/// If in addition configuration macro #"ALIB_DEBUG_CONTAINERS" is given, then a final function becomes
44/// available:
45/// - #"DumpCustomFunctionHashMapMetrics"
46
47/// \see
48/// Chapter #"alib_boxing_more_debug" of the
49/// #"alib_mod_boxing;Programmer's Manual" of module \alib_boxing_nl.
50//==================================================================================================
51namespace debug {
52
53/// Registers a virtual table for debug purposes.
54/// This function is invoked internally, when a dynamic \e vtable is created and
55/// when a static \e vtable is registered.
56///
57/// Statically created \e vtables have to be registered during bootstrap in debug-compilations.
58/// For this, macro #"ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER" is available, which is empty
59/// in release compilations.
60///
61/// \see
62/// Macros ALIB_BOXING_VTABLE_DECLARE and #"alib_mod_boxing;Programmer's Manual" chapter
63/// #"alib_boxing_more_opt_staticvt".
64///
65/// @param vtable The vtable to register.
66/// @param productionType Denotes whether the \p{vtable} is a static constexpr object or
67/// dynamically created from template type #"%VTableUnoptimized".
69void DbgRegisterVTable( detail::VTable* vtable, detail::VTable::DbgFactoryType productionType );
70
71/// Returns all \e vtable singletons that have been created during program execution so far.
72/// One \e vtable is created for each mapped type used.
73///
74/// \see
75/// The result can be conveniently passed to #"DumpVTables".
76/// @return A vector of pointers to objects of type #"detail::VTable".
78std::vector<detail::VTable*>
80
81/// Returns a vector of \c std::type_info objects, representing all function types that either
82/// a default or a type specific implementation has been registered for.<br>
83/// A second value in the vector provides the number of invocations of a default implementation.
84/// If such is not available, this number is set to <c>std::numeric_limits<uinteger>::max()</c>.
85///
86/// The list includes the built-in function types.
87///
88/// \see
89/// The result can be conveniently passed to #"DumpFunctions".
90/// @return A vector of pairs of type information structs and usage numbers.
92std::vector<std::pair<const std::type_info*,uinteger>>
94
95/// Collects all function declarator types of the given box-function table.
96///
97/// \see
98/// The result can be conveniently passed to #"DumpFunctions".
99///
100/// @param input The function table to use.
101/// @param output The result vector to fill.
103void getFunctionTypes( const detail::FunctionTable& input,
104 std::vector<std::pair<const std::type_info*,uinteger>>& output );
105
106/// Collects all function declarator types, with type-specific implementations.
107/// Parameter \p{vtable} might, for example, be retrieved from a box instance with
108/// #"Box::DbgGetVTable".
109///
110/// Note that the result can be conveniently passed to #".DumpFunctions".
111/// \see Overloaded version #"GetSpecificFunctionTypes(const Box&)" which accepts a "sample Box".
112///
113///
114/// @param vtable The vtable to get all function implementations for.
115/// @return A vector of type information structs.
116inline
117std::vector<std::pair<const std::type_info*,uinteger>>
119 std::vector<std::pair<const std::type_info*,uinteger>> result;
120 getFunctionTypes( vtable->Functions, result );
121 return result;
122}
123
124/// Convenience function: invokes #".GetSpecificFunctionTypes(const detail::VTable*)" with
125/// the \e vtable of the box created or passed with the invocation.
126///
127/// \see
128/// The result can be conveniently passed to #".DumpFunctions".
129///
130/// @param box A box that the vtable is used of.
131/// @return A vector of type information structs.
132inline
133std::vector<std::pair<const std::type_info*,uinteger>>
136
137#if ALIB_STRINGS
138/// Implementation of #".TypeName(const detail::VTable*)".
139/// \par Availability
140/// This function is included only if module \alib_strings is included in the \alibbuild.
141///
142/// @param vtable The vtable.
143/// @param[out] result The target string to write the type information to.
144ALIB_DLL void typeName( const detail::VTable* vtable, AString& result );
145
146/// Writes the (demangled) mapped type that the given \p{vtable} represents.
147///
148/// \par Availability
149/// This function is included only if module \alib_strings is included in the \alibbuild.
150///
151/// @param vtable The \e vtable to get the mapped type name for.
152/// @return A string containing the requested information.
153inline AString TypeName ( const detail::VTable* vtable ) {
154 AString result;
155 typeName( vtable, result );
156 return result;
157}
158
159/// Convenience function: invokes #".TypeName(const detail::VTable*)" with
160/// the \e vtable of the box created or passed with the invocation.
161///
162/// \par Availability
163/// This function is included only if module \alib_strings is included in the \alibbuild.
164///
165/// @param box The box to get the mapped type name for.
166/// @return A string containing the requested information.
167inline AString TypeName( const Box& box ) {
168 AString result;
169 typeName( box.DbgGetVTable(), result );
170 return result;
171}
172
173/// Removes namespaces in the given \p{string}. The function is used with all debug-functions that
174/// create string values containing type names.
175/// Note that custom namespaces might be added to namespace variable
176/// #"debug::RemovableNamespaces" before invoking any function.
177///
178/// @param string The string to remove the namespace from.
179/// @param startIndex The index within the string to start searching for removable namespaces.
180/// @return A string containing the requested information.
181ALIB_DLL AString& RemoveNamespaces( AString& string, integer startIndex );
182
183/// See function #".RemoveNamespaces". Pre-initialized with <b>"alib::"</b>.
184ALIB_DLL extern std::vector<String> RemovableNamespaces;
185
186#endif // ALIB_STRINGS
187
188}} // namespace [alib::boxing::debug]
189
190#endif // ALIB_DEBUG_BOXING
#define ALIB_DLL
#define ALIB_EXPORT
const detail::VTable * DbgGetVTable() const
Definition box.hpp:379
std::vector< std::pair< const std::type_info *, uinteger > > GetKnownFunctionTypes()
Definition vtable.cpp:136
std::vector< alib::String > RemovableNamespaces
See function #".RemoveNamespaces". Pre-initialized with "alib::".
std::vector< detail::VTable * > GetKnownVTables()
Definition vtable.cpp:112
void DbgRegisterVTable(detail::VTable *vtable, detail::VTable::DbgFactoryType productionType)
AString & RemoveNamespaces(AString &string, integer startIndex)
void getFunctionTypes(const detail::FunctionTable &input, std::vector< std::pair< const std::type_info *, uinteger > > &output)
Definition vtable.cpp:167
std::vector< std::pair< const std::type_info *, uinteger > > GetSpecificFunctionTypes(const detail::VTable *vtable)
AString TypeName(const detail::VTable *vtable)
void typeName(const detail::VTable *vtable, AString &result)
DOXYGEN.
Definition box.cpp:17
lang::integer integer
Type alias in namespace #"%alib".
Definition integers.hpp:149
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
The custom function hash.
Definition vtable.hpp:226
FunctionTable Functions
Box-functions attached with #"BootstrapRegister".
Definition vtable.hpp:257