ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
boxing.prepro.hpp File Reference

Description:

This header-file is part of the ALib C++ Framework.

© 2013-2025 A-Worx GmbH, Germany. Published under Boost Software License.

Definition in file boxing.prepro.hpp.

#include "alib/alib.inl"

Go to the source code of this file.

Macros

#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_N(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_W(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_X(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER(Identifier)
#define ALIB_BOXING_CUSTOMIZE(TSource, TMapped, ...)
#define ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE(TSource, TElement, ...)
#define ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE_NON_UNBOXABLE(TSource, TElement, ...)
#define ALIB_BOXING_CUSTOMIZE_DENY_BOXING(TSource)
#define ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE(TSource, TMapped)
#define ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(TSource, TMapped)
#define ALIB_BOXING_DEFINE_FEQUALS_FOR_COMPARABLE_TYPE(TComparable)
#define ALIB_BOXING_DEFINE_FISLESS_FOR_COMPARABLE_TYPE(TComparable)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE(TMapped, Identifier)
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define ALIB_BOXING_VTABLE_DEFINE_ARRAYTYPE(TMapped, Identifier)

Macro Definition Documentation

◆ ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE

#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE ( TAppendable)
Value:
void BootstrapRegister(typename TFDecl::Signature function)
Definition box.inl:1173
static void Appendable(const Box &self, strings::TAString< TChar, TAllocator > &target)

This macro registers templated box-function implementation Appendable for the given type TAppendable.

The macro is to be placed in the bootstrap section of an application, for any type that is appendable to class AString.

This macro selects version box-function type FAppend<character>. If a custom type is appendable to two or three underlying character types of class AString, then macros

should be used. Note that for each character type of ALib Strings, a different box-function is registered.

Note
As by default, custom types get boxed as pointers, the type in question usually has to be provided here as pointer type, for example:
   ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE( my_namespace::MyType* )
Parameters
TAppendableThe appendable type.

Definition at line 142 of file boxing.prepro.hpp.

◆ ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_N

#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_N ( TAppendable)
Value:

Same as macro ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE but implements interface FAppend<nchar> instead of FAppend<character>.

Parameters
TAppendableThe appendable type.

Definition at line 146 of file boxing.prepro.hpp.

◆ ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_W

#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_W ( TAppendable)
Value:

Same as macro ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE but implements interface FAppend<wchar> instead of FAppend<character>.

Parameters
TAppendableThe appendable type.

Definition at line 150 of file boxing.prepro.hpp.

◆ ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_X

#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_X ( TAppendable)
Value:

Same as macro ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE but implements interface FAppend<xchar> instead of FAppend<character>.

Parameters
TAppendableThe appendable type.

Definition at line 154 of file boxing.prepro.hpp.

◆ ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER

#define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER ( Identifier)
Value:
alib::boxing::debug::DbgRegisterVTable( &alib::boxing::detail::SNGLTN_ # Identifier, \
void DbgRegisterVTable(detail::VTable *vtable, detail::VTable::DbgFactoryType productionType)
@ Static
A static VTable is in place.
Definition vtable.inl:269

Registers a statically created vtable singleton declared with either ALIB_BOXING_VTABLE_DECLARE or ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE.

This macro has to be placed in the bootstrap code of software. In debug-compilations, this macro is empty.

See also
Chapter 12.2 Optimizations With Static VTables of the Programmer's Manual of module ALib Boxing.
Parameters
IdentifierThe identifier name of the vtable singleton as passed to macros ALIB_BOXING_VTABLE_DECLARE or ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE.

Definition at line 129 of file boxing.prepro.hpp.

◆ ALIB_BOXING_CUSTOMIZE

#define ALIB_BOXING_CUSTOMIZE ( TSource,
TMapped,
... )
Value:
namespace alib::boxing { \
template<> struct BoxTraits<TSource> \
{ \
using Mapping= TMapped; \
static constexpr bool IsArray= false; \
__VA_ARGS__ \
}; } \

Macro used to specialize template struct BoxTraits, which customizes boxing for given boxable type TSource to be mapped to non-array type TMapped.

Type alias Mapping is implemented by the macro to evaluate to TMapped>. The implementations of methods Write and Read are to be provided with the variadic macro arguments.

This macro belongs to a set of sibling macros. For customization of boxing the best suitable macro should be chosen. The set is

See also
For more information, consult chapter 7. Customizing Boxing of the Programmer's Manual of module ALib Boxing.
Parameters
TSourceThe C++ 'source' type to specialize struct BoxTraits for.
TMappedThe target type to map TSource to.
...Definition of static inline methods Write and Read.

Definition at line 42 of file boxing.prepro.hpp.

◆ ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE

#define ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE ( TSource,
TElement,
... )
Value:
namespace alib::boxing { \
template<> struct BoxTraits<TSource> \
{ \
using Mapping= TElement; \
static constexpr bool IsArray= true; \
__VA_ARGS__ \
}; }

Specializes template struct BoxTraits, to customize boxing for given boxable type TSource to be mapped to array type TMapped[].

Type definition Mapping is implemented by the macro to evaluate to TMapped. The implementations of methods Write and Read are to be provided with the variadic macro arguments.

See also
Macro ALIB_BOXING_CUSTOMIZE for information about the sibling macros.
Parameters
TSourceThe C++ 'source' type to specialize struct BoxTraits for.
TElementThe element type of the array to map TSource to.
...Definition of static inline methods Write and Read.

Definition at line 51 of file boxing.prepro.hpp.

◆ ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE_NON_UNBOXABLE

#define ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE_NON_UNBOXABLE ( TSource,
TElement,
... )
Value:
namespace alib::boxing { \
template<> struct BoxTraits<TSource> \
{ using Mapping= TElement; \
static constexpr bool IsArray= true; \
__VA_ARGS__ \
static constexpr void Read( const Placeholder& box); \
}; }

Specializes template struct BoxTraits, to customize boxing for given boxable type TSource to be mapped to array type TMapped[].

Type definition Mapping is implemented by the macro to evaluate to TMapped and IsArray evaluates to true.
Static method Read is declared to return void, with no implementation given (as it will not be called).
The implementation of method Write is to be provided with the variadic portion of the macro arguments.

See also
Macro ALIB_BOXING_CUSTOMIZE for information about the sibling macros.
Parameters
TSourceThe C++ 'source' type to specialize struct BoxTraits for.
TElementThe element type of the array to map TSource to.
...Definition of static inline method Write.

Definition at line 81 of file boxing.prepro.hpp.

◆ ALIB_BOXING_CUSTOMIZE_DENY_BOXING

#define ALIB_BOXING_CUSTOMIZE_DENY_BOXING ( TSource)
Value:
namespace alib::boxing { \
template<> struct BoxTraits<TSource> \
{ using Mapping= NotBoxableTag; \
static constexpr bool IsArray= false; \
static constexpr void Write( Placeholder& box, TSource const & value ); \
static constexpr void Read ( const Placeholder& box); \
}; }

Specializes template struct BoxTraits, to completely forbid boxing and unboxing of type TSource.

For this, type definition Mapping is implemented by the macro to evaluate to TMapped and just declarations of static methods Write and Read are given.
The latter is declared to return void. Note that this in principle is not necessary because using NotBoxableTag already forbids unboxing. Nevertheless, this way concept IsLocked is satisfied for TSource as well.

See also
Macro ALIB_BOXING_CUSTOMIZE for information about the sibling macros.
Parameters
TSourceThe type that should be denied to be used with ALib Boxing.

Definition at line 91 of file boxing.prepro.hpp.

◆ ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE

#define ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE ( TSource,
TMapped )
Value:
namespace alib::boxing { \
template<> struct BoxTraits<TSource> \
{ using Mapping= TMapped; \
static constexpr bool IsArray= false; \
static constexpr void Write( Placeholder& box, TSource const & value ) { box.Write( static_cast<TMapped>( value ) ); } \
static constexpr void Read( const Placeholder& box); \
}; }

Specializes template struct BoxTraits. This version of a set of sibling macros, is to be used when a simple type mapping is to be performed for types TSource that are statically castable to TMapped.
In contrast to macro ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING, with this macro, unboxing the source type is denied.

The macro provides the implementations of all three entities of the type trait BoxTraits:

  • Type Mapping evaluates to using TMapped.
  • Static method Write performs a static cast of the source value to the destination type and then passes the result to Write.
  • Static method Read is declared to return void, with no implementation given.
See also
Macro ALIB_BOXING_CUSTOMIZE for information about the sibling macros.
Parameters
TSourceThe C++ 'source' type to specialize struct BoxTraits for.
TMappedThe target type to map TSource to.

Definition at line 71 of file boxing.prepro.hpp.

◆ ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING

#define ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING ( TSource,
TMapped )
Value:
namespace alib::boxing { \
template<> struct BoxTraits<TSource> \
{ using Mapping= TMapped; \
static constexpr bool IsArray= false; \
static constexpr void Write( Placeholder& box, TSource const & value ) { box.Write( static_cast<TMapped>( value ) ); } \
static constexpr TSource Read (const Placeholder& box) { return static_cast<TSource>(box.Read<TMapped>()); } \
}; }

Specializes template struct BoxTraits. This version of a set of sibling macros, is to be used when simple type mappings are to be performed between types that are statically castable, or when boxing as pointer should be enforced.

The macro provides the implementations of all three entities of the type trait BoxTraits:

  • Type Mapping evaluates to TMapped.
  • Static method Write is defined to do static cast of the source value to the destination type and to then pass the result to Write.
  • Static method Read is defined to read the mapped type using Placeholder::Read and statically cast this to TSource.
See also
Macro ALIB_BOXING_CUSTOMIZE for information about the sibling macros.
Parameters
TSourceThe C++ 'source' type to specialize struct BoxTraits for.
TMappedThe target type to map TSource to.

Definition at line 61 of file boxing.prepro.hpp.

◆ ALIB_BOXING_DEFINE_FEQUALS_FOR_COMPARABLE_TYPE

#define ALIB_BOXING_DEFINE_FEQUALS_FOR_COMPARABLE_TYPE ( TComparable)
Value:

This macro registers templated box-function ComparableTypes for given mapped type TComparable.

If a type is boxed as pointer type, then TComparable has to be given as pointer type. For comparison, the unboxed pointers will be dereferenced. If both are nulled, true is returned, if one is nulled, false.

As all function registrations have to be performed at run-time, this macro is to be placed in the bootstrap section of an application.

Parameters
TComparableThe comparable type name.

Definition at line 136 of file boxing.prepro.hpp.

◆ ALIB_BOXING_DEFINE_FISLESS_FOR_COMPARABLE_TYPE

#define ALIB_BOXING_DEFINE_FISLESS_FOR_COMPARABLE_TYPE ( TComparable)
Value:

This macro registers templated box-function ComparableTypes for given type TComparable.

If a type is boxed as pointer type, then TComparable has to be given as pointer type. For comparison, the unboxed pointers will be dereferenced. If both are nulled, false is returned, if only lhs is nulled, true and if only rhs is nulled, then false.

As all function registrations have to be performed at run-time, this macro is to be placed in the bootstrap section of an application.

Parameters
TComparableThe comparable type name.

Definition at line 139 of file boxing.prepro.hpp.

◆ ALIB_BOXING_VTABLE_DECLARE

#define ALIB_BOXING_VTABLE_DECLARE ( TMapped,
Identifier )
Value:
ALIB_EXPORT namespace alib::boxing { namespace detail { \
extern ALIB_DLL VTable SNGLTN_ # Identifier; } \
template<> struct VTableOptimizationTraits< TMapped, false > { \
static constexpr detail::VTable* Get() { return &detail:: SNGLTN_ # Identifier; } }; } \
#define ALIB_DLL
Definition alib.inl:573
#define ALIB_EXPORT
Definition alib.inl:562

Declares an extern object of type VTable named Identifier in namespace detail.
Furthermore specializes the type trait VTableOptimizationTraits for mapped type TMapped to have its method Get return the extern VTable-instance.

This macro has to be placed in a header included by each compilation unit that creates or accesses boxes of type TMapped.

See also
Parameters
TMappedThe mapped type to declare a vtable singleton for.
IdentifierThe identifier name of the vtable singleton.

Definition at line 101 of file boxing.prepro.hpp.

◆ ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE

#define ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE ( TMapped,
Identifier )
Value:
ALIB_EXPORT namespace alib::boxing { namespace detail { \
extern ALIB_DLL VTable SNGLTN_ # Identifier; } \
template<> struct VTableOptimizationTraits< TMapped, true > { \
static constexpr detail::VTable* Get() { return &detail:: SNGLTN_ # Identifier;} }; } \

Same as ALIB_BOXING_VTABLE_DECLARE, but used with mapped array types. Specializes VTableOptimizationTraits for mapped type TMapped.

See also
Macros ALIB_BOXING_VTABLE_DECLARE (for plain types), ALIB_BOXING_VTABLE_DEFINE, ALIB_BOXING_VTABLE_DEFINE and ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER.
Parameters
TMappedThe mapped type to declare a vtable singleton for.
IdentifierThe identifier name of the vtable singleton.

Definition at line 107 of file boxing.prepro.hpp.

◆ ALIB_BOXING_VTABLE_DEFINE

#define ALIB_BOXING_VTABLE_DEFINE ( TMapped,
Identifier )
Value:
alib::boxing::detail::VTable alib::boxing::detail::SNGLTN_ # Identifier \
( typeid(TMapped), typeid(void) , \
std::is_pointer<TMapped>::value \
? VTable::MappingType::Pointer \
: std::is_enum<TMapped>::value \
? VTable::MappingType::Enum \
: VTable::MappingType::Value , \
constexpr unsigned SizeTraits
The custom function hash.
Definition vtable.inl:228

Defines the external object declared with ALIB_BOXING_VTABLE_DECLARE.

This macro has to be placed in a compilation unit.

Parameters
TMappedThe mapped type to define a vtable singleton for.
IdentifierThe identifier name of the vtable singleton.

Definition at line 113 of file boxing.prepro.hpp.

◆ ALIB_BOXING_VTABLE_DEFINE_ARRAYTYPE

#define ALIB_BOXING_VTABLE_DEFINE_ARRAYTYPE ( TMapped,
Identifier )
Value:
alib::boxing::detail::VTable alib::boxing::detail::SNGLTN_ # Identifier \
(typeid(TMapped[1]) , typeid(TMapped), VTable::MappingType(sizeof(TMapped)), sizeof(Placeholder)); \

Defines the external object declared with ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE.

This macro has to be placed in a compilation unit.

Parameters
TMappedThe mapped type to define a vtable singleton for.
IdentifierThe identifier name of the vtable singleton.

Definition at line 123 of file boxing.prepro.hpp.