ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
fmtcallerinfo.inl
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/// \emoji :copyright: 2013-2025 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 \b 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{
23 const lang::CallerInfo& ci; ///< The wrapped caller information.
24
25 /// Formats the wrapped caller information using a given pattern string.
26 /// Within the pattern string, different symbols are interpreted as tokens.
27 ///
28 /// Strings within the format text that should not be interpreted as tokens may be given
29 /// in single quotes.
30 /// Two consecutive single quotes will be replaced to one single quote.<br>
31 ///
32 /// The following tokens are supported:
33 ///
34 /// <center>Token</center> | <center>Description</center>
35 /// - - - - - - - - - - - - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
36 /// sf | Prints the #"CallerInfo::File;source file name".
37 /// sl | Prints the #"CallerInfo::Line;line number" in the source file.
38 /// sm | Prints the #"CallerInfo::Func;function or method name" in the source file.
39 /// 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>.
40 /// 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>.
41 /// 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.
42 /// ta | Prints a combination of 'tn', 'ti', and 'tc'.
43 /// yf | Prints the full type name. If the \b 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.)
44 /// yn | Prints shortened type name, otherwise like 'yf'.
45 /// ya | Like 'sm' but in case the \b CallerInfo originates from a non-static member function, the shortened type name and <b>"::"</b> are prepended.<br>(With release-builds, nothing is printed.)
46 ///
47 /// @param format The format pattern string.
48 /// @param target A reference to an AString that gets the result of the format processing
49 /// appended.
50 /// @param targetData If \c CurrentData::Keep (the default) the string is appended to \p{target}.
51 /// if \c CurrentData::Clear, \p{target} is cleared.
52 /// @returns \p{target} (for convenience).
56};
57
58
59//==================================================================================================
60/// Implementation of #"FFormat" for boxable type #"FMTCallerInfo".<br>
61/// Writes the content of \p{box} (which is of type \b %CallerInfo) to the given \b %AString
62/// object \p{target} using a local instance of class #"FMTCallerInfo" and its
63/// method #"FMTCallerInfo::Format;*".
64///
65/// If parameter \p{formatSpec} is empty, a default format string defined by string resource
66/// of key \b "FMTCI" is used. This resource by default evaluates to
67/// \par
68/// <c>"[@ sf:sl from ''ya'' by ''ta'']"</c>
69///
70/// which results in the same output that is generated if an instance of class \b CallerInfo is
71/// simply appended to an \b AString, what in turn is defined with functor
72/// #"AppendableTraits<lang::CallerInfo,TChar,TAllocator>".
73///
74/// @param self The box that the function was invoked on.
75/// @param formatSpec The specification of the format.
76/// @param nf A copy of the number format of the formatter (allowed to be modified).
77/// @param target The AString object receiving the formatted string.
78//==================================================================================================
79ALIB_DLL void
80FFormat_CallerInfo( const Box & self, const String & formatSpec, NumberFormat& nf, AString& target );
81
82
83} // namespace alib[::format]
84
85/// Type alias in namespace \b alib.
87
88} // namespace [alib]
#define ALIB_DLL
Definition alib.inl:573
#define ALIB_EXPORT
Definition alib.inl:562
void FFormat_CallerInfo(const Box &self, const String &formatSpec, NumberFormat &nf, AString &target)
@ Keep
Chooses not no clear existing data.
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
Definition box.inl:1135
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2172
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