ALib C++ Library
Library Version: 2412 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 sub-namespace #alib::lang::system of module \alib_basecamp of
4/// the \aliblong.
5///
6/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
7/// Published under \ref mainpage_license "Boost Software License".
8//==================================================================================================
9#ifndef HPP_ALIB_LANG_FORMAT_CALLERINFO
10#define HPP_ALIB_LANG_FORMAT_CALLERINFO 1
11#pragma once
12#if !defined(DOXYGEN)
13# include "alib/alib.hpp"
14#endif
16
17#include "alib/strings/fwds.hpp"
19
20
21namespace alib { namespace lang::format {
22
23/// This struct is used to format caller information provided with type \alib{CallerInfo}.
24///
25/// Besides using method #Format "manually", instances of type \b CallerInfo may be passed as
26/// arguments to type \alib{lang::format;FormatterPythonStyle} using the according placeholder
27/// syntax.
28/// If done, internally an instance of this type is created and its #Format method called.
29///
30/// \note
31/// This is achieved by boxed function \alib{lang::format;FFormat_CallerInfo}, as
32/// explained in chapter \ref alib_basecamp_format_custom_types of the Programmer's Manual
33/// of module \alib_basecamp.
35{
36 const lang::CallerInfo& ci; ///< The wrapped caller information.
37
38 /// Formats the wrapped caller information using a given pattern string.
39 /// Within the pattern string, different symbols are interpreted as tokens.
40 ///
41 /// Strings within the format text that should not be interpreted as tokens may be given
42 /// in single quotes.
43 /// Two consecutive single quotes will be replaced to one single quote.<br>
44 ///
45 /// The following tokens are supported:
46 ///
47 /// <center>Token</center> | <center>Description</center>
48 /// - - - - - - - - - - - - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
49 /// sf | Prints the \alib{lang::CallerInfo;File;source file name}.
50 /// sl | Prints the \alib{lang::CallerInfo;Line;line number} in the source file.
51 /// sm | Prints the \alib{lang::CallerInfo;Func;function or method name} in the source file.
52 /// tn | Prints the \alib{threads;Thread::GetName;ALib tread name}. If no thread is set, the string <em>"<None>"</em> is written, which is resourced with <b>"FMTCINT"</b>.
53 /// ti | Prints the \alib{threads;Thread::GetName;ALib tread ID}. If no thread is set, the string <em>"<Null>"</em> is written, which is resourced with <b>"FMTCINR"</b>.
54 /// 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.
55 /// ta | Prints a combination of 'tn', 'ti', and 'tc'.
56 /// 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.)
57 /// yn | Prints shortened type name generated with \alib{lang;DbgTypeDemangler::GetShort}, otherwise like 'yf'.
58 /// 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.)
59 ///
60 /// @param format The format pattern string.
61 /// @param target A reference to an AString that gets the result of the format processing
62 /// appended.
63 /// @param targetData If \c CurrentData::Keep (the default) the string is appended to \p{target}.
64 /// if \c CurrentData::Clear, \p{target} is cleared.
65 /// @returns \p{target} (for convenience).
67 AString& Format( Substring format, AString& target,
69};
70
71
72//==================================================================================================
73/// Implementation of \alib{lang::format;FFormat} for boxable type \alib{FMTCallerInfo}.<br>
74/// Writes the content of \p{box} (which is of type \b %CallerInfo) to the given \b %AString
75/// object \p{target} using a local instance of class \alib{lang::format;FMTCallerInfo} and its
76/// method \alib{lang::format;FMTCallerInfo::Format}.
77///
78/// If parameter \p{formatSpec} is empty, a default format string defined by string resource
79/// of key \b "FMTCI" is used. This resource by default evaluates to
80/// \par
81/// <c>"[@ sf:sl from ''ya'' by ''ta'']"</c>
82///
83/// which results in the same output that is generated if an instance of class \b CallerInfo is
84/// simply appended to an \b AString, what in turn is defined with functor
85/// \alib{strings::APPENDABLES;T_Append<lang::CallerInfo,TChar,TAllocator>}.
86///
87/// @param self The box that the function was invoked on.
88/// @param formatSpec The specification of the format.
89/// @param nf A copy of the number format of the formatter (allowed to be modified).
90/// @param target The AString object receiving the formatted string.
91//==================================================================================================
92ALIB_API void
93FFormat_CallerInfo( const Box & self, const String & formatSpec, NumberFormat& nf, AString& target );
94
95
96} // namespace alib[:: lang::format]
97
98/// Type alias in namespace \b alib.
100
101} // namespace [alib]
102
103#endif // HPP_ALIB_LANG_FORMAT_CALLERINFO
104
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_API
Definition alib.hpp:639
void FFormat_CallerInfo(const Box &box, const String &formatSpec, NumberFormat &, AString &target)
@ Keep
Chooses not no clear existing data.
Definition alib.cpp:69
strings::TFormat< character > Format
Type alias in namespace alib.
const lang::CallerInfo & ci
The wrapped caller information.