ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
scopedump.inl
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of module \alib_alox of the \aliblong.
4 *
5 * \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6 * Published under \ref mainpage_license "Boost Software License".
7 **************************************************************************************************/
8#ifndef HPP_ALOX_DETAIL_SCOPEDUMP
9#define HPP_ALOX_DETAIL_SCOPEDUMP 1
10
11#if !defined(HPP_ALIB_LOX_PROPPERINCLUDE)
12# error "ALib sources with ending '.inl' must not be included from outside."
13#endif
14
15#if !defined (HPP_ALIB_ALOX)
16 #include "alib/alox/alox.hpp"
17#endif
18
19
20namespace alib { namespace lox { namespace detail {
21
22/** ************************************************************************************************
23 * This class is an internal helper to export current scope values.
24 * It was extracted from class \b %Lox to keep that class clean from this somehow 'cluttered' code.
25 *
26 * The current purpose of this class is to write information into an AString buffer. This is used
27 * by method \ref alib::lox::Lox::State "Lox::State". In the future, other export formats,
28 * like JSON might be implemented here.
29 *
30 * \note As this is a pure internal helper class. Documentation may be limited.
31 **************************************************************************************************/
33{
34 // #############################################################################################
35 // Protected fields
36 // #############################################################################################
37 protected:
38 /** The target to write to. */
40
41 /** String to identify global keys. */
43
44 /** The maximum length of a key. Adjusts (increases) over life-cycle. */
46
47#if ALIB_THREADS
48 /** User-defined threads names. */
50#endif
51
52 // #############################################################################################
53 // Public interface
54 // #############################################################################################
55 public:
56
57 #if defined(ALIB_DOX)
58 /** ****************************************************************************************
59 * Constructor
60 * @param threadDictionary User-defined threads names.
61 * @param target Target string to write to.
62 * @param noKeyHashKey String to identify global keys.
63 * @param maxKeyLength The start value for the maximum length of a key.
64 ******************************************************************************************/
65 ScopeDump( ScopeInfo::ThreadDictionary& threadDictionary, const NString noKeyHashKey,
66 NAString& target, int maxKeyLength= 10 )
67 : targetBuffer(target)
68 , noKey(noKeyHashKey)
69 , maximumKeyLength(maxKeyLength)
70 , threadDict(threadDictionary)
71 {}
72 #else
74 const NString noKeyHashKey, NAString& target, int maxKeyLength= 10 )
75 : targetBuffer(target)
76 , noKey(noKeyHashKey)
77 , maximumKeyLength(maxKeyLength)
78 ALIB_IF_THREADS(, threadDict(threadDictionary) )
79 {}
80 #endif
81
82 /** ****************************************************************************************
83 * Writes hash tables stored in a ScopeStore. Keys are Strings.
84 * Value types currently supported are LogData* and int.
85 * @param store The store to use.
86 * @return The total number of hash table entries written.
87 ******************************************************************************************/
88 template<typename T>
91
92
93 /** ****************************************************************************************
94 * Writes the contents of the ScopeStore used for <em>Scope Domains</em>.
95 * @param store The store to use
96 * @param indentSpaces The number of spaces to add at the beginning of each line.
97 * @return The total number of <em>Scope Domains</em> written.
98 ******************************************************************************************/
99 template<typename T>
101 int writeStore( ScopeStore<T, true>* store, int indentSpaces );
102
103 // #############################################################################################
104 // Internals
105 // #############################################################################################
106 protected:
107 /** ****************************************************************************************
108 * Helper method to #writeStoreMap.
109 * @param map The map to use
110 * @param prefix A prefix string for each line
111 * @return The number of objects written
112 ******************************************************************************************/
113 template<typename T>
115 integer writeStoreMapHelper( std::map<NString, T>& map, const NString& prefix );
116
117#if ALIB_THREADS
118 /** ****************************************************************************************
119 * Helper method to write thread information.
120 * @param threadID The thread id.
121 * @return The target to allow concatenated calls.
122 ******************************************************************************************/
125#endif
126
127 /** ****************************************************************************************
128 * Helper method to write a StringTree's key as scope information.
129 * @param key The key used for the \b %StringTree.
130 * @return The target to allow concatenated calls.
131 ******************************************************************************************/
134
135}; // ScopeDump
136
137
138//! @cond NO_DOX
139// needed to suppress pedantic warnings with clang
140extern template int ScopeDump::writeStore ( ScopeStore<NString , true >* store, int indentSpaces );
141extern template int ScopeDump::writeStore ( ScopeStore<PrefixLogable* , true >* store, int indentSpaces );
142extern template int ScopeDump::writeStoreMap( ScopeStore<std::map<NString, int>* , false>* store );
143extern template int ScopeDump::writeStoreMap( ScopeStore<std::map<NString, Box>* , false>* store );
144//! @endcond
145
146
147}}} // namespace [alib::lox::detail]
148
149
150
151#endif // HPP_ALOX_DETAIL_SCOPEDUMP
ALIB_API int writeStoreMap(ScopeStore< T, false > *store)
ALIB_API int writeStore(ScopeStore< T, true > *store, int indentSpaces)
ALIB_API NAString & storeKeyToScope(String key)
ALIB_API NAString & storeThreadToScope(ThreadID threadID)
ScopeInfo::ThreadDictionary & threadDict
Definition scopedump.inl:49
ALIB_API integer writeStoreMapHelper(std::map< NString, T > &map, const NString &prefix)
ScopeDump(ScopeInfo::ThreadDictionary &threadDictionary, const NString noKeyHashKey, NAString &target, int maxKeyLength=10)
Definition scopedump.inl:65
#define ALIB_IF_THREADS(...)
Definition alib.hpp:303
#define ALIB_API
Definition alib.hpp:538
Definition alib.cpp:57
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:286
threads::ThreadID ThreadID
Type to store thread identifiers.
Definition thread.hpp:393