10bool FIsNotNull_Default(
const Box& box ) {
11 return !( (box.IsArray() && box.UnboxLength() == 0 )
12 || (box.IsPointer() && box.Data().PointerPair.P1 ==
nullptr )
16std::size_t FHashcode_Default(
const Box& self ) {
17 if( self.IsPointer() ) {
18 return size_t(0xa814e72cUL)
19 + size_t( self.TypeID().hash_code() )
20 + self.Data().Integrals.UArray[0] * 89047023;
24 return size_t(0x49a024efUL)
25 + size_t( self.TypeID().hash_code() )
26 + self.Data().Integrals.UArray[0] * 79204799;
29 if( self.IsArray() ) {
30 std::size_t result= 0xa925eb91L
31 + std::size_t( self.ElementTypeID().hash_code() );
34 auto size = self.ArrayElementSize();
35 auto length= self.UnboxLength();
36 if( size == 2 || size == 6 ) {
40 std::span<uint16_t> array= {self.Data().GetPointer<uint16_t>(),
size_t(length) };
41 for( uint16_t v : array )
42 result = 67 * result + v;
44 return size_t( result );
48 std::span<uint32_t> array= {self.Data().GetPointer<uint32_t>(),
size_t(length) };
49 for( uint32_t v : array )
50 result = 67*result + v;
52 return size_t( result );
56 std::span<uint64_t> array= {self.Data().GetPointer<uint64_t>(),
size_t(length) };
57 for( uint64_t v : array )
58 result = std::size_t( 67 * result + v );
60 return std::size_t( result );
66 std::span<unsigned char> array= {self.Data().GetPointer<
unsigned char>(),
size_t(length) };
67 for(
unsigned char v : array )
68 result = 67 * result + v;
70 return size_t( result );
74 size_t result= size_t(0xcf670957UL)
75 + size_t( self.TypeID().hash_code() );
77 unsigned usedLen= self.GetPlaceholderUsageLength();
83 return size_t( ( self.Data().Integrals.UArray[0]
84 & ((Bit1 << (usedLen * 8) )- 1) ) * 32194735 )
88 result+= self.Data().Integrals.UArray[0] * 32194735;
95 return size_t( ( self.Data().Integrals.UArray[1]
96 & ((Bit1 << ((usedLen -
sizeof(
uinteger)) * 8) )- 1) ) * 321947 )
100 return result + self.Data().Integrals.UArray[1] * 321947;
105bool FEquals_Default(
const Box& self,
const Box& rhs ) {
106 if( !self.IsSameType( rhs ) )
110 if( self.IsArray() ) {
112 if( self.UnboxLength() != rhs.UnboxLength()
113 || ( ( self.Data().GetPointer<
char>() ==
nullptr)
114 != ( rhs .Data().GetPointer<
char>() ==
nullptr ) ) )
117 return self.Data().GetPointer<
char>() ==
nullptr
118 || self.UnboxLength() == 0
119 || self.Data().GetPointer<
char>() == rhs.Data().GetPointer<
char>()
120 || memcmp( self.Data().GetPointer<
char>(),
121 rhs .Data().GetPointer<
char>(),
122 static_cast <size_t>( self.UnboxLength() ) * self.ArrayElementSize()
127 unsigned usedLen= self.GetPlaceholderUsageLength();
131 if( usedLen <
sizeof(
uinteger ) ) {
132 uinteger mask= (Bit1 << (usedLen * 8) )- 1;
133 return ( self.Data().Integrals.UArray[0] & mask )
134 == ( rhs .Data().Integrals.UArray[0] & mask );
138 if( self.Data().Integrals.UArray[0] != rhs.Data().Integrals.UArray[0] )
147 return ( self.Data().Integrals.UArray[1] & mask )
148 == ( rhs .Data().Integrals.UArray[1] & mask );
151 return self.Data().Integrals.UArray[1] == rhs.Data().Integrals.UArray[1];
155bool FEquals_double(
const Box& self,
const Box& rhsBox ) {
156 double lhs= self.UnboxFloatingPoint();
158 if( rhsBox.IsFloatingPoint () ) rhs= rhsBox.UnboxFloatingPoint () ;
159 else if( rhsBox.IsSignedIntegral () ) rhs= double( rhsBox.UnboxSignedIntegral () );
160 else if( rhsBox.IsUnsignedIntegral() ) rhs= double( rhsBox.UnboxUnsignedIntegral() );
164 #if defined(__clang__)
165 #pragma clang diagnostic push
166 #pragma clang diagnostic ignored "-Wfloat-equal"
172 || std::fabs( lhs - rhs ) <= double( 2.0f * std::numeric_limits<float>::epsilon() );
174 #if defined(__clang__)
175 #pragma clang diagnostic pop
179bool FEquals_integer(
const Box& self,
const Box& rhsBox ) {
180 if( rhsBox.IsFloatingPoint() )
181 return FEquals_double( rhsBox, self );
184 if( rhsBox.IsSignedIntegral () ) rhs= rhsBox.UnboxSignedIntegral () ;
185 else if( rhsBox.IsUnsignedIntegral() ) rhs=
static_cast< integer>( rhsBox.UnboxUnsignedIntegral() );
188 return self.UnboxSignedIntegral() == rhs;
191bool FEquals_uinteger(
const Box& self,
const Box& rhsBox ) {
192 if( rhsBox.IsFloatingPoint() )
193 return FEquals_double( rhsBox, self );
196 if( rhsBox.IsSignedIntegral () ) rhs=
uinteger( rhsBox.UnboxSignedIntegral () );
197 else if( rhsBox.IsUnsignedIntegral() ) rhs= rhsBox.UnboxUnsignedIntegral() ;
200 return self.UnboxUnsignedIntegral() == rhs;
203bool FEquals_char(
const Box& self,
const Box& rhs ) {
204 if( !rhs.IsCharacter() )
206 return self.UnboxCharacter() == rhs.UnboxCharacter();
210template<
typename TChar>
211bool FEquals_TChar_Arr(
const Box& lhs,
const Box& rhs ) {
212 if ( !rhs.IsArrayOf<TChar>() )
215 const TChar* compBuf= rhs.Data().GetPointer<TChar>();
216 const TChar* boxBuf= lhs.Data().GetPointer<TChar>();
217 if ( (boxBuf ==
nullptr) != (compBuf ==
nullptr) )
220 integer compLen= rhs.UnboxLength();
221 integer boxLen= lhs.UnboxLength();
222 if ( boxLen != compLen )
228bool FIsLess_Default(
const Box& box,
const Box& comp ) {
229 return std::type_index( box.TypeID() ) < std::type_index(comp.TypeID() )
230 || ( box.TypeID() == comp.TypeID()
231 &&box.Data().Integrals.UArray[0] < comp.Data().Integrals.UArray[0] );
235#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
236bool FIsLess_integer(
const Box& self,
const Box& rhs ) {
237 auto lhs= self.Data().Integrals.Array[0];
238 if( rhs.IsSameType( self ) )
return lhs < rhs.Unbox<
integer > ();
240 if( rhs.IsFloatingPoint() )
return double( lhs ) < rhs.UnboxFloatingPoint();
242 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
245bool FIsLess_uinteger(
const Box& self,
const Box& rhs ) {
246 auto lhs= self.Data().Integrals.UArray[0];
247 if( rhs.IsSameType( self ) )
return lhs < rhs.Data().Integrals.UArray[0] ;
249 if( rhs.IsFloatingPoint() )
return double ( lhs ) < rhs.UnboxFloatingPoint();
251 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
256bool helperBijectiveLessS(
integer selfVal,
const Box& selfType,
const Box& rhs )
258 if( rhs.IsSignedIntegral () )
return selfVal < rhs.UnboxSignedIntegral () ;
259 if( rhs.IsUnsignedIntegral() )
return selfVal <
integer(rhs.UnboxUnsignedIntegral());
260 if( rhs.IsFloatingPoint () )
return double( selfVal ) < rhs.UnboxFloatingPoint () ;
263 return std::type_index( selfType.TypeID() ) < std::type_index( rhs.TypeID() );
266bool helperBijectiveLessU(
uinteger selfVal,
const Box& selfType,
const Box& rhs )
268 if( rhs.IsSignedIntegral () )
return selfVal <
uinteger(rhs.UnboxSignedIntegral ());
269 if( rhs.IsUnsignedIntegral() )
return selfVal < rhs.UnboxUnsignedIntegral() ;
270 if( rhs.IsFloatingPoint () )
return double(selfVal) < rhs.UnboxFloatingPoint () ;
273 return std::type_index( selfType.TypeID() ) < std::type_index( rhs.TypeID() );
276bool FIsLess_int8_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
integer( self.Unbox< int8_t >() ), self, rhs ); }
277bool FIsLess_int16_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
integer( self.Unbox< int16_t >() ), self, rhs ); }
278bool FIsLess_int32_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
integer( self.Unbox< int32_t >() ), self, rhs ); }
279bool FIsLess_int64_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
integer( self.Unbox< int64_t >() ), self, rhs ); }
280bool FIsLess_intGap_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
integer( self.Unbox<
intGap_t>() ), self, rhs ); }
282bool FIsLess_uint8_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
uinteger( self.Unbox<uint8_t >() ), self, rhs ); }
283bool FIsLess_uint16_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
uinteger( self.Unbox<uint16_t >() ), self, rhs ); }
284bool FIsLess_uint32_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
uinteger( self.Unbox<uint32_t >() ), self, rhs ); }
285bool FIsLess_uint64_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
uinteger( self.Unbox<uint64_t >() ), self, rhs ); }
286bool FIsLess_uintGap_t(
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
uinteger( self.Unbox<
uintGap_t>() ), self, rhs ); }
290bool FIsLess_char(
const Box& self,
const Box& rhs ) {
291 if( rhs.IsCharacter () )
292 return self.UnboxCharacter() < rhs.UnboxCharacter () ;
294 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
299bool FIsLess_double(
const Box& self,
const Box& rhs ) {
300 double lhs= self.Unbox<
double>();
301 if( rhs.IsFloatingPoint () )
return lhs < rhs.UnboxFloatingPoint () ;
302 if( rhs.IsSignedIntegral () )
return lhs < double( rhs.UnboxSignedIntegral () );
303 if( rhs.IsUnsignedIntegral() )
return lhs < double( rhs.UnboxUnsignedIntegral() );
305 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
308#if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
309 bool FIsLess_float(
const Box& self,
const Box& rhs )
311 float lhs= self.Unbox<
float>();
312 if( rhs.IsType<
float >() )
return lhs < rhs.Unbox<
float >() ;
313 if( rhs.IsType<
double >() )
return lhs < float( rhs.Unbox<
double>() );
314 if( rhs.IsSignedIntegral () )
return lhs < float( rhs.UnboxSignedIntegral () );
315 if( rhs.IsUnsignedIntegral() )
return lhs < float( rhs.UnboxUnsignedIntegral() );
317 return std::type_index( self.TypeID() ) < std::type_index( rhs.TypeID() );
326 if ( !self.IsArray() || self.UnboxLength() == 0)
331 if( src==
nullptr || placeHolder.Integrals.Array[1] < 0 )
334 size_t alignment= self.ArrayElementSize();
335 if( alignment >
sizeof(std::ptrdiff_t) )
336 alignment=
sizeof(std::ptrdiff_t);
339 placeHolder.SetPointer( memory().Alloc( self.ArrayElementSize() * placeHolder.Integrals.UArray[1],
341 memcpy( placeHolder.GetPointer<
char>(), src, self.ArrayElementSize() * placeHolder.Integrals.UArray[1] );
346bool FIsTrue_Default(
const Box& self ) {
348 return self.UnboxLength() != 0;
351 unsigned usedLen= self.GetPlaceholderUsageLength();
356 return ( self.Data().Integrals.UArray[0]
357 & ((Bit1 << (usedLen * 8) )- 1) ) != 0;
360 if( self.Data().Integrals.UArray[0] != 0 )
368 return ( self.Data().Integrals.UArray[1]
369 & ((Bit1 << (usedLen -
sizeof(
uinteger)) * 8 )- 1) ) != 0;
372 return self.Data().Integrals.UArray[1] != 0;
377template<
typename TChar>
378bool FIsLess_TChar_arr(
const Box& lhs,
const Box& rhs ) {
379 if( rhs.IsArrayOf<TChar>() )
380 return lhs.Unbox<strings::TString<TChar>>() < rhs.Unbox<strings::TString<TChar>>();
382 return std::type_index( lhs.TypeID() ) < std::type_index(rhs.TypeID() );
386template<
typename TChar,
typename TAllocator>
387void FAppend_Default(
const Box& self, strings::TAString<TChar,TAllocator>& target) {
388 if( self.IsPointer() ) {
391 << strings::THex<TChar>( self.Data().Integrals.UArray[0] )
396 if( self.IsEnum() ) {
397 target <<
ALIB_REL_DBG(
"EnumType", self.TypeID() ) <<
'(' << self.Data().Integrals.Array[0] <<
')';
401 if( self.IsArray() ) {
402 target <<
ALIB_REL_DBG(
"ArrayType", self.ElementTypeID() ) <<
'[' << self.UnboxLength() <<
']';
407 target <<
ALIB_REL_DBG(
"ValueType", self.TypeID() ) <<
"(Size: " << self.GetPlaceholderUsageLength() <<
" bytes)";
411template<
typename TCharSrc,
typename TChar,
typename TAllocator>
412void FAppend_TcharArr(
const Box& box, strings::TAString<TChar,TAllocator>& target )
413{ target.template Append<NC>( box.UnboxArray<TCharSrc>(), box.UnboxLength() ); }
427#if ALIB_DEBUG && !DOXYGEN
428namespace{
unsigned initFlag= 0; }
432 ALIB_ASSERT_ERROR( initFlag == 0x92A3EF61,
"BOXING",
"Not initialized when calling shutdown." )
439 ALIB_ASSERT_ERROR( initFlag == 0,
"BOXING",
"This method must not be invoked twice." )
446 debug::LongDoubleTrueLengthSet();
447 debug::LONGDOUBLE_WRITE_TEST_MEM[0]= 0.0L;
449 "Platform not supported. SizeTraits<long double> contains wrong size" )
461DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_1])
463DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_1])
465 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
477 #if ALIB_SIZEOF_INTEGER == 8
484 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
487 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
492 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
502DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_2])
504DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_2])
543 #if !ALIB_SINGLE_THREADED
620 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
636 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
647 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
654 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
670 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
681 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
691 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
707 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
714 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
729 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
745 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
751 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
779 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
791 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
821 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
825 if constexpr (
sizeof(
long double) <=
sizeof(
Placeholder) ) {
897 #if ALIB_EXT_LIB_THREADS_AVAILABLE
917 #if ALIB_SYSTEM && ALIB_EXCEPTIONS
947 #if !ALIB_SINGLE_THREADED
971 assert( initFlag == 0x92A3EF61 );
978 if( increaseUsageCounter )
985 ALIB_ERROR(
"BOXING",
"Static VTable of mapped type <{}> not registered.\n"
986 "Use the macro ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER with bootstrapping.",
989 ALIB_ERROR(
"BOXING",
"Static VTable of mapped type <{}[]> not registered.\n"
990 "Use the macro ALIB_BOXING_REGISTER_MAPPED_ARRAY_TYPE with bootstrapping.",
#define ALIB_ERROR(domain,...)
#define IF_ALIB_MONOMEM(...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_REL_DBG(releaseCode,...)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_X(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER(Identifier)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_N(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_W(TAppendable)
ScanStates
Per-entry information about how a node was scanned.
This namespace exposes entities of module ALib Assert.
void DbgCheckIsInitialized()
void DbgCheckRegistration(detail::VTable *vtable, bool increaseUsageCounter)
void BootstrapRegisterDefault(typename TFDecl::Signature function)
void BootstrapRegister(typename TFDecl::Signature function)
constexpr unsigned SizeTraits
int Compare(const TChar *lhs, const TChar *rhs, integer cmpLength)
void FFormat_File(const Box &box, const String &formatSpec, NumberFormat &nf, AString &target)
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.
Exceptions
Exception codes of namespace #"alib::variables;2".
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
lang::intGap_t intGap_t
Type alias in namespace #"%alib".
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace #"%alib".
characters::wchar wchar
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
strings::TAString< xchar, lang::HeapAllocator > XAString
Type alias in namespace #"%alib".
lang::uintGap_t uintGap_t
Type alias in namespace #"%alib".
boxing::Pair< T, U > Pair
Type alias in namespace #"%alib".
characters::nchar nchar
Type alias in namespace #"%alib".
characters::xchar xchar
Type alias in namespace #"%alib".
strings::TAString< wchar, lang::HeapAllocator > WAString
Type alias in namespace #"%alib".
lang::uinteger uinteger
Type alias in namespace #"%alib".
static void Appendable(const Box &self, strings::TAString< TChar, TAllocator > &target)
static void WrappedAppendable(const Box &self, strings::TAString< TChar, TAllocator > &target)
static bool ComparableTypes(const Box &self, const Box &rhs)
static size_t UsePlaceholderBytes(const Box &self)
static bool ConstantTrue(const Box &)
static void Shutdown()
Needs to be called only in debug versions to shut down internal hashtables cleanly.
The custom function hash.
const std::type_info & ElementType
DbgFactoryType DbgProduction
Debug information.
@ Unregistered
Not registered, yet.
const std::type_info & Type
TReturn * GetPointer() const