ALib C++ Library
Library Version: 2511 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 Boxes;
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) {
29 return const_cast<void*>( box.GetVoidPointer() );
30 }
31};
32}}
33
34ALIB_BOXING_VTABLE_DECLARE( Boxes* , vt_boxes )
35#if ALIB_MONOMEM
36ALIB_BOXING_VTABLE_DECLARE( BoxesMA*, vt_boxesma )
37#endif
38ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE( Box , vt_boxarray )
39
40
41//##################################################################################################
42// Enums
43//##################################################################################################
44ALIB_EXPORT namespace alib { namespace boxing {
45template<typename TEnum>
46requires std::is_enum<TEnum>::value
47struct BoxTraits<TEnum >
48{
49 using Mapping= TEnum;
50 static constexpr bool IsArray= false;
51
52 static constexpr void Write( Placeholder& box, TEnum const & enumElement )
53 { box.Write( integer( enumElement ) ); }
54
55 static TEnum Read( const Placeholder& box)
56 { return TEnum( static_cast<typename std::underlying_type_t<TEnum>>(box.Integrals.Array[0])); }
57};
58}}
59
60
61//##################################################################################################
62// Boolean
63//##################################################################################################
64DOX_MARKER([DOX_BOXING_OPTIMIZE_DECLARE_1])
65ALIB_BOXING_VTABLE_DECLARE( bool, vt_bool )
66DOX_MARKER([DOX_BOXING_OPTIMIZE_DECLARE_1])
67
69
70
71//##################################################################################################
72// Integrals
73//##################################################################################################
74#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
75
76 ALIB_BOXING_VTABLE_DECLARE( integer, vt_integer )
77 ALIB_BOXING_VTABLE_DECLARE( uinteger, vt_uinteger )
78
79 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( integer , integer )
80 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uinteger , uinteger )
81
83 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uint8_t, uinteger )
84 //ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( int16_t, integer ) // done in dox sample below
85 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uint16_t, uinteger )
86 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( intGap_t, integer )
87 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uintGap_t, uinteger )
88
89 #if ALIB_SIZEOF_INTEGER == 8
90 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( int32_t, integer )
91 ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE( uint32_t, uinteger )
92 #endif
93
94
95DOX_MARKER([DOX_BOXING_CUSTOM_MANUAL])
96ALIB_EXPORT namespace alib { namespace boxing {
97
98template<>
99struct BoxTraits<int16_t>
100{
101 using Mapping= alib::integer;
102 static constexpr bool IsArray= false;
103
104 // The Write function (boxing) converts the value to type alib::integer
105 static constexpr void Write( Placeholder& box, int16_t const & value ) {
106 box.Write( integer( value ) );
107 }
108
109 // The read function is decared to return 'void'. This determines that unboxing is not
110 // possible/allowed.
111 // Thus, no implementation is given, because this method is never called.
112 static void Read( const Placeholder& box);
113};
114
115}}
116DOX_MARKER([DOX_BOXING_CUSTOM_MANUAL])
117
118//--------------------------- documentation sample of Programmer's Manual --------------------------
119
120#else // ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
121 ALIB_BOXING_VTABLE_DECLARE( int8_t , vt_int8_t )
122 ALIB_BOXING_VTABLE_DECLARE( uint8_t , vt_uint8_t )
123 ALIB_BOXING_VTABLE_DECLARE( int16_t , vt_int16_t )
124 ALIB_BOXING_VTABLE_DECLARE( uint16_t , vt_uint16_t )
125 ALIB_BOXING_VTABLE_DECLARE( int32_t , vt_int32_t )
126 ALIB_BOXING_VTABLE_DECLARE( uint32_t , vt_uint32_t )
127 ALIB_BOXING_VTABLE_DECLARE( intGap_t , vt_intGap_t )
128 ALIB_BOXING_VTABLE_DECLARE( uintGap_t , vt_uintGap_t )
129 #if ALIB_SIZEOF_INTEGER == 8
130 ALIB_BOXING_VTABLE_DECLARE( int64_t , vt_int64_t )
131 ALIB_BOXING_VTABLE_DECLARE( uint64_t , vt_uint64_t )
132 #endif
133
135 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint8_t, uint8_t)
136 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( int16_t, int16_t)
137 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint16_t, uint16_t)
138 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( int32_t, int32_t)
139 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint32_t, uint32_t)
140 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( intGap_t, intGap_t)
141 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uintGap_t, uintGap_t)
142
143 #if ALIB_SIZEOF_INTEGER == 8
144 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( int64_t, int64_t)
145 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( uint64_t, uint64_t)
146 #endif
147
148#endif // ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
149
150
151
152//##################################################################################################
153// Floating point
154//##################################################################################################
155#if !ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
157#else
158 ALIB_BOXING_VTABLE_DECLARE( float, vt_float )
160#endif
161
162 ALIB_BOXING_VTABLE_DECLARE( double , vt_double )
163 ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( double , double )
164
165#if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
166 ALIB_BOXING_VTABLE_DECLARE( long double, vt_long_double )
167
168ALIB_EXPORT namespace alib::boxing {
169template<>
170struct BoxTraits<long double>
171{
172 using Mapping= long double;
173 static constexpr bool IsArray= false;
174 static void Write( Placeholder& box, long double const & value ) {
175 const char* src = reinterpret_cast<const char*>( &value );
176 char* dest= reinterpret_cast< char*>( &box );
177 for (int i = 0; i < ALIB_SIZEOF_LONGDOUBLE_WRITTEN; ++i)
178 *dest++= *src++;
179 }
180
181 static long double Read (const Placeholder& placeholder) {
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
267
270ALIB_BOXING_VTABLE_DECLARE( alib::time::Ticks::Duration , vt_time_ticks_duration )
272ALIB_BOXING_VTABLE_DECLARE( alib::time::DateTime::Duration , vt_time_datetime_duration )
273#if !ALIB_SINGLE_THREADED
275#endif
276
277#if ALIB_STRINGS
278ALIB_BOXING_VTABLE_DECLARE( std::reference_wrapper<alib::strings::TAString<nchar ALIB_COMMA lang::HeapAllocator>>, vt_alib_wrapped_tanstring )
279ALIB_BOXING_VTABLE_DECLARE( std::reference_wrapper<alib::strings::TAString<wchar ALIB_COMMA lang::HeapAllocator>>, vt_alib_wrapped_tawstring )
280ALIB_BOXING_VTABLE_DECLARE( std::reference_wrapper<alib::strings::TAString<xchar ALIB_COMMA lang::HeapAllocator>>, vt_alib_wrapped_taxstring )
281
283#endif
284
285#endif //DOXYGEN
#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:497
#define ALIB_SIZEOF_LONGDOUBLE_WRITTEN
Definition prepro.dox.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.
LineFeeds
Denotes line-feed encoding sequences "\n" and "\r\n".
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.
boxing::TBoxes< lang::HeapAllocator > Boxes
Type alias in namespace alib.
Definition boxes.inl:189
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
boxing::TBoxes< MonoAllocator > BoxesMA
Type alias in namespace alib.
Definition boxes.inl:193
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.