ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
appendables.inl
Go to the documentation of this file.
1
2//==================================================================================================
3/// \file
4/// This header file is part of module \alib_strings of 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_STRINGS_APPENDABLES
10#define HPP_ALIB_STRINGS_APPENDABLES 1
11#pragma once
12#if !defined(HPP_ALIB_STRINGS_TASTRING_INLINING)
13# error "ALib sources with ending '.inl' must not be included from outside."
14#endif
15
16namespace alib { namespace strings {
17
18// #################################################################################################
19// struct T_Append: fundamental types
20// #################################################################################################
21
22// Faking all template specializations of namespace strings for doxygen into namespace
23// strings::APPENDABLES to keep the documentation of namespace string clean!
24#if DOXYGEN
25namespace APPENDABLES {
26#endif
27
28/// Specialization of functor \alib{strings;T_Append} for type \c bool.
29template<typename TChar, typename TAllocator> struct T_Append<bool ,TChar,TAllocator>
30{
31 //==============================================================================================
32 /// Writes the words "true" or "false" to the given AString.
33 /// @param target The \b AString that \b Append was invoked on.
34 /// @param b The boolean to write to \p{target}.
35 //==============================================================================================
36 void operator()( TAString<TChar,TAllocator>& target, bool b )
37 {
38 target.template _<NC>( b ? "true" : "false" );
39 }
40};
41
42/// Specialization of functor \alib{strings;T_Append} for type \c int8_t.
43template<typename TChar, typename TAllocator> struct T_Append<int8_t ,TChar,TAllocator>
44{
45 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
46 /// conversion to the corresponding static specialization for that type.
47 ///
48 /// @param target The \b AString that \b Append was invoked on.
49 /// @param value The value to write.
50 void operator()( TAString<TChar,TAllocator>& target, int8_t value )
51 {
52 T_Append<int64_t, TChar,TAllocator>()( target, value );
53 }
54};
55
56/// Specialization of functor \alib{strings;T_Append} for type \c uint8_t.
57template<typename TChar, typename TAllocator> struct T_Append<uint8_t ,TChar,TAllocator>
58{
59 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
60 /// conversion to the corresponding static specialization for that type.
61 ///
62 /// @param target The \b AString that \b Append was invoked on.
63 /// @param value The value to write.
64 void operator()( TAString<TChar,TAllocator>& target, uint8_t value )
65 {
66 T_Append<uint64_t, TChar,TAllocator>()( target, value );
67 }
68};
69
70/// Specialization of functor \alib{strings;T_Append} for type \c int16_t.
71template<typename TChar, typename TAllocator> struct T_Append<int16_t ,TChar,TAllocator>
72{
73 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
74 /// conversion to the corresponding static specialization for that type.
75 ///
76 /// @param target The \b AString that \b Append was invoked on.
77 /// @param value The value to write.
78 void operator()( TAString<TChar,TAllocator>& target, int16_t value )
79 {
80 T_Append<int64_t, TChar,TAllocator>()( target, value );
81 }
82
83};
84
85/// Specialization of functor \alib{strings;T_Append} for type \c uint16_t.
86template<typename TChar, typename TAllocator> struct T_Append<uint16_t ,TChar,TAllocator>
87{
88 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
89 /// conversion to the corresponding static specialization for that type.
90 ///
91 /// @param target The \b AString that \b Append was invoked on.
92 /// @param value The value to write.
93 void operator()( TAString<TChar,TAllocator>& target, uint16_t value )
94 {
95 T_Append<uint64_t, TChar,TAllocator>()( target, value );
96 }
97
98};
99
100/// Specialization of functor \alib{strings;T_Append} for type \c int32_t.
101template<typename TChar, typename TAllocator> struct T_Append<int32_t ,TChar,TAllocator>
102{
103 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
104 /// conversion to the corresponding static specialization for that type.
105 ///
106 /// @param target The \b AString that \b Append was invoked on.
107 /// @param value The value to write.
108 void operator()( TAString<TChar,TAllocator>& target, int32_t value )
109 {
110 T_Append<int64_t, TChar,TAllocator>()( target, value );
111 }
112
113};
114
115/// Specialization of functor \alib{strings;T_Append} for type \c uint32_t.
116template<typename TChar, typename TAllocator> struct T_Append<uint32_t ,TChar,TAllocator>
117{
118 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
119 /// conversion to the corresponding static specialization for that type.
120 ///
121 /// @param target The \b AString that \b Append was invoked on.
122 /// @param value The value to write.
123 void operator()( TAString<TChar,TAllocator>& target, uint32_t value )
124 {
125 T_Append<uint64_t, TChar,TAllocator>()( target, value );
126 }
127
128};
129
130
131/// Specialization of functor \alib{strings;T_Append} for type \c int64_t.
132template<typename TChar, typename TAllocator> struct T_Append<int64_t ,TChar,TAllocator>
133{
134 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
135 /// conversion to the corresponding static specialization for that type.
136 ///
137 /// @param target The \b AString that \b Append was invoked on.
138 /// @param value The value to write.
139 void operator()( TAString<TChar,TAllocator>& target, int64_t value );
140};
141
142/// Specialization of functor \alib{strings;T_Append} for type \c uint64_t.
143template<typename TChar, typename TAllocator> struct T_Append<uint64_t ,TChar,TAllocator>
144{
145 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
146 /// conversion to the corresponding static specialization for that type.
147 ///
148 /// @param target The \b AString that \b Append was invoked on.
149 /// @param value The value to write.
150 void operator()( TAString<TChar,TAllocator>& target, uint64_t value );
151};
152
153/// Specialization of functor \alib{strings;T_Append} for type \c intGap_t.
154template<typename TChar, typename TAllocator> struct T_Append<intGap_t ,TChar,TAllocator>
155{
156 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
157 /// conversion to the corresponding static specialization for that type.
158 ///
159 /// @param target The \b AString that \b Append was invoked on.
160 /// @param value The value to write.
162 {
163 T_Append<int64_t, TChar,TAllocator>()( target, value );
164 }
165
166};
167
168/// Specialization of functor \alib{strings;T_Append} for type \c uintGap_t.
169template<typename TChar, typename TAllocator> struct T_Append<uintGap_t ,TChar,TAllocator>
170{
171 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
172 /// conversion to the corresponding static specialization for that type.
173 ///
174 /// @param target The \b AString that \b Append was invoked on.
175 /// @param value The value to write.
177 {
178 T_Append<uint64_t, TChar,TAllocator>()( target, value );
179 }
180};
181
182/// Specialization of functor \alib{strings;T_Append} for type \c float.
183template<typename TChar, typename TAllocator> struct T_Append<float ,TChar,TAllocator>
184{
185 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
186 /// conversion to the corresponding static specialization for that type.
187 ///
188 /// @param target The \b AString that \b Append was invoked on.
189 /// @param value The value to write.
190 void operator()( TAString<TChar,TAllocator>& target, float value)
191 {
192 T_Append<double, TChar,TAllocator>()( target, static_cast<double>(value) );
193 }
194};
195
196/// Specialization of functor \alib{strings;T_Append} for type \c double.
197template<typename TChar, typename TAllocator> struct T_Append<double ,TChar,TAllocator>
198{
199 /// Creates a defaulted object of type \alib{strings;TFormat;Format} and defers the number
200 /// conversion to the corresponding static specialization for that type.
201 ///
202 /// @param target The \b AString that \b Append was invoked on.
203 /// @param value The value to write.
204 void operator()( TAString<TChar,TAllocator>& target, double value);
205};
206
207/// Specialization of functor \alib{strings;T_Append} for type <c>long double</c>.
208template<typename TChar, typename TAllocator> struct T_Append<long double ,TChar,TAllocator>
209{
210 /// Casts the value "down" to just \c double and creates a defaulted object of
211 /// type \alib{strings;TFormat;Format} and defers the number
212 /// conversion to the corresponding static specialization for type \c double.
213 ///
214 /// @param target The \b AString that \b Append was invoked on.
215 /// @param value The value to write.
216 void operator()( TAString<TChar,TAllocator>& target, long double value)
217 {
218 T_Append<double, TChar,TAllocator>()( target, static_cast<double>(value) );
219 }
220};
221
222
223#if ALIB_DEBUG
224/// Specialization of functor \alib{strings;T_Append} for type \c std::type_info.<br>
225/// Available only in debug-compilations.
226template<typename TChar, typename TAllocator> struct T_Append<std::type_info ,TChar,TAllocator>
227{
228 //==============================================================================================
229 /// Writes the demangled type name.
230 /// @param target The \b AString that \b Append was invoked on.
231 /// @param type The type to write to \p{target}.
232 //==============================================================================================
233 void operator()( TAString<TChar,TAllocator>& target, const std::type_info& type );
234};
235#endif
236
237#if ALIB_EXT_LIB_THREADS_AVAILABLE
238/// Specialization of functor \alib{strings;T_Append} for type \c std::thread::id.<br>
239template<typename TChar, typename TAllocator> struct T_Append<std::thread::id ,TChar,TAllocator>
240{
241 //==============================================================================================
242 /// Writes the thread information.
243 /// @param target The \b AString that \b Append was invoked on.
244 /// @param type The thread ID to write to \p{target}.
245 //==============================================================================================
246 void operator()( TAString<TChar,TAllocator>& target, const std::thread::id& type );
247};
248#endif
249
250/// Specialization of functor \alib{strings;T_Append} for type \alib{lang;CallerInfo}.<br>
251/// This functor writes all information available in a standard format.
252/// A more flexible way is provided with formatter type \alib{lang::format;FMTCallerInfo} that
253/// defines a format string to pick certain fields of the \b CallerInfo.
254/// This format specification is also availble in placeholders of type
255/// \alib{lang::format;FormatterPythonStyle}.
256template<typename TChar, typename TAllocator> struct T_Append<lang::CallerInfo ,TChar,TAllocator>
257{
258 //==============================================================================================
259 /// Writes thread and source location.
260 /// @param target The \b AString that \b Append was invoked on.
261 /// @param ci The caller information to write to \p{target}.
262 //==============================================================================================
264};
265
266
267
268// Faking all template specializations of namespace strings for doxygen into namespace
269// strings::APPENDABLES to keep the documentation of namespace string clean!
270#if DOXYGEN
271}
272#endif
273
274
275}} // namespace [alib::strings]
276
277#endif // HPP_ALIB_STRINGS_APPENDABLES
278
Definition alib.cpp:69
lang::intGap_t intGap_t
Type alias in namespace alib.
Definition integers.hpp:279
lang::uintGap_t uintGap_t
Type alias in namespace alib.
Definition integers.hpp:282
void operator()(TAString< TChar, TAllocator > &target, bool b)
void operator()(TAString< TChar, TAllocator > &target, double value)
void operator()(TAString< TChar, TAllocator > &target, float value)
void operator()(TAString< TChar, TAllocator > &target, int16_t value)
void operator()(TAString< TChar, TAllocator > &target, int32_t value)
void operator()(TAString< TChar, TAllocator > &target, int64_t value)
void operator()(TAString< TChar, TAllocator > &target, int8_t value)
void operator()(TAString< TChar, TAllocator > &target, intGap_t value)
void operator()(TAString< TChar, TAllocator > &target, const lang::CallerInfo &ci)
void operator()(TAString< TChar, TAllocator > &target, long double value)
void operator()(TAString< TChar, TAllocator > &target, const std::thread::id &type)
void operator()(TAString< TChar, TAllocator > &target, const std::type_info &type)
void operator()(TAString< TChar, TAllocator > &target, uint16_t value)
void operator()(TAString< TChar, TAllocator > &target, uint32_t value)
void operator()(TAString< TChar, TAllocator > &target, uint64_t value)
void operator()(TAString< TChar, TAllocator > &target, uint8_t value)
void operator()(TAString< TChar, TAllocator > &target, uintGap_t value)