ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
boxingcustoms.inl.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_boxing of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8
9// ######### Switch off documentation parser for (almost) the whole header #####
10#if !DOXYGEN
11
12// #################################################################################################
13// void*, Boxes*, Box[]
14// #################################################################################################
15ALIB_BOXING_VTABLE_DECLARE( void*, vt_voidP )
16
17ALIB_EXPORT namespace alib { namespace boxing {
18
19class BoxesHA;
20class BoxesMA;
21
22template<>
23struct BoxTraits<void*>
24{
25 using Mapping= void*;
26 static constexpr bool IsArray= false;
27 static constexpr Placeholder Write( const void* value ) { return Placeholder( value ); }
28 static void* Read ( const Placeholder& box) { return const_cast<void*>( box.GetVoidPointer() ); }
29};
30}}
31
32ALIB_BOXING_VTABLE_DECLARE( BoxesHA*, vt_boxes )
33#if ALIB_MONOMEM
34ALIB_BOXING_VTABLE_DECLARE( BoxesMA*, vt_boxesma )
35#endif
36ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE( Box , vt_boxarray )
37
38
39// #################################################################################################
40// Enums
41// #################################################################################################
42ALIB_EXPORT namespace alib { namespace boxing {
43template<typename TEnum>
44requires std::is_enum<TEnum>::value
45struct BoxTraits<TEnum >
46{
47 using Mapping= TEnum;
48 static constexpr bool IsArray= false;
49
50 static constexpr void Write( Placeholder& box, TEnum const & enumElement )
51 { box.Write( integer( enumElement ) ); }
52
53 static TEnum Read( const Placeholder& box)
54 { return TEnum( static_cast<typename std::underlying_type_t<TEnum>>( box.Integrals.Array[0]) ); }
55};
56}}
57
58
59// #################################################################################################
60// Boolean
61// #################################################################################################
62DOX_MARKER([DOX_BOXING_OPTIMIZE_DECLARE_1])
63ALIB_BOXING_VTABLE_DECLARE( bool, vt_bool )
64DOX_MARKER([DOX_BOXING_OPTIMIZE_DECLARE_1])
65
67
68
69// #################################################################################################
70// Integrals
71// #################################################################################################
72#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
73
74 ALIB_BOXING_VTABLE_DECLARE( integer, vt_integer )
75 ALIB_BOXING_VTABLE_DECLARE( uinteger, vt_uinteger )
76
77 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( integer , integer )
78 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uinteger , uinteger )
79
81 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uint8_t, uinteger )
82 //ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( int16_t, integer ) // done in dox sample below
83 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uint16_t, uinteger )
84 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( intGap_t, integer )
85 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uintGap_t, uinteger )
86
87 #if ALIB_SIZEOF_INTEGER == 8
88 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( int32_t, integer )
89 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uint32_t, uinteger )
90 #endif
91
92
93DOX_MARKER([DOX_BOXING_CUSTOM_MANUAL])
94ALIB_EXPORT namespace alib { namespace boxing {
95
96template<>
97struct BoxTraits<int16_t>
98{
100 static constexpr bool IsArray= false;
101
102 // The Write function (boxing) converts the value to type alib::integer
103 static constexpr void Write( Placeholder& box, int16_t const & value ) {
104 box.Write( integer( value ) );
105 }
106
107 // The read function is decared to return 'void'. This determines that unboxing is not
108 // possible/allowed.
109 // Thus, no implementation is given, because this method is never called.
110 static void Read( const Placeholder& box);
111};
112
113}}
114DOX_MARKER([DOX_BOXING_CUSTOM_MANUAL])
115
116//--------- documentation sample of Programmer's Manual --------
117
118#else // ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
119 ALIB_BOXING_VTABLE_DECLARE( int8_t , vt_int8_t )
120 ALIB_BOXING_VTABLE_DECLARE( uint8_t , vt_uint8_t )
121 ALIB_BOXING_VTABLE_DECLARE( int16_t , vt_int16_t )
122 ALIB_BOXING_VTABLE_DECLARE( uint16_t , vt_uint16_t )
123 ALIB_BOXING_VTABLE_DECLARE( int32_t , vt_int32_t )
124 ALIB_BOXING_VTABLE_DECLARE( uint32_t , vt_uint32_t )
125 ALIB_BOXING_VTABLE_DECLARE( intGap_t , vt_intGap_t )
126 ALIB_BOXING_VTABLE_DECLARE( uintGap_t , vt_uintGap_t )
127 #if ALIB_SIZEOF_INTEGER == 8
128 ALIB_BOXING_VTABLE_DECLARE( int64_t , vt_int64_t )
129 ALIB_BOXING_VTABLE_DECLARE( uint64_t , vt_uint64_t )
130 #endif
131
133 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint8_t, uint8_t)
134 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( int16_t, int16_t)
135 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint16_t, uint16_t)
136 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( int32_t, int32_t)
137 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint32_t, uint32_t)
138 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( intGap_t, intGap_t)
139 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uintGap_t, uintGap_t)
140
141 #if ALIB_SIZEOF_INTEGER == 8
142 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( int64_t, int64_t)
143 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint64_t, uint64_t)
144 #endif
145
146#endif // ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
147
148
149
150// #################################################################################################
151// Floating point
152// #################################################################################################
153#if !ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
155#else
156 ALIB_BOXING_VTABLE_DECLARE( float, vt_float )
158#endif
159
160 ALIB_BOXING_VTABLE_DECLARE( double , vt_double )
161 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( double , double )
162
163#if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
164 ALIB_BOXING_VTABLE_DECLARE( long double, vt_long_double )
165
166ALIB_EXPORT namespace alib::boxing {
167template<>
168struct BoxTraits<long double>
169{
170 using Mapping= long double;
171 static constexpr bool IsArray= false;
172 static void Write( Placeholder& box, long double const & value )
173 {
174 const char* src = reinterpret_cast<const char*>( &value );
175 char* dest= reinterpret_cast< char*>( &box );
176 for (int i = 0; i < ALIB_SIZEOF_LONGDOUBLE_WRITTEN; ++i)
177 *dest++= *src++;
178 }
179
180 static long double Read (const Placeholder& placeholder)
181 {
182 long double result;
183 const char* src = reinterpret_cast<const char*>( &placeholder );
184 char* dest= reinterpret_cast< char*>( &result );
185 for (int i = 0; i < ALIB_SIZEOF_LONGDOUBLE_WRITTEN; ++i)
186 *dest++= *src++;
187 return result;
188 }
189}; }
190
191#endif
192
193
194// #################################################################################################
195// Characters
196// #################################################################################################
197
198#if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
199 ALIB_BOXING_VTABLE_DECLARE( wchar, vt_wchar )
200
202 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( char8_t , wchar )
203
204 #if ALIB_CHARACTERS_NATIVE_WCHAR
205 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( wchar_t, wchar )
206 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( char16_t, wchar )
207 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( char32_t, wchar )
208 #else
210 # if ALIB_CHARACTERS_SIZEOF_WCHAR == 4
211 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( char16_t, wchar )
212 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( char32_t, wchar )
213 # else
214 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( char16_t, wchar )
215 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( char32_t, wchar )
216 # endif
217 #endif
218#else
219 ALIB_BOXING_VTABLE_DECLARE( char , vt_char )
220 ALIB_BOXING_VTABLE_DECLARE( wchar_t , vt_wchar_t )
221 ALIB_BOXING_VTABLE_DECLARE( char8_t , vt_char8_t )
222 ALIB_BOXING_VTABLE_DECLARE( char16_t , vt_char16_t )
223 ALIB_BOXING_VTABLE_DECLARE( char32_t , vt_char32_t )
224
226 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(wchar_t , wchar_t )
227 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(char8_t , char8_t )
228 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(char16_t, char16_t )
229 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(char32_t, char32_t )
230#endif
231
232
233// #################################################################################################
234// Static VTables for standard types
235// #################################################################################################
236ALIB_BOXING_VTABLE_DECLARE( std::type_info* , vt_std_type_info )
237
238// #################################################################################################
239// Static VTables for low-level ALib types
240// #################################################################################################
241// CodeMarker_CommonEnums
266
269ALIB_BOXING_VTABLE_DECLARE( alib::time::Ticks::Duration , vt_time_ticks_duration )
271ALIB_BOXING_VTABLE_DECLARE( alib::time::DateTime::Duration , vt_time_datetime_duration )
272#if !ALIB_SINGLE_THREADED
274#endif
275
276#if ALIB_STRINGS
277ALIB_BOXING_VTABLE_DECLARE( std::reference_wrapper<alib::strings::TAString<nchar ALIB_COMMA lang::HeapAllocator>>, vt_alib_wrapped_tanstring )
278ALIB_BOXING_VTABLE_DECLARE( std::reference_wrapper<alib::strings::TAString<wchar ALIB_COMMA lang::HeapAllocator>>, vt_alib_wrapped_tawstring )
279ALIB_BOXING_VTABLE_DECLARE( std::reference_wrapper<alib::strings::TAString<xchar ALIB_COMMA lang::HeapAllocator>>, vt_alib_wrapped_taxstring )
280
282#endif
283
284#endif //DOXYGEN
285
286
287
288
#define ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE(TMapped, Identifier)
#define ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(TSource, TMapped)
#define ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE(TSource, TMapped)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_EXPORT
Definition alib.inl:488
#define ALIB_SIZEOF_LONGDOUBLE_WRITTEN
Definition prepro.md:27
SortOrder
Denotes sort order.
Side
Denotes if something is left or right.
SourceData
Denotes if the source data should be moved or copied.
Reach
Denotes the reach of something.
Recursive
Denotes whether recursion is performed/allowed or not.
Timing
Denotes if asynchronous tasks become synchronized.
Alignment
Denotes Alignments.
ContainerOp
Denotes standard container operations.
Switch
Denotes if sth. is switched on or off.
Phase
Denotes a phase, e.g.,of a transaction.
CreateIfNotExists
Denotes whether something should be created if it does not exist.
Case
Denotes upper and lower case character treatment.
CreateDefaults
Denotes whether default entities should be created or not.
Whitespaces
Denotes whether a string is trimmed or not.
Caching
Denotes if a cache mechanism is enabled or disabled.
Propagation
Denotes whether a e.g a setting should be propagated.
ValueReference
Denotes if a value is interpreted as an absolute or relative number.
Safeness
Denotes whether something should be performed in a safe or unsafe fashion.
Initialization
Used for example with constructors that allow to suppress initialization of members.
Inclusion
Denotes how members of a set something should be taken into account.
Timezone
Denotes whether a time value represents local time or UTC.
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
boxing::TBoxes< MonoAllocator > BoxesMA
Type alias in namespace alib.
Definition boxes.inl:245
boxing::TBoxes< lang::HeapAllocator > BoxesHA
Type alias in namespace alib.
Definition boxes.inl:241
static std::conditional_t<!std::is_abstract< TBoxable >::value, TBoxable, TBoxable & > Read(const Placeholder &box)
DefaultBoxingTag Mapping
static constexpr void Write(Placeholder &box, const TBoxable &value)
static constexpr bool IsArray
Denotes whether type TBoxable is boxed as an array-type or not.