ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
boxing.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2024 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
8
9#if !defined(ALIB_DOX)
10# if !defined(HPP_ALIB_BOXING_BOXING)
11# include "alib/boxing/boxing.hpp"
12# endif
13
14# if !defined(HPP_ALIB_CHARACTERS_CHARARRAY)
16# endif
17
18# if ALIB_MONOMEM && !defined(HPP_ALIB_MONOMEM_MONOALLOCATOR)
20# endif
21
22# if ALIB_DEBUG && !defined (HPP_ALIB_BOXING_DBGBOXING)
24# endif
25
26# if ALIB_ENUMS && ALIB_STRINGS
27# if !defined(HPP_ALIB_ENUMS_SERIALIZATION)
29# endif
30# if !defined(HPP_ALIB_STRINGS_UTIL_TOKEN)
32# endif
33# endif
34
35
36# if ALIB_STRINGS
37# if !defined (HPP_ALIB_STRINGS_ASTRING)
39# endif
40# if !defined(HPP_ALIB_STRINGS_NUMBERFORMAT)
42# endif
43# if !defined (HPP_ALIB_STRINGS_FORMAT)
45# endif
46# if !defined(HPP_ALIB_STRINGS_UTIL_TOKEN)
48# endif
49# endif
50
51# if ALIB_CAMP
52# if !defined(HPP_ALIB_LANG_COMMONENUMS)
54# endif
55# endif
56
57# if !defined (_GLIBCXX_CMATH) && !defined (_CMATH_)
58# include <cmath>
59# endif
60
61# if !defined(_GLIBCXX_FUNCTIONAL) && !defined(_FUNCTIONAL_)
62 #include <functional>
63# endif
64#endif // !defined(ALIB_DOX)
65
66
67#if ALIB_STRINGS
68 ALIB_BOXING_VTABLE_DEFINE( std::reference_wrapper<alib::strings::TAString<nchar>>, vt_alib_wrapped_tanstring )
69 ALIB_BOXING_VTABLE_DEFINE( std::reference_wrapper<alib::strings::TAString<wchar>>, vt_alib_wrapped_tawstring )
70 ALIB_BOXING_VTABLE_DEFINE( std::reference_wrapper<alib::strings::TAString<xchar>>, vt_alib_wrapped_taxstring )
71#endif
72
74namespace alib {
75
76/** ************************************************************************************************
77 * This is the reference documentation of sub-namespace \c boxing of the \aliblink, which
78 * holds types of library module \alib_boxing.
79 *
80 * Extensive documentation for this module is provided with
81 * \ref alib_mod_boxing "ALib Module Boxing - Programmer's Manual".
82 **************************************************************************************************/
83namespace boxing {
84
85// #################################################################################################
86// #################################################################################################
87// class Box
88// #################################################################################################
89// #################################################################################################
90
91#if ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
92 bool Box::IsSignedIntegral() const
93 {
94 #if ALIB_SIZEOF_INTEGER == 8
95 return IsType< int64_t >()
97 #else
98 return IsType< int32_t >()
100 #endif
104 }
105
106 bool Box::IsUnsignedIntegral() const
107 {
108 #if ALIB_SIZEOF_INTEGER == 8
109 return IsType<uint64_t >()
111 #else
112 return IsType<uint32_t >()
114 #endif
118 }
119
121 {
122 #if ALIB_SIZEOF_INTEGER == 8
123 return IsType< int64_t >() ? ( Unbox< int64_t >() )
124 : IsType< int32_t >() ? static_cast< integer>( Unbox< int32_t >() )
125 #else
126 return IsType< int32_t >() ? ( Unbox< int32_t >() )
127 : IsType< int64_t >() ? static_cast< integer>( Unbox< int64_t >() )
128 #endif
129 : IsType< int8_t >() ? static_cast< integer>( Unbox< int8_t >() )
130 : IsType< int16_t >() ? static_cast< integer>( Unbox< int16_t >() )
132 }
133
134
136 {
137 #if ALIB_SIZEOF_INTEGER == 8
138 return IsType<uint64_t >() ? ( Unbox<uint64_t >() )
140 #else
141 return IsType<uint32_t >() ? ( Unbox<uint32_t >() )
143 #endif
147 }
148#endif
149
150#if ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
151bool Box::IsCharacter() const
152{
153 return IsType<char >()
156 || IsType<char32_t>();
157}
158
160{
161 return IsType<char >() ? static_cast<wchar>( Unbox<char >() )
165}
166#endif
167
169{
170 return IsType< double>()
171 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
172 || IsType< float >()
173 #endif
174 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
176 #endif
177 ;
178}
179
181{
182 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
183 if( IsType< float >() ) return static_cast<double>( Unbox<float >() );
184 #endif
185
186 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
187 if( IsType<long double>() ) return static_cast<double>( Unbox<long double>() );
188 #endif
189
190 return Unbox<double>();
191}
192
193 Box::operator bool() const { return Call<FIsTrue >(); }
194bool Box::IsNotNull () const { return Call<FIsNotNull >(); }
195size_t Box::Hashcode () const { return Call<FHashcode >(); }
197void Box::Clone( monomem::MonoAllocator& memory) { Call<FClone >( memory ); } )
198
199
200}} // namespace [alib::boxing]
201
202using namespace alib::boxing;
203bool Box::operator==(const Box& rhs) const { return Call<FEquals>( rhs ); }
204bool Box::operator< (const Box& rhs) const { return Call<FIsLess>( rhs ); }
205bool Box::operator<=(const Box& rhs) const { return Call<FIsLess>( rhs ) || Call<FEquals>( rhs ); }
206bool Box::operator> (const Box& rhs) const { return !Call<FIsLess>( rhs ) && !Call<FEquals>( rhs ); }
207namespace alib { namespace boxing {
208
209
210// #################################################################################################
211// #################################################################################################
212// class Boxes
213// #################################################################################################
214// #################################################################################################
215#if ALIB_MONOMEM
217 {
218 for( auto& box : *this )
219 box.Clone( memory );
220 }
221#endif
222
223#if !defined(ALIB_DOX)
224
225namespace {
226
227// #################################################################################################
228// #################################################################################################
229// Functions
230// #################################################################################################
231// #################################################################################################
232
233
234// #################################################################################################
235// FIsNotNull
236// #################################################################################################
237bool FIsNotNull_Default( const Box& box )
238{
239 return !( (box.IsArray() && box.UnboxLength() == 0 )
240 || (box.IsPointer() && box.Data().Pointers.CVoid == nullptr )
241 );
242}
243
244
245// #################################################################################################
246// FHashcode
247// #################################################################################################
248std::size_t FHashcode_Default( const Box& self )
249{
250 if( self.IsPointer() )
251 {
252 return static_cast<size_t>(0xa814e72cUL)
253 + static_cast<size_t>( self.TypeID().hash_code() )
254 + self.Data().Integrals.UInt * 89047023;
255 }
256
257 if( self.IsEnum() )
258 {
259 return static_cast<size_t>(0x49a024efUL)
260 + static_cast<size_t>( self.TypeID().hash_code() )
261 + self.Data().Integrals.UInt * 79204799;
262 }
263
264 if( self.IsArray() )
265 {
266 std::size_t result= 0xa925eb91L
267 + std::size_t( self.ElementTypeID().hash_code() );
268
269 // do different loops depending on array element size
270 auto size = self.ArrayElementSize();
271 auto length= self.UnboxLength();
272 if( size == 2 || size == 6 )
273 {
274 if (size == 6)
275 length*= 3;
276
277 uint16_t* array= self.Data().Pointer<uint16_t>();
278 for( integer i= 0 ; i < length ; ++i )
279 result = 67 * result + array[i];
280
281 return static_cast<size_t>( result );
282 }
283
284 if( size == 4 )
285 {
286 uint32_t* array= self.Data().Pointer<uint32_t>();
287 for( integer i= 0 ; i < length ; ++i )
288 result = 67*result + array[i];
289
290 return static_cast<size_t>( result );
291 }
292
293 if( size == 8 )
294 {
295 uint64_t* array= self.Data().Pointer<uint64_t>();
296 for( integer i= 0 ; i < length ; ++i )
297 result = std::size_t( 67 * result + array[i] );
298
299 return std::size_t( result );
300 }
301
302 // any other size
303 {
304 length*= size;
305 unsigned char* array= self.Data().Pointer<unsigned char>();
306 for( int i= 0 ; i < length ; ++i )
307 result = 67*result + array[i];
308
309 return static_cast<size_t>( result );
310 }
311 }
312
313 //--- default (value types) ---
314 size_t result= static_cast<size_t>(0xcf670957UL)
315 + static_cast<size_t>( self.TypeID().hash_code() );
316
317 unsigned int usedLen= self.GetPlaceholderUsageLength();
318
319 constexpr uinteger Bit1= static_cast<uinteger>( 1 );
320
321 // smaller than first "word"
322 if( usedLen < sizeof( uinteger ) )
323 return static_cast<size_t>( ( self.Data().GetUInteger(0)
324 & ((Bit1 << (usedLen * 8) )- 1) ) * 32194735 )
325 + result;
326
327 // add first word
328 result+= self.Data().GetUInteger(0) * 32194735;
329
330 if( usedLen == sizeof(uinteger) )
331 return result;
332
333 // tests if smaller than second "word"
334 if( usedLen - sizeof( uinteger ) < sizeof( uinteger ) )
335 {
336 return static_cast<size_t>( ( self.Data().GetUInteger(1)
337 & ((Bit1 << ((usedLen - sizeof(uinteger)) * 8) )- 1) ) * 321947 )
338 + result;
339 }
340
341 return result + self.Data().GetUInteger(1) * 321947;
342
343
344}
345
346// #################################################################################################
347// FEquals
348// #################################################################################################
349bool FEquals_Default( const Box& self, const Box& rhs )
350{
351 if( !self.IsSameType( rhs ) )
352 return false;
353
354 // array types?
355 if( self.IsArray() )
356 {
357 // different in type, length or nulled?
358 if( self.UnboxLength() != rhs.UnboxLength()
359 || ( ( self.Data().Pointer<char>() == nullptr)
360 != ( rhs .Data().Pointer<char>() == nullptr ) ) )
361 return false;
362
363 return self.Data().Pointer<char>() == nullptr
364 || self.UnboxLength() == 0
365 || self.Data().Pointer<char>() == rhs.Data().Pointer<char>()
366 || memcmp( self.Data().Pointer<char>(),
367 rhs .Data().Pointer<char>(),
368 static_cast <size_t>( self.UnboxLength() ) * self.ArrayElementSize()
369 ) == 0;
370 }
371
372 // non-array types
373 unsigned int usedLen= self.GetPlaceholderUsageLength();
374
375 constexpr uinteger Bit1= static_cast<uinteger>( 1 );
376 // tests if smaller than first "word"
377 if( usedLen < sizeof( uinteger ) )
378 {
379 uinteger mask= (Bit1 << (usedLen * 8) )- 1;
380 return ( self.Data().GetUInteger(0) & mask )
381 == ( rhs .Data().GetUInteger(0) & mask );
382 }
383
384 // test first word
385 if( self.Data().GetUInteger(0) != rhs.Data().GetUInteger(0) )
386 return false;
387
388 if( usedLen == sizeof( uinteger ) )
389 return true;
390
391 // tests if smaller than second "word"
392 if( usedLen - sizeof( uinteger ) < sizeof( uinteger ) )
393 {
394 uinteger mask= (Bit1 << (usedLen - sizeof(uinteger)) * 8 )- 1;
395 return ( self.Data().GetUInteger(1) & mask )
396 == ( rhs .Data().GetUInteger(1) & mask );
397 }
398
399 return self.Data().GetUInteger(1) == rhs.Data().GetUInteger(1);
400}
401
402
403bool FEquals_double( const Box& self, const Box& rhsBox )
404{
405 double lhs= self.UnboxFloatingPoint();
406 double rhs;
407 if( rhsBox.IsFloatingPoint () ) rhs= rhsBox.UnboxFloatingPoint () ;
408 else if( rhsBox.IsSignedIntegral () ) rhs= static_cast<double>( rhsBox.UnboxSignedIntegral () );
409 else if( rhsBox.IsUnsignedIntegral() ) rhs= static_cast<double>( rhsBox.UnboxUnsignedIntegral() );
410 else return false;
411
412 // we can ignore this warning, because we fixed it with the second test
413 #if defined(__clang__)
414 #pragma clang diagnostic push
415 #pragma clang diagnostic ignored "-Wfloat-equal"
416 #endif
417
418 return lhs == rhs
419 // take rounding errors into account.
420 // We use the "float-epsilon" and double it to be even a little weaker!
421 || std::fabs( lhs - rhs ) <= static_cast<double>( 2.0f * std::numeric_limits<float>::epsilon() );
422
423 #if defined(__clang__)
424 #pragma clang diagnostic pop
425 #endif
426}
427
428bool FEquals_integer( const Box& self, const Box& rhsBox )
429{
430 if( rhsBox.IsFloatingPoint() )
431 return FEquals_double( rhsBox, self );
432
433 integer rhs;
434 if( rhsBox.IsSignedIntegral () ) rhs= rhsBox.UnboxSignedIntegral () ;
435 else if( rhsBox.IsUnsignedIntegral() ) rhs= static_cast< integer>( rhsBox.UnboxUnsignedIntegral() );
436 else return false;
437
438 return self.UnboxSignedIntegral() == rhs;
439}
440
441bool FEquals_uinteger( const Box& self, const Box& rhsBox )
442{
443 if( rhsBox.IsFloatingPoint() )
444 return FEquals_double( rhsBox, self );
445
446 uinteger rhs;
447 if( rhsBox.IsSignedIntegral () ) rhs= static_cast<uinteger>( rhsBox.UnboxSignedIntegral () );
448 else if( rhsBox.IsUnsignedIntegral() ) rhs= rhsBox.UnboxUnsignedIntegral() ;
449 else return false;
450
451 return self.UnboxUnsignedIntegral() == rhs;
452}
453
454bool FEquals_char( const Box& self, const Box& rhs )
455{
456 if( !rhs.IsCharacter() )
457 return false;
458 return self.UnboxCharacter() == rhs.UnboxCharacter();
459}
460
461
462template<typename TChar>
463bool FEquals_TChar_Arr( const Box& lhs, const Box& rhs )
464{
465 if ( !rhs.IsArrayOf<TChar>() )
466 return false;
467
468 const TChar* compBuf= rhs.Data().Pointer<TChar>();
469 const TChar* boxBuf= lhs.Data().Pointer<TChar>();
470 if ( (boxBuf == nullptr) != (compBuf == nullptr) )
471 return false;
472
473 integer compLen= rhs.UnboxLength();
474 integer boxLen= lhs.UnboxLength();
475 if ( boxLen != compLen )
476 return false;
477
478 return 0 == characters::CharArray<TChar>::Compare ( boxBuf, compBuf, boxLen );
479}
480
481// #################################################################################################
482// FIsLess
483// #################################################################################################
484bool FIsLess_Default( const Box& box, const Box& comp )
485{
486 return std::type_index( box.TypeID() ) < std::type_index(comp.TypeID() )
487 || ( box.TypeID() == comp.TypeID()
488 &&box.Data().GetUInteger(0) < comp.Data().GetUInteger(0) );
489
490}
491
492#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
493bool FIsLess_integer( const Box& self, const Box& rhs )
494{
495 auto lhs= self.Data().GetInteger(0);
496 if( rhs.IsSameType( self ) ) return lhs < rhs.Unbox<integer > () ;
497 if( rhs.IsType<uinteger>() ) return lhs < static_cast<integer> ( rhs.Unbox<uinteger> () );
498 if( rhs.IsFloatingPoint() ) return static_cast<double> ( lhs ) < rhs.UnboxFloatingPoint();
499
500 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
501}
502
503bool FIsLess_uinteger( const Box& self, const Box& rhs )
504{
505 auto lhs= self.Data().GetUInteger(0);
506 if( rhs.IsSameType( self ) ) return lhs < rhs.Data().GetUInteger(0) ;
507 if( rhs.IsType<integer> () ) return static_cast<integer> ( lhs ) < rhs.Unbox<integer>();
508 if( rhs.IsFloatingPoint() ) return static_cast<double > ( lhs ) < rhs.UnboxFloatingPoint();
509
510 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
511}
512
513#else
514
515bool helperBijectiveLessS( integer selfVal, const Box& selfType, const Box& rhs )
516{
517 if( rhs.IsSignedIntegral () ) return selfVal < rhs.UnboxSignedIntegral () ;
518 if( rhs.IsUnsignedIntegral() ) return selfVal < static_cast< integer>( rhs.UnboxUnsignedIntegral() );
519 if( rhs.IsFloatingPoint () ) return static_cast<double>( selfVal ) < rhs.UnboxFloatingPoint () ;
520
521 // no number?
522 return std::type_index( selfType.TypeID() ) < std::type_index( rhs.TypeID() );
523}
524
525bool helperBijectiveLessU( uinteger selfVal, const Box& selfType, const Box& rhs )
526{
527 if( rhs.IsSignedIntegral () ) return selfVal < static_cast<uinteger>( rhs.UnboxSignedIntegral () );
528 if( rhs.IsUnsignedIntegral() ) return selfVal < rhs.UnboxUnsignedIntegral() ;
529 if( rhs.IsFloatingPoint () ) return static_cast<double>( selfVal ) < rhs.UnboxFloatingPoint () ;
530
531 // no number?
532 return std::type_index( selfType.TypeID() ) < std::type_index( rhs.TypeID() );
533}
534
535bool FIsLess_int8_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessS( static_cast< integer>( self.Unbox< int8_t >() ), self, rhs ); }
536bool FIsLess_int16_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessS( static_cast< integer>( self.Unbox< int16_t >() ), self, rhs ); }
537bool FIsLess_int32_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessS( static_cast< integer>( self.Unbox< int32_t >() ), self, rhs ); }
538bool FIsLess_int64_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessS( static_cast< integer>( self.Unbox< int64_t >() ), self, rhs ); }
539bool FIsLess_intGap_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessS( static_cast< integer>( self.Unbox< intGap_t>() ), self, rhs ); }
540
541bool FIsLess_uint8_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessU( static_cast<uinteger>( self.Unbox<uint8_t >() ), self, rhs ); }
542bool FIsLess_uint16_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessU( static_cast<uinteger>( self.Unbox<uint16_t >() ), self, rhs ); }
543bool FIsLess_uint32_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessU( static_cast<uinteger>( self.Unbox<uint32_t >() ), self, rhs ); }
544bool FIsLess_uint64_t ( const Box& self, const Box& rhs ) { return helperBijectiveLessU( static_cast<uinteger>( self.Unbox<uint64_t >() ), self, rhs ); }
545bool FIsLess_uintGap_t( const Box& self, const Box& rhs ) { return helperBijectiveLessU( static_cast<uinteger>( self.Unbox<uintGap_t>() ), self, rhs ); }
546
547#endif
548
549bool FIsLess_char( const Box& self, const Box& rhs )
550{
551 if( rhs.IsCharacter () )
552 return self.UnboxCharacter() < rhs.UnboxCharacter () ;
553
554 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
555}
556
557
558
559bool FIsLess_double( const Box& self, const Box& rhs )
560{
561 double lhs= self.Unbox<double>();
562 if( rhs.IsFloatingPoint () ) return lhs < rhs.UnboxFloatingPoint () ;
563 if( rhs.IsSignedIntegral () ) return lhs < static_cast<double> ( rhs.UnboxSignedIntegral () );
564 if( rhs.IsUnsignedIntegral() ) return lhs < static_cast<double> ( rhs.UnboxUnsignedIntegral() );
565
566 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
567}
568
569#if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
570 bool FIsLess_float( const Box& self, const Box& rhs )
571 {
572 float lhs= self.Unbox<float>();
573 if( rhs.IsType<float >() ) return lhs < rhs.Unbox<float >() ;
574 if( rhs.IsType<double >() ) return lhs < static_cast<float> ( rhs.Unbox<double>() );
575 if( rhs.IsSignedIntegral () ) return lhs < static_cast<float> ( rhs.UnboxSignedIntegral () );
576 if( rhs.IsUnsignedIntegral() ) return lhs < static_cast<float> ( rhs.UnboxUnsignedIntegral() );
577
578 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
579 }
580#endif
581
582
583
584// #################################################################################################
585// FClone
586// #################################################################################################
587#if ALIB_MONOMEM
588
589void FClone_Default( Box& self, monomem::MonoAllocator& memory)
590{
591 if ( !self.IsArray() || self.UnboxLength() == 0)
592 return;
593
594 Placeholder& placeHolder= self.Data();
595 auto* src= placeHolder.Pointer<char>();
596 if( src== nullptr || placeHolder.GetInteger(1) < 0 )
597 return;
598
599 size_t alignment= self.ArrayElementSize();
600 if( alignment > sizeof(std::ptrdiff_t) )
601 alignment= sizeof(std::ptrdiff_t);
602
603
604 placeHolder.Pointer( memory.Alloc( self.ArrayElementSize() * placeHolder.GetUInteger(1) ,
605 alignment ) );
606 memcpy( placeHolder.Pointer<char>(), src, self.ArrayElementSize() * placeHolder.GetUInteger(1) );
607}
608
609#endif
610
611// #################################################################################################
612// FIsTrue
613// #################################################################################################
614bool FIsTrue_Default( const Box& self )
615{
616 if( self.IsArray() )
617 return self.UnboxLength() != 0;
618
619 // non-array types
620 unsigned int usedLen= self.GetPlaceholderUsageLength();
621
622 constexpr uinteger Bit1= static_cast<uinteger>( 1 );
623 // tests if smaller than first "word"
624 if( usedLen < sizeof( uinteger ) )
625 return ( self.Data().GetUInteger(0)
626 & ((Bit1 << (usedLen * 8) )- 1) ) != 0;
627
628 // test first word
629 if( self.Data().GetUInteger(0) != 0 )
630 return true;
631
632 if( usedLen == sizeof( uinteger ) )
633 return false;
634
635 // tests if smaller than second "word"
636 if( usedLen - sizeof( uinteger ) < sizeof( uinteger ) )
637 {
638 return ( self.Data().GetUInteger(1)
639 & ((Bit1 << (usedLen - sizeof(uinteger)) * 8 )- 1) ) != 0;
640 }
641
642 return self.Data().GetUInteger(1) != 0;
643}
644
645
646// #################################################################################################
647// ############################ Strings And Boxing #####################################
648// #################################################################################################
649#if ALIB_STRINGS
650
651template<typename TChar>
652bool FIsLess_TChar_arr( const Box& lhs, const Box& rhs )
653{
654 if( rhs.IsArrayOf<TChar>() )
656
657 return std::type_index( lhs.TypeID() ) < std::type_index(rhs.TypeID() );
658}
659
660
661template<typename TChar>
662void FAppend_Default( const Box& self, strings::TAString<TChar>& target)
663{
664 if( self.IsPointer() )
665 {
666 target << ALIB_REL_DBG( "PointerType", self.TypeID() )
668 << typename strings::TFormat<TChar>::Hex( self.Data().Integrals.UInt )
669 << ')';
670 return;
671 }
672
673 if( self.IsEnum() )
674 {
675 target << ALIB_REL_DBG( "EnumType", self.TypeID() ) << '(' << self.Data().Integrals.Int << ')';
676 return;
677 }
678
679 if( self.IsArray() )
680 {
681 target << ALIB_REL_DBG( "ArrayType", self.ElementTypeID() ) << '[' << self.UnboxLength() << ']';
682 return;
683 }
684
685 // value type
686 target << ALIB_REL_DBG( "ValueType", self.TypeID() ) << "(Size: " << self.GetPlaceholderUsageLength() << " bytes)";
687}
688
689
690template<typename TCharSrc, typename TChar>
691void FAppend_TcharArr( const Box& box, strings::TAString<TChar>& target )
692{
693 target.template Append<false>( box.UnboxArray<TCharSrc>(), box.UnboxLength() );
694}
695
696#endif
697
698
699} // anonymous namespace
700
701#endif // !defined(ALIB_DOX)
702
703
704// #################################################################################################
705// Non-anonymous functions
706// #################################################################################################
707
709{
710 return false;
711}
712
713
714// static member definition
715
716// #################################################################################################
717// Bootstrap()
718// #################################################################################################
719#if !defined(ALIB_DOX)
720namespace{ unsigned int initFlag= 0; }
721#endif // !defined(ALIB_DOX)
722
723#if ALIB_DEBUG && !defined(ALIB_DOX)
724 // This is used by boxing::Bootstrap to do runtime-check for compatibility of boxing
725 // and long double values.
726 // It was moved to file boxes.cpp to prevent the compiler to optimize and remove the code.
727 extern long double dbgLongDoubleWriteTestMem[2];
728 extern void dbgLongDoubleTrueLengthSet();
729 extern bool dbgLongDoubleTrueLengthTest();
730#endif
731
733{
734 ALIB_ASSERT_ERROR( initFlag != 2, "BOXING", "Can't bootstrap after termination" )
735 if( initFlag == 0x92A3EF61 )
736 return;
737 initFlag= 0x92A3EF61;
738
739 //############### Debug-compilation checks ################
740 #if ALIB_DEBUG
741 // check size of long double
742 {
743 dbgLongDoubleTrueLengthSet();
744 dbgLongDoubleWriteTestMem[0]= 0.0L;
745 ALIB_ASSERT_ERROR( dbgLongDoubleTrueLengthTest(), "BOXING",
746 "Platform not supported. Template specialization T_SizeInPlaceholder<long double> contains wrong size" )
747 }
748 #endif
749
750 //############################# BootstrapRegister Static VTables #################################
754
755DOX_MARKER([DOX_ALIB_BOXING_OPTIMIZE_REGISTER_1])
757DOX_MARKER([DOX_ALIB_BOXING_OPTIMIZE_REGISTER_1])
758
759 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
762 #else
771 #if ALIB_SIZEOF_INTEGER == 8
774 #endif
775 #endif // !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
776
777
779 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
781 #endif
782 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
784 #endif
785
786
787 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
789 #else
794 #endif
795
796DOX_MARKER([DOX_ALIB_BOXING_OPTIMIZE_REGISTER_2])
798DOX_MARKER([DOX_ALIB_BOXING_OPTIMIZE_REGISTER_2])
799
803
804 // Static VTables for standard types
806
807 // CodeMarker_CommonEnums
808 // Static VTables for low-level ALib types
809 #if !defined(HPP_ALIB_LANG_COMMONENUMS_DEFS)
814 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_ContainerOp )
815 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_CreateDefaults )
816 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_CreateIfNotExists )
817 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_CurrentData )
819 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_Initialization )
821 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_Propagation )
823 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_Responsibility )
831 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_ValueReference )
832 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_Whitespaces )
833 #endif
834
835 #if ALIB_STRINGS
836 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_wrapped_tanstring )
837 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_wrapped_tawstring )
838 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_wrapped_taxstring )
839 ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( vt_alib_strings_token )
840 #endif
841
842 //######################## Register default implementations #######################
843 BootstrapRegisterDefault<FIsTrue >( FIsTrue_Default );
844 BootstrapRegisterDefault<FIsNotNull >( FIsNotNull_Default );
845 BootstrapRegisterDefault<FIsLess >( FIsLess_Default );
846 BootstrapRegisterDefault<FHashcode >( FHashcode_Default );
847 BootstrapRegisterDefault<FEquals >( FEquals_Default );
849 BootstrapRegisterDefault<FClone >( FClone_Default ); )
850
851 // ################################ IsNotNull ##########################################
853 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
854 BootstrapRegister<FIsNotNull, TMappedTo< integer >>( FIsNotNull::ConstantTrue );
855 BootstrapRegister<FIsNotNull, TMappedTo<uinteger >>( FIsNotNull::ConstantTrue );
856 #else
857 BootstrapRegister<FIsNotNull, TMappedTo< int8_t >>( FIsNotNull::ConstantTrue );
858 BootstrapRegister<FIsNotNull, TMappedTo<uint8_t >>( FIsNotNull::ConstantTrue );
859 BootstrapRegister<FIsNotNull, TMappedTo< int16_t >>( FIsNotNull::ConstantTrue );
860 BootstrapRegister<FIsNotNull, TMappedTo<uint16_t >>( FIsNotNull::ConstantTrue );
861 BootstrapRegister<FIsNotNull, TMappedTo< int32_t >>( FIsNotNull::ConstantTrue );
862 BootstrapRegister<FIsNotNull, TMappedTo<uint32_t >>( FIsNotNull::ConstantTrue );
863 BootstrapRegister<FIsNotNull, TMappedTo< int64_t >>( FIsNotNull::ConstantTrue );
864 BootstrapRegister<FIsNotNull, TMappedTo<uint64_t >>( FIsNotNull::ConstantTrue );
865 BootstrapRegister<FIsNotNull, TMappedTo< intGap_t >>( FIsNotNull::ConstantTrue );
866 BootstrapRegister<FIsNotNull, TMappedTo<uintGap_t >>( FIsNotNull::ConstantTrue );
867 #endif
868
869 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
870 BootstrapRegister<FIsNotNull, TMappedTo<wchar >>( FIsNotNull::ConstantTrue );
871 #else
872 BootstrapRegister<FIsNotNull, TMappedTo<char >>( FIsNotNull::ConstantTrue );
873 BootstrapRegister<FIsNotNull, TMappedTo<wchar_t >>( FIsNotNull::ConstantTrue );
874 BootstrapRegister<FIsNotNull, TMappedTo<char16_t >>( FIsNotNull::ConstantTrue );
875 BootstrapRegister<FIsNotNull, TMappedTo<char32_t >>( FIsNotNull::ConstantTrue );
876 #endif
877
878
879 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
880 BootstrapRegister<FIsNotNull, TMappedTo<float >>( FIsNotNull::ConstantTrue );
881 #endif
882 BootstrapRegister<FIsNotNull, TMappedTo<double >>( FIsNotNull::ConstantTrue );
883
884 // ################################ Hashcode ##########################################
885 BootstrapRegister<FHashcode, TMappedTo<bool >>( FHashcode::UsePlaceholderBytes<sizeof(bool )> );
886 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
887 BootstrapRegister<FHashcode, TMappedTo< integer >>( FHashcode::UsePlaceholderBytes<sizeof( integer )> );
888 BootstrapRegister<FHashcode, TMappedTo<uinteger >>( FHashcode::UsePlaceholderBytes<sizeof(uinteger )> );
889 #else
890 BootstrapRegister<FHashcode, TMappedTo< int8_t >>( FHashcode::UsePlaceholderBytes<sizeof( int8_t )> );
891 BootstrapRegister<FHashcode, TMappedTo<uint8_t >>( FHashcode::UsePlaceholderBytes<sizeof(uint8_t )> );
892 BootstrapRegister<FHashcode, TMappedTo< int16_t >>( FHashcode::UsePlaceholderBytes<sizeof( int16_t )> );
893 BootstrapRegister<FHashcode, TMappedTo<uint16_t >>( FHashcode::UsePlaceholderBytes<sizeof(uint16_t )> );
894 BootstrapRegister<FHashcode, TMappedTo< int32_t >>( FHashcode::UsePlaceholderBytes<sizeof( int32_t )> );
895 BootstrapRegister<FHashcode, TMappedTo<uint32_t >>( FHashcode::UsePlaceholderBytes<sizeof(uint32_t )> );
896 BootstrapRegister<FHashcode, TMappedTo< int64_t >>( FHashcode::UsePlaceholderBytes<sizeof( int64_t )> );
897 BootstrapRegister<FHashcode, TMappedTo<uint64_t >>( FHashcode::UsePlaceholderBytes<sizeof(uint64_t )> );
898 BootstrapRegister<FHashcode, TMappedTo< intGap_t >>( FHashcode::UsePlaceholderBytes<sizeof( intGap_t)> );
899 BootstrapRegister<FHashcode, TMappedTo<uintGap_t >>( FHashcode::UsePlaceholderBytes<sizeof(uintGap_t)> );
900 #endif
901
902 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
903 BootstrapRegister<FHashcode, TMappedTo<wchar >>( FHashcode::UsePlaceholderBytes<sizeof(wchar )> );
904 #else
905 BootstrapRegister<FHashcode, TMappedTo<char >>( FHashcode::UsePlaceholderBytes<sizeof(char )> );
906 BootstrapRegister<FHashcode, TMappedTo<wchar_t >>( FHashcode::UsePlaceholderBytes<sizeof(wchar_t )> );
907 BootstrapRegister<FHashcode, TMappedTo<char16_t >>( FHashcode::UsePlaceholderBytes<sizeof(char16_t )> );
908 BootstrapRegister<FHashcode, TMappedTo<char32_t >>( FHashcode::UsePlaceholderBytes<sizeof(char32_t )> );
909 #endif
910
911
912 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
913 BootstrapRegister<FHashcode, TMappedTo<float >>( FHashcode::UsePlaceholderBytes<sizeof(float )> );
914 #endif
915 BootstrapRegister<FHashcode, TMappedTo<double >>( FHashcode::UsePlaceholderBytes<sizeof(double )> );
916 BootstrapRegister<FHashcode, TMappedTo<long double>>( FHashcode::UsePlaceholderBytes<
918
919
920 // ################################ Equals ###########################################
921 BootstrapRegister<FEquals , TMappedTo<bool >>( FEquals::ComparableTypes<bool> );
922
923 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
924 BootstrapRegister<FEquals , TMappedTo< integer >>( FEquals_integer );
925 BootstrapRegister<FEquals , TMappedTo<uinteger >>( FEquals_uinteger );
926 #else
927 BootstrapRegister<FEquals , TMappedTo< int8_t >>( FEquals_integer );
928 BootstrapRegister<FEquals , TMappedTo<uint8_t >>( FEquals_uinteger );
929 BootstrapRegister<FEquals , TMappedTo< int16_t >>( FEquals_integer );
930 BootstrapRegister<FEquals , TMappedTo<uint16_t >>( FEquals_uinteger );
931 BootstrapRegister<FEquals , TMappedTo< int32_t >>( FEquals_integer );
932 BootstrapRegister<FEquals , TMappedTo<uint32_t >>( FEquals_uinteger );
933 BootstrapRegister<FEquals , TMappedTo< int64_t >>( FEquals_integer );
934 BootstrapRegister<FEquals , TMappedTo<uint64_t >>( FEquals_uinteger );
935 BootstrapRegister<FEquals , TMappedTo< intGap_t >>( FEquals_integer );
936 BootstrapRegister<FEquals , TMappedTo<uintGap_t >>( FEquals_uinteger );
937 #endif
938
939 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
940 BootstrapRegister<FEquals , TMappedTo<float >>( FEquals_double );
941 #endif
942 BootstrapRegister<FEquals , TMappedTo<double >>( FEquals_double );
943 BootstrapRegister<FEquals , TMappedTo<long double>>( FEquals_double );
944
945
946 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
947 BootstrapRegister<FEquals , TMappedTo<wchar >>( FEquals_char );
948 #else
949 BootstrapRegister<FEquals , TMappedTo<char >>( FEquals_char );
950 BootstrapRegister<FEquals , TMappedTo<wchar_t >>( FEquals_char );
951 BootstrapRegister<FEquals , TMappedTo<char16_t >>( FEquals_char );
952 BootstrapRegister<FEquals , TMappedTo<char32_t >>( FEquals_char );
953 #endif
954
955 BootstrapRegister<FEquals , TMappedToArrayOf<nchar>>( FEquals_TChar_Arr<nchar>);
956 BootstrapRegister<FEquals , TMappedToArrayOf<wchar>>( FEquals_TChar_Arr<wchar>);
957 BootstrapRegister<FEquals , TMappedToArrayOf<xchar>>( FEquals_TChar_Arr<xchar>);
958
959 // ################################ IsLess ###########################################
960 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
961 BootstrapRegister<FIsLess , TMappedTo< integer >>( FIsLess_integer );
962 BootstrapRegister<FIsLess , TMappedTo<uinteger >>( FIsLess_uinteger);
963 #else
964 BootstrapRegister<FIsLess , TMappedTo< int8_t >>( FIsLess_int8_t );
965 BootstrapRegister<FIsLess , TMappedTo<uint8_t >>( FIsLess_uint8_t );
966 BootstrapRegister<FIsLess , TMappedTo< int16_t >>( FIsLess_int16_t );
967 BootstrapRegister<FIsLess , TMappedTo<uint16_t >>( FIsLess_uint16_t );
968 BootstrapRegister<FIsLess , TMappedTo< int32_t >>( FIsLess_int32_t );
969 BootstrapRegister<FIsLess , TMappedTo<uint32_t >>( FIsLess_uint32_t );
970 BootstrapRegister<FIsLess , TMappedTo< int64_t >>( FIsLess_int64_t );
971 BootstrapRegister<FIsLess , TMappedTo<uint64_t >>( FIsLess_uint64_t );
972 BootstrapRegister<FIsLess , TMappedTo< intGap_t >>( FIsLess_intGap_t );
973 BootstrapRegister<FIsLess , TMappedTo<uintGap_t >>( FIsLess_uintGap_t);
974 #endif
975
976 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
977 BootstrapRegister<FIsLess , TMappedTo<float >>( FIsLess_float );
978 #endif
979 BootstrapRegister<FIsLess , TMappedTo<double >>( FIsLess_double );
980 BootstrapRegister<FIsLess , TMappedTo<long double>>( FIsLess_double );
981
982 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
983 BootstrapRegister<FIsLess , TMappedTo<wchar >>( FIsLess_char );
984 #else
985 BootstrapRegister<FIsLess , TMappedTo<char >>( FIsLess_char );
986 BootstrapRegister<FIsLess , TMappedTo<wchar_t >>( FIsLess_char );
987 BootstrapRegister<FIsLess , TMappedTo<char16_t >>( FIsLess_char );
988 BootstrapRegister<FIsLess , TMappedTo<char32_t >>( FIsLess_char );
989 #endif
990
991
992 // #############################################################################################
993 // ########################## Strings And Boxing ###################################
994 // #############################################################################################
995#if ALIB_STRINGS
996 // register functions interface implementations
997 BootstrapRegister<FIsLess, TMappedToArrayOf<nchar>>( FIsLess_TChar_arr<nchar> );
998 BootstrapRegister<FIsLess, TMappedToArrayOf<wchar>>( FIsLess_TChar_arr<wchar> );
999 BootstrapRegister<FIsLess, TMappedToArrayOf<xchar>>( FIsLess_TChar_arr<xchar> );
1000
1001 // register functions of type FAppend
1002 BootstrapRegisterDefault<FAppend<character >>( FAppend_Default<character > );
1003 BootstrapRegisterDefault<FAppend<complementChar>>( FAppend_Default<complementChar> );
1004 BootstrapRegisterDefault<FAppend<strangeChar >>( FAppend_Default<strangeChar > );
1005
1006 BootstrapRegister<FAppend<nchar>, TMappedTo<bool >>(FAppend<nchar>::Appendable< bool >);
1007 BootstrapRegister<FAppend<wchar>, TMappedTo<bool >>(FAppend<wchar>::Appendable< bool >);
1008
1009 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
1010 BootstrapRegister<FAppend<nchar>, TMappedTo<wchar >>(FAppend<nchar>::Appendable< wchar >);
1011 BootstrapRegister<FAppend<wchar>, TMappedTo<wchar >>(FAppend<wchar>::Appendable< wchar >);
1012 #else
1013 BootstrapRegister<FAppend<nchar>, TMappedTo<nchar >>(FAppend<nchar>::Appendable< nchar >);
1014 BootstrapRegister<FAppend<wchar>, TMappedTo<nchar >>(FAppend<wchar>::Appendable< nchar >);
1015 BootstrapRegister<FAppend<nchar>, TMappedTo<wchar >>(FAppend<nchar>::Appendable< wchar >);
1016 BootstrapRegister<FAppend<wchar>, TMappedTo<wchar >>(FAppend<wchar>::Appendable< wchar >);
1017 BootstrapRegister<FAppend<nchar>, TMappedTo<xchar >>(FAppend<nchar>::Appendable< xchar >);
1018 BootstrapRegister<FAppend<wchar>, TMappedTo<xchar >>(FAppend<wchar>::Appendable< xchar >);
1019 #endif
1020
1021 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
1022 BootstrapRegister<FAppend<nchar>, TMappedTo<integer >>(FAppend<nchar>::Appendable<integer >);
1023 BootstrapRegister<FAppend<wchar>, TMappedTo<integer >>(FAppend<wchar>::Appendable<integer >);
1024 BootstrapRegister<FAppend<nchar>, TMappedTo<uinteger >>(FAppend<nchar>::Appendable<uinteger >);
1025 BootstrapRegister<FAppend<wchar>, TMappedTo<uinteger >>(FAppend<wchar>::Appendable<uinteger >);
1026 #else
1027 BootstrapRegister<FAppend<nchar>, TMappedTo< int8_t >>(FAppend<nchar>::Appendable< int8_t >);
1028 BootstrapRegister<FAppend<wchar>, TMappedTo< int8_t >>(FAppend<wchar>::Appendable< int8_t >);
1029 BootstrapRegister<FAppend<nchar>, TMappedTo< int16_t >>(FAppend<nchar>::Appendable< int16_t >);
1030 BootstrapRegister<FAppend<wchar>, TMappedTo< int16_t >>(FAppend<wchar>::Appendable< int16_t >);
1031 BootstrapRegister<FAppend<nchar>, TMappedTo< int32_t >>(FAppend<nchar>::Appendable< int32_t >);
1032 BootstrapRegister<FAppend<wchar>, TMappedTo< int32_t >>(FAppend<wchar>::Appendable< int32_t >);
1033 BootstrapRegister<FAppend<nchar>, TMappedTo< int64_t >>(FAppend<nchar>::Appendable< int64_t >);
1034 BootstrapRegister<FAppend<wchar>, TMappedTo< int64_t >>(FAppend<wchar>::Appendable< int64_t >);
1035 BootstrapRegister<FAppend<nchar>, TMappedTo< intGap_t>>(FAppend<nchar>::Appendable< intGap_t>);
1036 BootstrapRegister<FAppend<wchar>, TMappedTo< intGap_t>>(FAppend<wchar>::Appendable< intGap_t>);
1037 BootstrapRegister<FAppend<nchar>, TMappedTo<uint8_t >>(FAppend<nchar>::Appendable<uint8_t >);
1038 BootstrapRegister<FAppend<wchar>, TMappedTo<uint8_t >>(FAppend<wchar>::Appendable<uint8_t >);
1039 BootstrapRegister<FAppend<nchar>, TMappedTo<uint16_t >>(FAppend<nchar>::Appendable<uint16_t >);
1040 BootstrapRegister<FAppend<wchar>, TMappedTo<uint16_t >>(FAppend<wchar>::Appendable<uint16_t >);
1041 BootstrapRegister<FAppend<nchar>, TMappedTo<uint32_t >>(FAppend<nchar>::Appendable<uint32_t >);
1042 BootstrapRegister<FAppend<wchar>, TMappedTo<uint32_t >>(FAppend<wchar>::Appendable<uint32_t >);
1043 BootstrapRegister<FAppend<nchar>, TMappedTo<uint64_t >>(FAppend<nchar>::Appendable<uint64_t >);
1044 BootstrapRegister<FAppend<wchar>, TMappedTo<uint64_t >>(FAppend<wchar>::Appendable<uint64_t >);
1045 BootstrapRegister<FAppend<nchar>, TMappedTo<uintGap_t>>(FAppend<nchar>::Appendable<uintGap_t>);
1046 BootstrapRegister<FAppend<wchar>, TMappedTo<uintGap_t>>(FAppend<wchar>::Appendable<uintGap_t>);
1047 #endif
1048
1049 BootstrapRegister<FAppend<nchar>, TMappedTo<double>>(FAppend<nchar>::Appendable<double>);
1050 BootstrapRegister<FAppend<wchar>, TMappedTo<double>>(FAppend<wchar>::Appendable<double>);
1051 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
1052 BootstrapRegister<FAppend<nchar>, TMappedTo<float >>(FAppend<nchar>::Appendable<float >);
1053 BootstrapRegister<FAppend<wchar>, TMappedTo<float >>(FAppend<wchar>::Appendable<float >);
1054 #endif
1055
1056 BootstrapRegister<FAppend<nchar>, TMappedToArrayOf<nchar >>(FAppend_TcharArr<nchar, nchar>);
1057 BootstrapRegister<FAppend<nchar>, TMappedToArrayOf<wchar >>(FAppend_TcharArr<wchar, nchar>);
1058 BootstrapRegister<FAppend<nchar>, TMappedToArrayOf<xchar >>(FAppend_TcharArr<xchar, nchar>);
1059 BootstrapRegister<FAppend<wchar>, TMappedToArrayOf<nchar >>(FAppend_TcharArr<nchar, wchar>);
1060 BootstrapRegister<FAppend<wchar>, TMappedToArrayOf<wchar >>(FAppend_TcharArr<wchar, wchar>);
1061 BootstrapRegister<FAppend<wchar>, TMappedToArrayOf<xchar >>(FAppend_TcharArr<xchar, wchar>);
1062 BootstrapRegister<FAppend<xchar>, TMappedToArrayOf<nchar >>(FAppend_TcharArr<nchar, xchar>);
1063 BootstrapRegister<FAppend<xchar>, TMappedToArrayOf<wchar >>(FAppend_TcharArr<wchar, xchar>);
1064 BootstrapRegister<FAppend<xchar>, TMappedToArrayOf<xchar >>(FAppend_TcharArr<xchar, xchar>);
1065
1075
1076 // CodeMarker_CommonEnums
1077 #if ALIB_CAMP
1102 #endif
1103
1105
1106 #if ALIB_DEBUG
1108 #endif
1109
1110
1111#endif // ALIB_STRINGS
1112
1113}
1114
1115
1116// Box::dbgCheckRegistration
1117// Note: this method has to go here, to be able to check if boxing was bootstrapped already.
1118// If not, no check is performed.
1119#if ALIB_DEBUG_BOXING
1120
1122{
1123 // ERROR: A global or static instance of class Box is created and initialized to a
1124 // mapped type that uses a dynamic vtable. This is forbidden.
1125 // See chapter "12.4 Global And Static Box Instances" of the Programmer's Manual
1126 // of module ALib Boxing, for more information.
1127 assert( initFlag == 0x92A3EF61 ); // magic number
1128}
1129
1130void detail::DbgCheckRegistration( detail::VTable* vtable, bool increaseUsageCounter )
1131{
1132 if( vtable==nullptr)
1133 return;
1134
1135 if( increaseUsageCounter )
1136 ++vtable->DbgCntUsage;
1137
1138 if( initFlag== 0 || vtable->DbgProduction != detail::VTable::DbgFactoryType::Unregistered )
1139 return;
1140
1141 if( !vtable->IsArray() )
1142 {
1143 lang::DbgTypeDemangler type( vtable->Type );
1144 ALIB_ERROR( "BOXING", "Static VTable of mapped type <", type.Get(),
1145 "> not registered. Use Macro ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER with bootstrapping." )
1146 }
1147 else
1148 {
1149 lang::DbgTypeDemangler type( vtable->ElementType );
1150 ALIB_ERROR( "BOXING", "Static VTable of mapped type <", type.Get(),
1151 "[]> not registered. Use Macro ALIB_BOXING_REGISTER_MAPPED_ARRAY_TYPE with bootstrapping." )
1152 }
1153}
1154#endif
1155
1156}} // namespace [alib::boxing]
uinteger UnboxUnsignedIntegral() const
Definition box.inl:626
ALIB_API bool operator<(Box const &rhs) const
Definition boxing.cpp:204
size_t ArrayElementSize() const
Definition box.inl:929
TElementType * UnboxArray() const
Definition box.inl:948
ALIB_API bool IsNotNull() const
Definition boxing.cpp:194
bool IsPointer() const
Definition box.inl:736
wchar UnboxCharacter() const
Definition box.inl:668
integer UnboxLength() const
Definition box.inl:979
bool IsFloatingPoint() const
Definition boxing.cpp:168
bool IsSameType(const Box &other) const
Definition box.inl:761
bool IsUnsignedIntegral() const
Definition box.inl:592
ALIB_API size_t Hashcode() const
Definition boxing.cpp:195
bool IsSignedIntegral() const
Definition box.inl:574
bool IsType() const
unsigned int GetPlaceholderUsageLength() const
Definition box.inl:878
ALIB_API bool operator<=(Box const &rhs) const
Definition boxing.cpp:205
bool IsEnum() const
Definition box.inl:748
ALIB_API double UnboxFloatingPoint() const
Definition boxing.cpp:180
const std::type_info & TypeID() const
Definition box.inl:902
const std::type_info & ElementTypeID() const
Definition box.inl:917
bool IsArrayOf() const
Definition box.inl:724
const Placeholder & Data() const
Definition box.inl:843
integer UnboxSignedIntegral() const
Definition box.inl:609
ALIB_API bool operator>(Box const &rhs) const
Definition boxing.cpp:206
ALIB_API bool operator==(Box const &rhs) const
Definition boxing.cpp:203
const TUnboxable Unbox() const
bool IsArray() const
Definition box.inl:711
bool IsCharacter() const
Definition box.inl:651
ALIB_API void Clone(monomem::MonoAllocator &memory)
ALIB_API void CloneAll(monomem::MonoAllocator &memory)
Definition boxing.cpp:216
ALIB_API const char * Get()
ALIB_FORCE_INLINE char * Alloc(size_t size, size_t alignment)
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
Definition vtable.inl:490
#define ALIB_WARNINGS_RESTORE
Definition alib.hpp:715
#define ALIB_ERROR(...)
Definition alib.hpp:980
#define ALIB_IF_MONOMEM(...)
Definition alib.hpp:271
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER(Identifier)
Definition vtable.inl:506
#define ALIB_ASSERT_ERROR(cond,...)
Definition alib.hpp:984
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
Definition alib.hpp:644
#define ALIB_REL_DBG(releaseCode,...)
Definition alib.hpp:459
ALIB_API void DbgCheckRegistration(detail::VTable *vtable, bool increaseUsageCounter)
Definition boxing.cpp:1130
ALIB_API void DbgCheckIsInitialized()
Definition boxing.cpp:1121
void Bootstrap()
Definition boxing.cpp:732
void BootstrapRegister(typename TFDecl::Signature function)
Definition boxing.hpp:120
Definition alib.cpp:57
lang::uinteger uinteger
Type alias in namespace alib.
Definition integers.hpp:289
characters::wchar wchar
Type alias in namespace alib.
characters::xchar xchar
Type alias in namespace alib.
lang::intGap_t intGap_t
Type alias in namespace alib.
Definition integers.hpp:292
lang::uintGap_t uintGap_t
Type alias in namespace alib.
Definition integers.hpp:295
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:286
static size_t UsePlaceholderBytes(const Box &self)
static ALIB_API bool ConstantTrue(const Box &)
Definition boxing.cpp:708
DbgFactoryType DbgProduction
Definition vtable.inl:233
const std::type_info & Type
Definition vtable.inl:194
const std::type_info & ElementType
Definition vtable.inl:198
static int Compare(const TChar *lhs, const TChar *rhs, integer cmpLength)
TCString< TChar > HexLiteralPrefix
constexpr TReturn * Pointer() const
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE constexpr integer GetInteger(int idx) const
detail::UnionIntegrals Integrals
Collection of integrals of different sizes.
constexpr uinteger GetUInteger(int idx) const
detail::UnionPointers Pointers
Collection of void, char and character pointers.
integer Int
Signed integral of platform-dependent size.
uinteger UInt
Unsigned integral of platform-dependent size.
const void * CVoid
A constant void pointer.