ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
scopedump.hpp
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/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_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 #"%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 #"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//==================================================================================================
20class ScopeDump {
21 protected:
22 /// The target to write to.
24
25 /// String to identify global keys.
27
28 /// The maximum length of a key. Adjusts (increases) over life-cycle.
30
31 #if !ALIB_SINGLE_THREADED
32 /// User-defined threads names.
34 #endif
35
36 public:
37
38 #if DOXYGEN
39 /// Constructor
40 /// @param threadDictionary User-defined threads names.
41 /// @param target Target string to write to.
42 /// @param noKeyHashKey String to identify global keys.
43 /// @param maxKeyLength The start value for the maximum length of a key.
44 ScopeDump( ScopeInfo::ThreadDictionary& threadDictionary, const NString noKeyHashKey,
45 NAString& target, int maxKeyLength= 10 )
46 : targetBuffer(target)
47 , noKey(noKeyHashKey)
48 , maximumKeyLength(maxKeyLength)
49 , threadDict(threadDictionary)
50 {}
51 #else
53 const NString noKeyHashKey, NAString& target, int maxKeyLength= 10 )
54 : targetBuffer(target)
55 , noKey(noKeyHashKey)
56 , maximumKeyLength(maxKeyLength)
57 IF_ALIB_THREADS(, threadDict(threadDictionary) ) {}
58 #endif
59
60 /// Writes hash tables stored in a ScopeStore. Keys are Strings.
61 /// Value types currently supported are LogData* and int.
62 /// @param store The store to use.
63 /// @return The total number of hash table entries written.
64 template<typename T>
67
68
69 /// Writes the contents of the ScopeStore used for <em>Scope Domains</em>.
70 /// @param store The store to use
71 /// @param indentSpaces The number of spaces to add at the beginning of each line.
72 /// @return The total number of <em>Scope Domains</em> written.
73 template<typename T>
75 int writeStore( ScopeStore<T, true>* store, int indentSpaces );
76
77 //################################################################################################
78 // Internals
79 //################################################################################################
80 protected:
81 /// Helper method to #"writeStoreMap".
82 /// @param map The map to use
83 /// @param prefix A prefix string for each line
84 /// @return The number of objects written
85 template<typename T>
88
89 #if !ALIB_SINGLE_THREADED
90 /// Helper method to write thread information.
91 /// @param threadID The thread id.
92 /// @return The target to allow concatenated calls.
95 #endif
96
97 /// Helper method to write a StringTree's key as scope information.
98 /// @param key The key used for the #"%StringTree".
99 /// @return The target to allow concatenated calls.
102
103}; // ScopeDump
104
105
106//! @cond NO_DOX
107// needed to suppress pedantic warnings with clang
108extern template int ScopeDump::writeStore ( ScopeStore<NString , true >* store, int indentSpaces );
109extern template int ScopeDump::writeStore ( ScopeStore<PrefixLogable* , true >* store, int indentSpaces );
110extern template int ScopeDump::writeStoreMap( ScopeStore<SSMap<int>* , false>* store );
111extern template int ScopeDump::writeStoreMap( ScopeStore<SSMap<Box>* , false>* store );
112//! @endcond
113
114
115}}} // namespace [alib::lox::detail]
#define ALIB_DLL
#define IF_ALIB_THREADS(...)
#define ALIB_EXPORT
integer writeStoreMapHelper(SSMap< T > &map, const NString &prefix)
NAString & targetBuffer
The target to write to.
Definition scopedump.hpp:23
NAString & storeKeyToScope(String key)
ScopeDump(ScopeInfo::ThreadDictionary &threadDictionary, const NString noKeyHashKey, NAString &target, int maxKeyLength=10)
Definition scopedump.hpp:44
ScopeInfo::ThreadDictionary & threadDict
User-defined threads names.
Definition scopedump.hpp:33
NAString & storeThreadToScope(ThreadID threadID)
const NString noKey
String to identify global keys.
Definition scopedump.hpp:26
integer maximumKeyLength
The maximum length of a key. Adjusts (increases) over life-cycle.
Definition scopedump.hpp:29
int writeStore(ScopeStore< T, true > *store, int indentSpaces)
int writeStoreMap(ScopeStore< T, false > *store)
HashMap< MonoAllocator, threads::ThreadID, String32 > ThreadDictionary
A map we use to translate thread IDs to thread names.
Definition scopeinfo.hpp:31
HashMap< PoolAllocator, NString, T, std::hash< NString >, std::equal_to< NString >, lang::Caching::Enabled, Recycling::None > SSMap
Shortcut to the ScopeStore's hashmap.
Definition alox.cpp:14
threads::ThreadID ThreadID
Type to store thread identifiers.
Definition thread.hpp:390
strings::TString< nchar > NString
Type alias in namespace #"%alib".
Definition string.hpp:2174
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
Definition integers.hpp:149
strings::TString< character > String
Type alias in namespace #"%alib".
Definition string.hpp:2165