ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Nested namespaces | Classes | Typedefs | Enumerations | Variables | Functions
aworx::lib Namespace Reference

This is the root namespace of ALib, a general purpose C++ library. ALib is developed by A-Worx GmbH, Germany, published under Boost Software License.

While being the root namespace of ALib C++ Library, the vast majority of library types are found in sub-namespaces hereof, which are associated with so called ALib Modules. The only sub-namespace that is not related to a single module is

and this is not even a real C++ namespace! In fact, it is used by various modules to place "documentation" of entities that provide compatibility to types of the standard C++ class library and 3rd-party libraries.

Next, in this namespace classes Module and ALibDistribution are found, which are used to organize the library in respect to resource management and bootstrapping.

Besides this, only a very few types and simple type definitions are placed in aworx::lib. These are types that support more than one module, were too simple to comprise a module or are for other reasons not eligible to be located in an ALib Module.
Among these types are a set of "common enums" which are used by different ALib Modules, and which might exploited by users of the library as well. These enums become available with the inclusion of header file alib/lib/fs_commonenums/commonenums.hpp.

Documentation

The ALib Programmer's Manual provides extensive documentation, including various separated manuals of ALib Modules, tutorials with sample code, information about configuring and compiling the library and so forth.
For people new to ALib, the ALib Programmer's Manual is the right place to start!

Reference Documentation

Nested namespaces

 bitbuffer
 
 boxing
 
 characters
 
 cli
 
 compatibility
 
 config
 
 detail
 
 enums
 
 expressions
 
 lox
 
 monomem
 
 resources
 
 results
 
 singletons
 
 strings
 
 system
 
 text
 
 threads
 
 time
 

Classes

class  ALibDistribution
 
class  DbgTypeDemangler
 
class  Module
 
struct  Owner
 
struct  TInitializeDefaults
 
struct  TOmitInitialization
 

Typedefs

using integer = platform_specific
 
using intGap_t = platform_specific
 
using ShiftOpRHS = int
 
using uinteger = platform_specific
 
using uintGap_t = platform_specific
 

Enumerations

enum  Alignment { Left, Right, Center }
 
enum  Bool : bool { False, True }
 
enum  Caching { Disabled, Enabled, Auto }
 
enum  Case : bool { Sensitive, Ignore }
 
enum  ContainerOp {
  Insert, Remove, Get, GetCreate,
  Create
}
 
enum  CreateDefaults : bool { No, Yes }
 
enum  CreateIfNotExists : bool { No, Yes }
 
enum  CurrentData : bool { Keep, Clear }
 
enum  Inclusion : bool { Include, Exclude }
 
enum  Initialization { Suppress, Perform }
 
enum  Phase { Begin = (1 << 0), End = (1 << 1) }
 
enum  Propagation : bool { Omit, ToDescendants }
 
enum  Reach : bool { Global, Local }
 
enum  Responsibility : bool { KeepWithSender, Transfer }
 
enum  Safeness : bool { Safe, Unsafe }
 
enum  Side : bool { Left, Right }
 
enum  SortOrder : bool { Ascending, Descending }
 
enum  SourceData : bool { Copy, Move }
 
enum  Switch : bool { Off, On }
 
enum  Timezone : bool { Local, UTC }
 
enum  Timing { Async, Sync }
 
enum  ValueReference { Absolute, Relative }
 
enum  Variables { LOCALE = 1, WAIT_FOR_KEY_PRESS = 2, HAS_CONSOLE_WINDOW = 3 }
 
enum  Whitespaces : bool { Trim, Keep }
 

Variables

lox::ALox ALOX
 
cli::Cli CLI
 
Config CONFIG
 
void(* DBG_SIMPLE_ALIB_MSG_PLUGIN )(const char *file, int line, const char *method, int type, const char *topic, int qtyMsgs, const char **msgs) =nullptr
 
bool DbgIsBootstrapped = false
 
expressions::Expressions EXPRESSIONS
 
results::Results RESULTS
 
system::System SYSTEM
 
text::Text TEXT
 

Functions

template<typename TIntegral >
constexpr int BitCount (TIntegral value)
 
template<typename TIntegral >
constexpr int BitCounterWidth ()
 
template<typename TIntegral >
constexpr int CLZ (TIntegral value)
 
template<typename TIntegral >
constexpr int CLZ0 (TIntegral value)
 
void DbgCheckSingleThreaded ()
 
ALIB_API void DbgSimpleALibMsg (const char *file, int line, const char *method, int type, const char *topic, const char *msg, const int intValue)
 
ALIB_API void DbgSimpleALibMsg (const char *file, int line, const char *method, 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 TIntegral >
constexpr TIntegral LowerBits (ShiftOpRHS width, TIntegral value)
 
template<ShiftOpRHS TWidth, typename TIntegral >
constexpr TIntegral LowerBits (TIntegral value)
 
template<ShiftOpRHS TWidth, typename TIntegral >
constexpr TIntegral LowerMask ()
 
template<typename TIntegral >
constexpr TIntegral LowerMask (ShiftOpRHS width)
 
template<typename TIntegral >
constexpr int MSB (TIntegral value)
 
template<typename TIntegral >
constexpr int MSB0 (TIntegral value)
 

Typedef Documentation

◆ integer

using integer = platform_specific

This type specifies platform independent integral values of the 'natural' bit-size of the underlying platform. In general, on 32-bit systems this will be 32-bit wide, on 64-bit systems, 64-bits. Hence, on standard architectures, it has the same bit-size and signedness as std::ptrdiff_t.

The type can be considered as a signed version of std::size_t. It is needed because standard type 'int' is not specified in respect to its size. E.g. GNU C++ and Clang compiler use 32-Bit integers for type int, even on 64-Bit platforms.

See also aworx::uinteger.

Note
This documentation is generated using the 64-Bit version of the library. In fact, the definition as int64_t shown here, is not guaranteed platform specific.

Definition at line 49 of file integers.hpp.

◆ intGap_t

using intGap_t = platform_specific

This type, together with its counterpart aworx::uintGap_t is used to fill a gap that occurs when method overloads or template specialization are needed for integer types. The rationale behind and use of this pair of types is best explained with a sample.

Consider the following code:

// Template function
template <typename TInteger> const char* MyFunc(TInteger val) { return "NOT IMPLEMENTED"; }
// Specializations for integer types
template<> const char* MyFunc( int8_t ) { return "Type= int8_t "; }
template<> const char* MyFunc( uint8_t ) { return "Type= uint8_t "; }
template<> const char* MyFunc( int16_t ) { return "Type= int16_t"; }
template<> const char* MyFunc( uint16_t ) { return "Type= uint16_t"; }
template<> const char* MyFunc( int32_t ) { return "Type= int32_t"; }
template<> const char* MyFunc( uint32_t ) { return "Type= uint32_t"; }
template<> const char* MyFunc( int64_t ) { return "Type= int64_t"; }
template<> const char* MyFunc( uint64_t ) { return "Type= uint64_t"; }
// TestMethod
void test()
{
// test std int types
cout << " int8_t : " << MyFunc( ( int8_t ) 0 ) << endl; // OK
cout << "uint8_t : " << MyFunc( (uint8_t ) 0 ) << endl; // OK
cout << " int16_t : " << MyFunc( ( int16_t) 0 ) << endl; // OK
cout << "uint16_t : " << MyFunc( (uint16_t) 0 ) << endl; // OK
cout << " int32_t : " << MyFunc( ( int32_t) 0 ) << endl; // OK
cout << "uint32_t : " << MyFunc( (uint32_t) 0 ) << endl; // OK
cout << " int64_t : " << MyFunc( ( int64_t) 0 ) << endl; // OK
cout << "uint64_t : " << MyFunc( (uint64_t) 0 ) << endl; // OK
cout << endl;
// test 'language' types
cout << " long : " << MyFunc( ( long ) 0 ) << endl; // Gap on common 32-bit platforms and 64-bit MSVC
cout << "unsigned long : " << MyFunc( (unsigned long ) 0 ) << endl; // Gap on common 32-bit platforms and 64-bit MSVC
cout << endl;
cout << " long long: " << MyFunc( ( long long) 0 ) << endl; // Gap on 64-Bit GNU C++
cout << "unsigned long long: " << MyFunc( (unsigned long long) 0 ) << endl; // Gap on 64-Bit GNU C++
cout << endl;
// further info
cout << endl;
cout << "sizeof( long )= " << sizeof( long ) << endl;
cout << "sizeof(unsigned long )= " << sizeof(unsigned long ) << endl;
cout << endl;
cout << "sizeof( long long)= " << sizeof( long long) << endl;
cout << "sizeof(unsigned long long)= " << sizeof(unsigned long long) << endl;
}

When this is run under 64 Bit - Linux, GNU compiler, the following output is produced:

 int8_t           : Type=  int8_t 
uint8_t           : Type= uint8_t 
 int16_t          : Type=  int16_t
uint16_t          : Type= uint16_t
 int32_t          : Type=  int32_t
uint32_t          : Type= uint32_t
 int64_t          : Type=  int64_t
uint64_t          : Type= uint64_t

         long     : Type=  int64_t
unsigned long     : Type= uint64_t

         long long: NOT IMPLEMENTED
unsigned long long: NOT IMPLEMENTED


sizeof(         long     )= 8
sizeof(unsigned long     )= 8

sizeof(         long long)= 8
sizeof(unsigned long long)= 8

This is not what many C++ programmers would expect: Although type long long is the same 64-bit type as long, the template method is not seen as specialized by the compiler. Therefore, we have a "gap" in the definition of specializations for types long long and unsigned long long.

When compiling and running the same sample code under GNU compiler 32-bit or under MSVC (Microsoft compiler), 32 or 64-bit, then the gap "moves" to be with types long and unsigned long instead. Here, this hurts a lot, because code that uses a simple integer constant 1L is not fetched by the template specializations!

The lesson learned is that two more specializations are needed and that their types are dependent on the compiler and library used. Because it is not allowed to specialize simply with all possible extra variants (this would lead to doubly defined methods), a preprocessor switch that chooses the right types to fill the gap is needed.

This type, together with uintGap_t, does exactly this: using the preprocessor to select the right "missing" type.

To fix the sample above, the following two specializations of the template method need to be added:

template<> const char* MyFunc( aworx:: intGap_t ) { return "Type= intGap_t"; }
template<> const char* MyFunc( aworx::uintGap_t ) { return "Type= uintGap_t"; }

When overloading functions with integer types, similar rules apply: To have the complete set of integer types covered, 10 overloads are needed: from type int8_t to type int64_t, type intGap_t and then those five types in two versions, signed and unsigned. Only with all overloads in place, compiler warnings (on high warning levels), compiler errors due to ambiguouties and/or the necessity of explicit type conversions are avoided.

See also
Along with these definitions, preprocessor symbol ALIB_SIZEOF_INTGAP is defined.

Definition at line 105 of file integers.hpp.

◆ ShiftOpRHS

using ShiftOpRHS = int

The C++ language defines the right-hand-side argument of bit shift operations to be of type int. To increase code readability we define this type explicitly.

Definition at line 35 of file bits.hpp.

◆ uinteger

using uinteger = platform_specific

Unsigned version of aworx::integer. This type should be the same as std::size_t on all platforms.

Definition at line 55 of file integers.hpp.

◆ uintGap_t

using uintGap_t = platform_specific

Used to complete overwriting methods and template specializations.
See signed sibling type aworx::intGap_t for more information.

Definition at line 111 of file integers.hpp.

Enumeration Type Documentation

◆ Alignment

enum Alignment
strong

Denotes Alignments.

Enumerator
Left 

Chooses left alignment.

Right 

Chooses right alignment.

Center 

Chooses centered alignment.

Definition at line 32 of file commonenumdefs.hpp.

◆ Bool

enum Bool : bool
strong

Enumeration representing a boolean value. While the use of this enumeration type seems senseless at the first sight (as the C++ has keywords bool, false and true), the reason for its existence is to have write and parse methods in place using the concept of ALib Enum Records.

The default name translation table is equipped with various 'overloaded' element entries like "yes", "no", "on", "off", "1" or "0". Furthermore, if other languages should be supported, this can even be extended at run-time.

Enumerator
False 

False value.

True 

True value.

Definition at line 49 of file commonenumdefs.hpp.

◆ Caching

enum Caching
strong

Denotes if a cache mechanism is enabled or disabled.

Enumerator
Disabled 

Caching is disabled.

Enabled 

Caching is enabled.

Auto 

Auto/default mode.

Definition at line 58 of file commonenumdefs.hpp.

◆ Case

enum Case : bool
strong

Denotes upper and lower case character treatment.

Enumerator
Sensitive 

Chooses an operation mode which differs between lower and upper case letters (usually the default).

Ignore 

Chooses an operation mode which does not differ between between lower and upper case letters.

Definition at line 69 of file commonenumdefs.hpp.

◆ ContainerOp

enum ContainerOp
strong

Denotes standard container operations.

Enumerator
Insert 

Denotes insertions.

Remove 

Denotes removals.

Get 

Denotes to search data.

GetCreate 

Denotes to create data if not found.

Create 

Denotes to create data.

Definition at line 81 of file commonenumdefs.hpp.

◆ CreateDefaults

enum CreateDefaults : bool
strong

Denotes whether default entities should be created or not.

Enumerator
No 

Do not create.

Yes 

Create default values.

Definition at line 93 of file commonenumdefs.hpp.

◆ CreateIfNotExists

enum CreateIfNotExists : bool
strong

Denotes whether something should be created if it does not exist.

Enumerator
No 

Do not create.

Yes 

Create if something does not exist.

Definition at line 102 of file commonenumdefs.hpp.

◆ CurrentData

enum CurrentData : bool
strong

Denotes if current, existing data should be cleared or if new data should be appended or otherwise added.

Enumerator
Keep 

Chooses not no clear existing data.

Clear 

Chooses to clear existing data.

Definition at line 112 of file commonenumdefs.hpp.

◆ Inclusion

enum Inclusion : bool
strong

Denotes how members of a set something should be taken into account.

Enumerator
Include 

Chooses inclusion.

Exclude 

Chooses exclusion.

Definition at line 121 of file commonenumdefs.hpp.

◆ Initialization

enum Initialization
strong

Used for example with constructors that allow to suppress initialization of members.

Enumerator
Suppress 

Suppress initialization. Writes "DontInitialize", reads in addition "suppress".

Perform 

Perform initialization. Writes "Initialize", reads in addition "perform".

Definition at line 130 of file commonenumdefs.hpp.

◆ Phase

enum Phase
strong

Denotes a phase, e.g. of a transaction.

Enumerator
Begin 

The start of a transaction.

End 

The end of a transaction.

Definition at line 141 of file commonenumdefs.hpp.

◆ Propagation

enum Propagation : bool
strong

Denotes whether a e.g a setting should be propagated.

Enumerator
Omit 

Do not propagate changes.

ToDescendants 

Propagate changes to descendants/children/sub-components.

Definition at line 150 of file commonenumdefs.hpp.

◆ Reach

enum Reach : bool
strong

Denotes the reach of something.

Enumerator
Global 

Denotes global reach.

Local 

Denotes local reach.

Definition at line 159 of file commonenumdefs.hpp.

◆ Responsibility

enum Responsibility : bool
strong

Denotes whether the responsibility for something is kept or passed. This is useful, e.g. in situations where objects are shared to determine if the responsibility for the deletion of object is transferred over to the receiver or kept by the sender of the object.

Enumerator
KeepWithSender 

Keeps responsibility, e.g. when passing an object.

Transfer 

Transfers responsibility to the receiving party.

Definition at line 170 of file commonenumdefs.hpp.

◆ Safeness

enum Safeness : bool
strong

Denotes whether something should be performed in a safe or unsafe fashion.

Enumerator
Safe 

Do it or treat it with safety.

Unsafe 

Omit checks or perform unsafe operations.

Definition at line 179 of file commonenumdefs.hpp.

◆ Side

enum Side : bool
strong

Denotes if something is left or right.

Enumerator
Left 

Denotes the left side of something.

Right 

Denotes the right side of something.

Definition at line 188 of file commonenumdefs.hpp.

◆ SortOrder

enum SortOrder : bool
strong

Denotes sort order.

Enumerator
Ascending 

Chooses ascending sort oder.

Descending 

Chooses descending sort oder.

Definition at line 197 of file commonenumdefs.hpp.

◆ SourceData

enum SourceData : bool
strong

Denotes if the source data should be moved or copied.

Enumerator
Copy 

Chooses not to clear existing data.

Move 

Chooses to clear existing data.

Definition at line 206 of file commonenumdefs.hpp.

◆ Switch

enum Switch : bool
strong

Denotes if sth. is switched on or off.

Enumerator
Off 

Switch it off, switched off, etc.

On 

Switch it on, switched on, etc.

Definition at line 215 of file commonenumdefs.hpp.

◆ Timezone

enum Timezone : bool
strong

Denotes whether a time value represents local time or UTC.

Enumerator
Local 

Denotes local time.

UTC 

Denotes UTC (coordinated universal time).

Definition at line 224 of file commonenumdefs.hpp.

◆ Timing

enum Timing
strong

Denotes if asynchronous tasks become synchronized.

Enumerator
Async 

The end of a transaction. Writes "Async", reads in addition "asynchronous", "no", "off", "false", "0" "-".

Sync 

The start of a transaction. Writes "Sync", reads in addition "synchronous", "synchronized", "synced" "yes", "on", "true", "1".

Definition at line 233 of file commonenumdefs.hpp.

◆ ValueReference

enum ValueReference
strong

Denotes if a value is interpreted as an absolute or relative number.

Enumerator
Absolute 

Referring to an absolute value.

Relative 

Referring to a relative value.

Definition at line 245 of file commonenumdefs.hpp.

◆ Variables

enum Variables
strong

Configuration variables of ALib.

Note
As required by module ALib Configuration, this enumerations is equipped with ALib Enum Records of type VariableDecl and resourced with this module.
Hence, all variable categories, names, default values and such can be modified by modifying the resource data of the singleton of class ALibDistribution.
Enumerator
LOCALE 

ALib Resourced variable.

WAIT_FOR_KEY_PRESS 

ALib Resourced variable.

HAS_CONSOLE_WINDOW 

ALib Resourced variable.

Definition at line 155 of file lib/fs_modules/distribution.hpp.

◆ Whitespaces

enum Whitespaces : bool
strong

Denotes whether a string is trimmed or not

Enumerator
Trim 

Trim whitespaces away.

Keep 

Keep whitespaces in string.

Definition at line 254 of file commonenumdefs.hpp.

Function Documentation

◆ BitCount()

constexpr int aworx::lib::BitCount ( TIntegral  value)
constexpr

Returns the number of bits set in an integral value. Internally, this method uses:

  • On gcc/clang: builtin method __builtin_popcount (and variations) which translate to a single assembly instruction, and a constexpression in case value is known at compile-time.
  • With MS-compilers, intrinsic popcount is used.
  • On other platforms, the number is evaluated programatically by a loop.
Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test.
Returns
The number of bits set in a value.

◆ BitCounterWidth()

constexpr int aworx::lib::BitCounterWidth ( )
inlineconstexpr

Returns the number of bits needed to count the bits set in a value of an integral type.

For example, a 16-Bit type may may have 0 to 16 bits set, hence 17 possible values, which need 5 bits to be counted.

Precisely, this function returns:

  • 4 for 8-bit types,
  • 5 for 16-bit types,
  • 6 for 32-bit types and
  • 7 for 64-bit types.
    Template Parameters
    TIntegralThe integral type to count bits in.
    Returns
    The number of bits needed to count the bits of type TIntegral.

◆ CLZ()

constexpr int aworx::lib::CLZ ( TIntegral  value)
constexpr

Returns the number of the leading 0-bits in an integral type. Internally, this method uses:

  • On gcc/clang: builtin methods __builtin_clz (and variations) which translate to a single assembly instruction, and a constexpression in case value is known at compile-time.
  • With MS-compilers, intrinsics _BitScanReverse and _BitScanReverse64 are used.
  • On other platforms, a binary search is performed.
Attention
This function must not be called with a value of 0! In debug-compilations, this method raises an ALib assertion in this case, while in release-compilations, the result is 'undefined'.. With function MSB0, an alternative is given which returns 0 if the input is 0.
Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. Must not be 0.
Returns
The highest bit set in value.

◆ CLZ0()

constexpr int aworx::lib::CLZ0 ( TIntegral  value)
constexpr

Variant of CLZ which tests given parameter value on 0 and returns 8 * sizeof(TIntegral) in this case. Otherwise returns the result of CLZ.

Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. May be 0, which results to the number of bits in TIntegral.
Returns
The number of leading zero-bits in value.

◆ DbgCheckSingleThreaded()

void DbgCheckSingleThreaded ( )
inline

This method stores the first thread that invokes it, and if in the future the method is visited by a different thread, it asserts.

In release compilations, this function is inlined and empty and therefore has not necessarily be removed by preprocessor macro ALIB_DBG or otherwise.

In debug-compilations, this is not empty, if:

  1. Module ALib Threads is not included in the ALib Distribution (what disables thread-safeness throughout the library), and
  2. Compiler symbol ALIB_EXT_LIB_THREADS_AVAILABLE was passed on library compilation, which allows to use the C++ thread library without causing linker failures.

If given, this function is called by macros ALIB_LOCK and ALIB_LOCK_WITH, which otherwise are defined by module ALib Threads. These macros will still be defined in the absence of that module. This exclamatory approach was made with ALib to motivate to write code that compiles with or without multi-threading support.

In addition to the invocation by these "remaining macro stubs", some other prominent entities, like lox::Lox, Formatter or monomem::AcquireGlobalAllocator invoke this method with acquisition.

Definition at line 62 of file alib.cpp.

◆ DbgSimpleALibMsg() [1/2]

ALIB_API void aworx::lib::DbgSimpleALibMsg ( const char *  file,
int  line,
const char *  method,
int  type,
const char *  topic,
const char *  msg,
const int  intValue 
)

Overloaded version of DbgSimpleALibMsg which accepts one integral value and writes msg and intValue in sequence.

Parameters
fileThe source file of the message invocation.
lineThe line number within file.
methodThe method invoking this function.
typeThe type of the message. The default implementation does not use this, other than invoking assert(0) in the case this parameter equals 0.
topicThe topic of the report.
msgThe message string.
intValueAn integer parameter (optional due to overload).

◆ DbgSimpleALibMsg() [2/2]

ALIB_API void aworx::lib::DbgSimpleALibMsg ( const char *  file,
int  line,
const char *  method,
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 
)

Some ALib modules do not (must not) rely on Report / ReportWriter mechanics. Therefore, this simple method is used for error handling in those portions of ALib that are exposed in such modules.
This method first checks if static function pointer DBG_SIMPLE_ALIB_MSG_PLUGIN is set and if yes, passes the parameters to this method and exits. If the complete ALib distribution is used, method ALibDistribution::Bootstrap sets this plug-in function to a custom one which passes the message(s) to a proper ALib Report.

Otherwise the method just writes to the standard output stream and then, if type equals 0, invokes assert(0).

Parameters
fileThe source file of the message invocation.
lineThe line number within file.
methodThe method invoking this function.
typeThe type of the message. The default implementation does not use this, other than invoking assert(0) in the case this parameter equals 0.
topicThe topic of the message.
msg1The first message string.
msg2Optional 2nd message string.
msg3Optional 3rd message string.
msg4Optional 4th message string.
msg5Optional 5th message string.

◆ LowerBits() [1/2]

constexpr TIntegral aworx::lib::LowerBits ( ShiftOpRHS  width,
TIntegral  value 
)
inlineconstexpr

Inline namespace function that keeps the given number of lower bits and masks the higher ones out of the given integral value. If parameter width is greater or equal to the width of the given TIntegral type, then all bits are returned.

See also
A fully templated version usable when the number of bits are known at compile time, is given with aworx::lib::LowerBits<ShiftOpRHS,typename>().
Template Parameters
TIntegralThe integral type to operate on (deduced by the compiler).
Parameters
widthThe number of lower bits to keep.
valueThe value to mask.
Returns
The given value with the upper remaining bits cleared.

◆ LowerBits() [2/2]

constexpr TIntegral aworx::lib::LowerBits ( TIntegral  value)
inlineconstexpr

Inline namespace function that keeps the given number of lower bits and masks the higher ones out of the given integral value. If parameter TWidth is greater or equal to the width of the given TIntegral type, then all bits are returned.

See also
While this is the fully templated version and hence explicitly constexpression for the reader of a code, with aworx::lib::LowerBits<TIntegral>(ShiftOpRHS,TIntegral), a version is given.
Template Parameters
TIntegralThe integral type to operate on (deduced by the compiler).
TWidthThe number of lower bits to keep.
Parameters
valueThe value to mask.
Returns
The given value with the upper remaining bits cleared.

◆ LowerMask() [1/2]

constexpr TIntegral aworx::lib::LowerMask ( )
inlineconstexpr

Inline namespace function that returns a mask with bits set to 1 up to the given binary digit, and bits above to 0. If parameter TWidth is greater or equal to the width of the given TIntegral type, then all bits are set in the returned value.

See also
While this is the fully templated version, with aworx::lib::LowerMask<TIntegral>(ShiftOpRHS), a run-time version is given.
Template Parameters
TWidthThe number of lower bits to set to 1.
TIntegralThe integral type to operate on (deduced by the compiler).
Returns
The requested mask.

◆ LowerMask() [2/2]

constexpr TIntegral aworx::lib::LowerMask ( ShiftOpRHS  width)
inlineconstexpr

Inline namespace function that returns a mask with bits set to 1 up to the given binary digit, and bits above to 0. If parameter width is greater or equal to the width of the given TIntegral type, then all bits are set in the returned value.

See also
A fully templated version usable when the number of bits are known at compile time, is given with aworx::lib::monomem::LowerMask<ShiftOpRHS,typename>().
Template Parameters
TIntegralThe integral type to operate on (deduced by the compiler).
Parameters
widthThe number of lower bits to set in the mask returned.
Returns
The requested mask.

◆ MSB()

constexpr int aworx::lib::MSB ( TIntegral  value)
constexpr

Returns the number of the most significant bit in an integral type. Internally, this method uses

  • On gcc/clang: builtin methods __builtin_clz (and variations) which translate to a single assembly instruction, and a constexpression in case value is known at compile-time. Internally, this method uses:
  • On gcc/clang: builtin methods __builtin_clz (and variations) which translate to a single assembly instruction, and a constexpression in case value is known at compile-time.
  • With MS-compilers, intrinsics _BitScanReverse and _BitScanReverse64 are used.
  • On other platforms, a binary search is performed.
Attention
This function must not be called with a value of 0! In debug-compilations, this method raises an ALib assertion in this case, while in release-compilations, the result is 'undefined'. With function MSB0, an alternative is given which returns 0 if the input is 0.
Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. Must not be 0.
Returns
The highest bit set in value.

◆ MSB0()

constexpr int aworx::lib::MSB0 ( TIntegral  value)
constexpr

Variant of MSB which tests given parameter value on 0 and returns 0 in this case. Otherwise returns the result of MSB.

Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. May be 0, which results to 0.
Returns
The highest bit set in value.

Variable Documentation

◆ ALOX

The singleton of module-class ALox.

Definition at line 52 of file aloxmodule.cpp.

◆ CLI

The singleton of module-class Cli.

Definition at line 33 of file cli.cpp.

◆ CONFIG

The singleton of module-class Config.

Definition at line 40 of file config.cpp.

◆ DBG_SIMPLE_ALIB_MSG_PLUGIN

void(* DBG_SIMPLE_ALIB_MSG_PLUGIN =nullptr

This function pointer defaults to nullptr and may be set to replace function DbgSimpleALibMsg. With the use of ALib Results, the module's bootstrap code (precisely method Results::bootstrap) sets this pointer to a small method which creates an Report on the default ReportWriter.

  • file: Information about the scope of invocation.
  • line: Information about the scope of invocation.
  • method: Information about the scope of invocation.
  • type: The type of the message. As a convention, 0 is severe error, others are warning levels.
  • qtyMsgs: The number of messages passed.
  • msgs: The message strings.

Definition at line 106 of file alib.cpp.

◆ DbgIsBootstrapped

ALIB_API bool DbgIsBootstrapped = false

This flag may be used to determine if ALib is bootstrapped already. While in general it is preferred to test corresponding single modules for being bootstrapped using Module::IsBootstrapped, this flag may be used to avoid the inclusion of header files of corresponding modules.

The flag is set to true at the end of phase BootstrapPhases::Final of module ALibDistribution and is cleared at the start of shutdown phase ShutdownPhases::Destruct.

Availability

This flag is available only with debug builds if fileset ALIB_FILESET_MODULES is included in the ALib Distribution.

Definition at line 17 of file alib.cpp.

◆ EXPRESSIONS

The singleton of module-class Expressions.

Definition at line 44 of file expressions.cpp.

◆ RESULTS

The singleton of module-class Results.

Definition at line 35 of file results.cpp.

◆ SYSTEM

The singleton of module-class System.

Definition at line 58 of file system.cpp.

◆ TEXT

The singleton of module-class Text.

Definition at line 48 of file text.cpp.

aworx::intGap_t
lib::intGap_t intGap_t
Type alias in namespace aworx.
Definition: integers.hpp:289
aworx::uintGap_t
lib::uintGap_t uintGap_t
Type alias in namespace aworx.
Definition: integers.hpp:292