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