ALib C++ Library
Library Version: 2510 R0
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-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace lox { namespace detail {
9
10//==================================================================================================
11/// This class is an internal helper to export current scope values.
12/// It was extracted from class \b %Lox to keep that class clean from this somehow 'cluttered' code.
13///
14/// The current purpose of this class is to write information into an AString buffer. This is used
15/// by method \ref alib::lox::Lox::State "Lox::State". In the future, other export formats,
16/// like JSON might be implemented here.
17///
18/// \note As this is a pure internal helper-class. Documentation may be limited.
19//==================================================================================================
21{
22 protected:
23 /// The target to write to.
25
26 /// String to identify global keys.
28
29 /// The maximum length of a key. Adjusts (increases) over life-cycle.
31
32 #if !ALIB_SINGLE_THREADED
33 /// User-defined threads names.
35 #endif
36
37 public:
38
39 #if DOXYGEN
40 /// Constructor
41 /// @param threadDictionary User-defined threads names.
42 /// @param target Target string to write to.
43 /// @param noKeyHashKey String to identify global keys.
44 /// @param maxKeyLength The start value for the maximum length of a key.
45 ScopeDump( ScopeInfo::ThreadDictionary& threadDictionary, const NString noKeyHashKey,
46 NAString& target, int maxKeyLength= 10 )
47 : targetBuffer(target)
48 , noKey(noKeyHashKey)
49 , maximumKeyLength(maxKeyLength)
50 , threadDict(threadDictionary)
51 {}
52 #else
54 const NString noKeyHashKey, NAString& target, int maxKeyLength= 10 )
55 : targetBuffer(target)
56 , noKey(noKeyHashKey)
57 , maximumKeyLength(maxKeyLength)
58 IF_ALIB_THREADS(, threadDict(threadDictionary) )
59 {}
60 #endif
61
62 /// Writes hash tables stored in a ScopeStore. Keys are Strings.
63 /// Value types currently supported are LogData* and int.
64 /// @param store The store to use.
65 /// @return The total number of hash table entries written.
66 template<typename T>
69
70
71 /// Writes the contents of the ScopeStore used for <em>Scope Domains</em>.
72 /// @param store The store to use
73 /// @param indentSpaces The number of spaces to add at the beginning of each line.
74 /// @return The total number of <em>Scope Domains</em> written.
75 template<typename T>
77 int writeStore( ScopeStore<T, true>* store, int indentSpaces );
78
79 // #############################################################################################
80 // Internals
81 // #############################################################################################
82 protected:
83 /// Helper method to #writeStoreMap.
84 /// @param map The map to use
85 /// @param prefix A prefix string for each line
86 /// @return The number of objects written
87 template<typename T>
90
91 #if !ALIB_SINGLE_THREADED
92 /// Helper method to write thread information.
93 /// @param threadID The thread id.
94 /// @return The target to allow concatenated calls.
97 #endif
98
99 /// Helper method to write a StringTree's key as scope information.
100 /// @param key The key used for the \b %StringTree.
101 /// @return The target to allow concatenated calls.
104
105}; // ScopeDump
106
107
108//! @cond NO_DOX
109// needed to suppress pedantic warnings with clang
110extern template int ScopeDump::writeStore ( ScopeStore<NString , true >* store, int indentSpaces );
111extern template int ScopeDump::writeStore ( ScopeStore<PrefixLogable* , true >* store, int indentSpaces );
112extern template int ScopeDump::writeStoreMap( ScopeStore<SSMap<int>* , false>* store );
113extern template int ScopeDump::writeStoreMap( ScopeStore<SSMap<Box>* , false>* store );
114//! @endcond
115
116
117}}} // namespace [alib::lox::detail]
118
ALIB_DLL NAString & storeThreadToScope(ThreadID threadID)
ALIB_DLL NAString & storeKeyToScope(String key)
NAString & targetBuffer
The target to write to.
Definition scopedump.inl:24
ALIB_DLL int writeStore(ScopeStore< T, true > *store, int indentSpaces)
ScopeDump(ScopeInfo::ThreadDictionary &threadDictionary, const NString noKeyHashKey, NAString &target, int maxKeyLength=10)
Definition scopedump.inl:45
ScopeInfo::ThreadDictionary & threadDict
User-defined threads names.
Definition scopedump.inl:34
ALIB_DLL integer writeStoreMapHelper(SSMap< T > &map, const NString &prefix)
ALIB_DLL int writeStoreMap(ScopeStore< T, false > *store)
const NString noKey
String to identify global keys.
Definition scopedump.inl:27
integer maximumKeyLength
The maximum length of a key. Adjusts (increases) over life-cycle.
Definition scopedump.inl:30
HashMap< MonoAllocator, threads::ThreadID, String32 > ThreadDictionary
A map we use to translate thread IDs to thread names.
Definition scopeinfo.inl:32
#define ALIB_DLL
Definition alib.inl:496
#define IF_ALIB_THREADS(...)
Definition alib.inl:401
#define ALIB_EXPORT
Definition alib.inl:488
HashMap< PoolAllocator, NString, T, std::hash< NString >, std::equal_to< NString >, lang::Caching::Enabled, Recycling::None > SSMap
Shortcut to the ScopeStore's hashmap.
threads::ThreadID ThreadID
Type to store thread identifiers.
Definition thread.inl:392
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2390
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2381