ALib C++ Library
Library Version: 2511 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 #endif
60
61 /// Writes hash tables stored in a ScopeStore. Keys are Strings.
62 /// Value types currently supported are LogData* and int.
63 /// @param store The store to use.
64 /// @return The total number of hash table entries written.
65 template<typename T>
68
69
70 /// Writes the contents of the ScopeStore used for <em>Scope Domains</em>.
71 /// @param store The store to use
72 /// @param indentSpaces The number of spaces to add at the beginning of each line.
73 /// @return The total number of <em>Scope Domains</em> written.
74 template<typename T>
76 int writeStore( ScopeStore<T, true>* store, int indentSpaces );
77
78 //################################################################################################
79 // Internals
80 //################################################################################################
81 protected:
82 /// Helper method to #writeStoreMap.
83 /// @param map The map to use
84 /// @param prefix A prefix string for each line
85 /// @return The number of objects written
86 template<typename T>
89
90 #if !ALIB_SINGLE_THREADED
91 /// Helper method to write thread information.
92 /// @param threadID The thread id.
93 /// @return The target to allow concatenated calls.
96 #endif
97
98 /// Helper method to write a StringTree's key as scope information.
99 /// @param key The key used for the \b %StringTree.
100 /// @return The target to allow concatenated calls.
103
104}; // ScopeDump
105
106
107//! @cond NO_DOX
108// needed to suppress pedantic warnings with clang
109extern template int ScopeDump::writeStore ( ScopeStore<NString , true >* store, int indentSpaces );
110extern template int ScopeDump::writeStore ( ScopeStore<PrefixLogable* , true >* store, int indentSpaces );
111extern template int ScopeDump::writeStoreMap( ScopeStore<SSMap<int>* , false>* store );
112extern template int ScopeDump::writeStoreMap( ScopeStore<SSMap<Box>* , false>* store );
113//! @endcond
114
115
116}}} // namespace [alib::lox::detail]
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:503
#define IF_ALIB_THREADS(...)
Definition alib.inl:401
#define ALIB_EXPORT
Definition alib.inl:497
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:390
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2198
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189