ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
fmtcallerinfo.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the module \alib_format of the \aliblong.
4///
5/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace format {
9
10/// This struct is used to format caller information provided with the type #"CallerInfo".
11///
12/// Besides using method #".Format" "manually", instances of type #"%CallerInfo" may be passed as
13/// arguments to type #"FormatterPythonStyle" using the according placeholder
14/// syntax.
15/// If done, internally an instance of this type is created and its #".Format" method called.
16///
17/// \note
18/// This is achieved by boxed function #"FFormat_CallerInfo", as
19/// explained in chapter #"alib_format_custom_types" of the Programmer's Manual
20/// of module \alib_format.
22 const lang::CallerInfo& ci; ///< The wrapped caller information.
23
24 /// Formats the wrapped caller information using a given pattern string.
25 /// Within the pattern string, different symbols are interpreted as tokens.
26 ///
27 /// Strings within the format text that should not be interpreted as tokens may be given
28 /// in single quotes.
29 /// Two consecutive single quotes will be replaced to one single quote.<br>
30 ///
31 /// The following tokens are supported:
32 ///
33 /// <center>Token</center> | <center>Description</center>
34 /// - - - - - - - - - - - - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
35 /// sf | Prints the #"CallerInfo::File;source file name".
36 /// sl | Prints the #"CallerInfo::Line;line number" in the source file.
37 /// sm | Prints the #"CallerInfo::Func;function or method name" in the source file.
38 /// tn | Prints the #"Thread::GetName;ALib tread name". If no thread is set, the string <em>"<None>"</em> is written, which is resourced with <b>"FMTCINT"</b>.
39 /// ti | Prints the #"Thread::GetName;ALib tread ID". If no thread is set, the string <em>"<Null>"</em> is written, which is resourced with <b>"FMTCINR"</b>.
40 /// tc | Prints the native tread ID of type <c>std::thread::id</c> in hexadecimal format. If no thread is set, this value is \c 0.
41 /// ta | Prints a combination of 'tn', 'ti', and 'tc'.
42 /// yf | Prints the full type name. If the #"%CallerInfo" does originate a static or global function, the string <em>"<None>"</em> is written, which is resourced with <b>"FMTCINY"</b>.<br>(With release-builds, nothing is printed.)
43 /// yn | Prints shortened type name, otherwise like 'yf'.
44 /// ya | Like 'sm' but in case the #"%CallerInfo" originates from a non-static member function, the shortened type name and <b>"::"</b> are prepended.<br>(With release-builds, nothing is printed.)
45 ///
46 /// @param format The format pattern string.
47 /// @param target A reference to an AString that gets the result of the format processing
48 /// appended.
49 /// @param targetData If \c CurrentData::Keep (the default) the string is appended to \p{target}.
50 /// if \c CurrentData::Clear, \p{target} is cleared.
51 /// @returns \p{target} (for convenience).
55};
56
57
58//==================================================================================================
59/// Implementation of #"FFormat" for boxable type #"FMTCallerInfo".<br>
60/// Writes the content of \p{box} (which is of type #"%CallerInfo") to the given #"%AString"
61/// object \p{target} using a local instance of class #"FMTCallerInfo" and its
62/// method #"FMTCallerInfo::Format;*".
63///
64/// If parameter \p{formatSpec} is empty, a default format string defined by string resource
65/// of key \b "FMTCI" is used. This resource by default evaluates to
66/// \par
67/// <c>"[@ sf:sl from ''ya'' by ''ta'']"</c>
68///
69/// which results in the same output that is generated if an instance of class #"%CallerInfo" is
70/// simply appended to an #"%AString", what in turn is defined with functor
71/// #"AppendableTraits<lang::CallerInfo,TChar,TAllocator>".
72///
73/// @param self The box that the function was invoked on.
74/// @param formatSpec The specification of the format.
75/// @param nf A copy of the number format of the formatter (allowed to be modified).
76/// @param target The AString object receiving the formatted string.
77//==================================================================================================
78ALIB_DLL void
79FFormat_CallerInfo( const Box& self, const String& formatSpec, NumberFormat& nf, AString& target );
80
81
82} // namespace alib[::format]
83
84/// Type alias in namespace #"%alib".
86
87} // namespace [alib]
#define ALIB_DLL
#define ALIB_EXPORT
void FFormat_CallerInfo(const Box &self, const String &formatSpec, NumberFormat &nf, AString &target)
@ Keep
Chooses not no clear existing data.
Definition alox.cpp:14
strings::TNumberFormat< character > NumberFormat
Type alias in namespace #"%alib".
boxing::Box Box
Type alias in namespace #"%alib".
Definition box.hpp:1128
strings::TString< character > String
Type alias in namespace #"%alib".
Definition string.hpp:2165
format::FMTCallerInfo FMTCallerInfo
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
const lang::CallerInfo & ci
The wrapped caller information.
AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep) const