ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib.hpp File Reference

Description:

This header file is part of the ALib C++ Library.

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

This header does not belong to a module of ALib, but is included in any ALib Distribution. Its purposes are:

  • To identify given ALib Compiler Symbols related to module selection and enable corresponding symbols (that may be not given) of dependent modules.
  • Provide functions Bootstrap and Shutdown which select the right bootstrapping and shutdown methods, depending on the ALib Distribution.
Note
This header is not shown in inclusion graphs of this documentation, as it is always included directly or indirectly.

Definition in file alib.hpp.

#include <type_traits>
#include <thread>
#include <typeinfo>
#include <assert.h>
Include dependency graph for alib.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CallerInfo
 
struct  CHK
 See sibling type NC. More...
 
struct  CompilationFlagMeaningsEntry
 This is a struct composing an entry in COMPILATION_FLAG_MEANINGS. More...
 
struct  NC
 
struct  TCompilationFlags
 

Namespaces

namespace  alib
 
namespace  alib::lang
 

Macros

#define ALIB_DOCUMENTATION_URL   "https://alib.dev/"
 DOXYGEN.
 
ALib Version And Feature Verification

Macros used to verify that the ALib binary used has the right version is compiled with the same feature set as the current compilation unit. For this, version and feature flags are compiled statically into the library. The macros are used internally, respectively 'automatically'. Hence, they need not to be used directly clients of the library.

#define ALIB_ASSERT_MODULE(modulename)
 
#define ALIB_REVISION   0
 
#define ALIB_VERSION   2412
 
ALib Module Selection

This group of symbols determine the availability of different ALib Modules of the ALib Distribution used. The symbols are defined in header alib/alib.hpp which always is and has to be the first ALib header file included (directly or indirectly). If none of the symbols is passed to the compiler, this header file will define all to 1, hence will include all modules a distribution.

If a symbol is given as 1, all corresponding symbols of dependent modules are also defined to 1, even if one had explicitly given as 0, which is considered a contradicting input.

#define ALIB_ALOX   1
 
#define ALIB_BITBUFFER   1
 
#define ALIB_BOXING   1
 
#define ALIB_CAMP   1
 
#define ALIB_CHARACTERS   1
 
#define ALIB_CLI   1
 
#define ALIB_CONFIGURATION   1
 
#define ALIB_CONTAINERS   1
 
#define ALIB_ENUMS   1
 
#define ALIB_EXPRESSIONS   1
 
#define ALIB_FILES   1
 
#define ALIB_MONOMEM   1
 
#define ALIB_SINGLETONS   1
 
#define ALIB_STRINGS   1
 
#define ALIB_THREADMODEL   1
 
#define ALIB_THREADS   1
 
#define ALIB_TIME   1
 
Code Selection

The macros listed here include or prune code, dependent on different preprocessor symbols. They are mainly given to avoid #if/#else/#endif statements for small code pieces.

#define ALIB_CPP_23(...)
 
#define ALIB_CPP_BEFORE_23(...)
 
#define ALIB_DBG(...)
 
#define ALIB_REL(...)
 
#define ALIB_REL_DBG(releaseCode, ...)
 
#define IF_ALIB_ALOX(...)
 
#define IF_ALIB_BITBUFFER(...)
 
#define IF_ALIB_BOXING(...)
 
#define IF_ALIB_CAMP(...)
 
#define IF_ALIB_CHARACTERS(...)
 
#define IF_ALIB_CLI(...)
 
#define IF_ALIB_CONFIGURATION(...)
 
#define IF_ALIB_CONTAINERS(...)
 
#define IF_ALIB_ENUMS(...)
 
#define IF_ALIB_EXPRESSIONS(...)
 
#define IF_ALIB_FILES(...)
 
#define IF_ALIB_MONOMEM(...)
 
#define IF_ALIB_SINGLETONS(...)
 
#define IF_ALIB_STRINGS(...)
 
#define IF_ALIB_THREADMODEL(...)
 
#define IF_ALIB_THREADS(...)
 
#define IF_ALIB_TIME(...)
 
#define IFNOT_ALIB_ALOX(...)
 
#define IFNOT_ALIB_BITBUFFER(...)
 
#define IFNOT_ALIB_BOXING(...)
 
#define IFNOT_ALIB_CAMP(...)
 
#define IFNOT_ALIB_CHARACTERS(...)
 
#define IFNOT_ALIB_CLI(...)
 
#define IFNOT_ALIB_CONFIGURATION(...)
 
#define IFNOT_ALIB_CONTAINERS(...)
 
#define IFNOT_ALIB_ENUMS(...)
 
#define IFNOT_ALIB_EXPRESSIONS(...)
 
#define IFNOT_ALIB_FILES(...)
 
#define IFNOT_ALIB_MONOMEM(...)
 
#define IFNOT_ALIB_SINGLETONS(...)
 
#define IFNOT_ALIB_STRINGS(...)
 
#define IFNOT_ALIB_THREADMODEL(...)
 
#define IFNOT_ALIB_THREADS(...)
 
#define IFNOT_ALIB_TIME(...)
 
C/C++ Language And Linkage Macros

The macros listed here are supporting C++ compilation and linking control and language specific utilities.

#define ALIB_API   __declspec(dllexport)
 
#define ALIB_ASSERT_GLOBAL_NAMESPACE
 
#define ALIB_CALLER   {__FILE__,__LINE__,ALIB_CALLER_FUNC,::std::this_thread::get_id(),&typeid(*this)}
 
#define ALIB_CALLER_FUNC   __FUNCTION__
 
#define ALIB_CALLER_NULLED   ALIB_CALLER
 
#define ALIB_CALLER_NULLED_COMMA   ALIB_CALLER ,
 
#define ALIB_CALLER_PRUNED   ALIB_CALLER
 
#define ALIB_CALLER_PRUNED_COMMA   ALIB_CALLER ,
 
#define ALIB_COMMA_CALLER_NULLED   , ALIB_CALLER
 
#define ALIB_COMMA_CALLER_PRUNED   , ALIB_CALLER
 
#define ALIB_DBG_TAKE_CI   const CallerInfo& ci
 
#define ALIB_FORCE_INLINE   __forceinline
 
#define ALIB_NO_RETURN   [[ noreturn ]]
 
#define ALIB_SIZEOF_WCHAR_T   4
 
#define ALIB_STACK_ALLOCATED_TYPE(T)
 
ALib Module Characters Feature Selection

#define ALIB_CHARACTERS_SIZEOF_WCHAR   ALIB_SIZEOF_WCHAR_T
 
#define ALIB_CHARACTERS_WIDE   1
 
C/C++ Compiler Warning Control

ALib sources are designed to be compiled on different compilers using the highest possible compiler warning levels available. In some situations, some warnings need to be temporarily disabled. The following macros do this in a compiler agnostic way.

#define ALIB_FALLTHROUGH   [[clang::fallthrough]];
 
#define ALIB_WARNINGS_ALLOW_BITWISE_SWITCH
 
#define ALIB_WARNINGS_ALLOW_MACRO_REDEFINITION
 
#define ALIB_WARNINGS_ALLOW_NULL_POINTER_PASSING    _Pragma("clang diagnostic push") \
 
#define ALIB_WARNINGS_ALLOW_SHIFT_COUNT_OVERFLOW
 
#define ALIB_WARNINGS_ALLOW_SPARSE_ENUM_SWITCH
 
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
 
#define ALIB_WARNINGS_ALLOW_UNSAFE_FUNCTION_OR_VARIABLE
 
#define ALIB_WARNINGS_IGNORE_DOCS
 
#define ALIB_WARNINGS_IGNORE_FUNCTION_TEMPLATE
 
#define ALIB_WARNINGS_IGNORE_INTEGER_OVERFLOW
 
#define ALIB_WARNINGS_IGNORE_INTEGRAL_CONSTANT_OVERFLOW    _Pragma("clang diagnostic push") \
 
#define ALIB_WARNINGS_IGNORE_NOTHING_RETURNED
 
#define ALIB_WARNINGS_IGNORE_RESERVED_IDENTIFIER
 
#define ALIB_WARNINGS_IGNORE_SIGN_CONVERSION
 
#define ALIB_WARNINGS_IGNORE_UNUSED_FUNCTION
 
#define ALIB_WARNINGS_IGNORE_UNUSED_LAMBDA_CAPTURE
 
#define ALIB_WARNINGS_IGNORE_UNUSED_MACRO
 
#define ALIB_WARNINGS_IGNORE_UNUSED_PARAMETER
 
#define ALIB_WARNINGS_IGNORE_UNUSED_VARIABLE
 
#define ALIB_WARNINGS_MACRO_NOT_USED_OFF
 
#define ALIB_WARNINGS_OVERLOAD_VIRTUAL_OFF
 
#define ALIB_WARNINGS_RESERVED_MACRO_NAME_OFF
 
#define ALIB_WARNINGS_RESTORE    _Pragma("clang diagnostic pop") \
 
#define ALIB_WARNINGS_UNINITIALIZED_OFF
 
C/C++ Preprocessor Helper Macros

The following macros are fundamental and building blocks for other macros.

#define ALIB_COMMA   ,
 
#define ALIB_COMMA_DBG   ,
 
#define ALIB_CONCAT(a, b)
 
#define ALIB_EMPTY
 
#define ALIB_IDENTIFIER(prefix)
 
#define ALIB_NSTRINGIFY(a)
 
#define ALIB_STATIC_ASSERT(CondVariable, Cond, Message)
 
#define ALIB_STATIC_DENY(CondVariable, Cond, Message)
 
#define ALIB_STRINGIFY(a)
 
Debug Assertions, Warnings and Errors

The macros listed here are defined in two different versions, depending on the ALib distribution. With single ALib Modules that do not incorporate class alib::lang::Report and family, namespace function alib::lang::DbgSimpleALibMsg (and overloads) are used to write the messages. The default implementation of this message invokes assert(false) if the message is of error type.
There is a very simple "plug-in" concept in place that allows redirecting this method to a user-defined one which may act differently.

If class report is included in the selected ALib distribution, two things happen:

  • the aforementioned plug-in is implemented and an ALib Report is generated inside the plug-in function.
  • The macros themselves are redefined to directly use the ALib Report facility. Such redefinition happens "in the middle" of header inclusion (as early as possible), with the effect that most classes of ALib are compiled using the simple version, but still use the mechanics of ALib Reports. Other parts of ALib classes, and of course all user code, will have the more sophisticated, report-based versions of the macros in place. The huge advantage of them is, that those accept an arbitrary list of arguments which are boxed and passed to a formatter. This allows easily composing detailed and formatted debug messages.

If also module ALox is compiled into the library, then a plug-in that uses ALox for the message output is used. See class ALoxReportWriter for more information.

#define ALIB_ASSERT(cond)
 
#define ALIB_ASSERT_ERROR(cond, ...)
 
#define ALIB_ASSERT_MESSAGE(cond, ...)
 
#define ALIB_ASSERT_RESULT_EQUALS( func, value)
 
#define ALIB_ASSERT_RESULT_GREATER_THAN(func, value)
 
#define ALIB_ASSERT_RESULT_LESS_THAN( func, value)
 
#define ALIB_ASSERT_RESULT_NOT_EQUALS( func, value)
 
#define ALIB_ASSERT_WARNING(cond, ...)
 
#define ALIB_ERROR(...)
 
#define ALIB_MESSAGE(...)
 
#define ALIB_WARNING(...)
 

Typedefs

using CallerInfo = lang::CallerInfo
 Type alias in namespace alib.
 

Enumerations

enum class  BootstrapPhases { PrepareResources = 1 , PrepareConfig = 2 , Final = 3 }
 Initialization levels usable with Bootstrapping ALib Camps. More...
 
enum class  ShutdownPhases { Announce = 1 , Destruct = 2 }
 Termination levels usable with Bootstrapping ALib Camps. More...
 

Functions

ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE void AssertALibVersionAndFlags (int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
 
ALIB_API void Bootstrap (BootstrapPhases targetPhase, lang::Camp *targetCamp=nullptr, int alibVersion=ALIB_VERSION, int alibRevision=ALIB_REVISION, TCompilationFlags compilationFlags=TCompilationFlags{ALIB_COMPILATION_FLAGS})
 
ALIB_WARNINGS_RESTORE void Bootstrap (int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
 
ALIB_API void DbgSimpleALibMsg (const CallerInfo &ci, int type, const char *topic, const char *msg, const int intValue)
 
ALIB_API void DbgSimpleALibMsg (const CallerInfo &ci, int type, const char *topic, const char *msg1=nullptr, const char *msg2=nullptr, const char *msg3=nullptr, const char *msg4=nullptr, const char *msg5=nullptr)
 
template<typename T >
constexpr bool IsNotNull (const T &t)
 
template<typename T >
constexpr bool IsNull (const T &t)
 
template<typename T >
constexpr void SetNull (const T &t)
 
void Shutdown ()
 
ALIB_API void Shutdown (ShutdownPhases targetPhase, lang::Camp *targetCamp=nullptr)
 

Macro Definition Documentation

◆ ALIB_DOCUMENTATION_URL

#define ALIB_DOCUMENTATION_URL   "https://alib.dev/"

DOXYGEN.

Definition at line 221 of file alib.hpp.