This namespace holds types and functions, which are very close to the C++ language itself. The availability of most of the entities found here, is not related to the inclusion of a certain ALib Module within the ALib Distribution chosen. Instead, the corresponding header files are always included when compiling ALib .
With the inclusion of ALib BaseCamp in the ALib Distribution , type Camp is found, which is used to organize the library in respect to resource management and bootstrapping. Furthermore, this very special "Camp-Module" adds sub-namespaces
to this namespace, as well as a few other basic language-related types like lang::Exception .
Nested Namespaces: | |
namespace | basecamp |
namespace | detail |
namespace | format |
namespace | resources |
namespace | system |
Type Index: | |
struct | BidiListHelper |
struct | BidiNodeBase |
class | Camp |
class | DbgTypeDemangler |
struct | ERException |
class | Exception |
struct | Message |
class | Owner |
class | PluginContainer |
class | Report |
class | ReportWriter |
class | ReportWriterStdIO |
struct | SidiListHelper |
struct | SidiNodeBase |
class | TBitSet |
struct | TInitializeDefaults |
struct | TOmitInitialization |
Type Definition Index: | |
using | integer = platform_specific |
using | intGap_t = platform_specific |
using | ShiftOpRHS = int |
using | uinteger = platform_specific |
using | uintGap_t = platform_specific |
Enumeration Index: | |
enum class | Alignment { Left , Right , Center } |
enum class | Bool : bool { False , True } |
enum class | Caching { Disabled , Enabled , Auto } |
enum class | Case : bool { Sensitive , Ignore } |
enum class | ContainerOp { Insert , Remove , Get , GetCreate , Create } |
enum class | CreateDefaults : bool { No , Yes } |
enum class | CreateIfNotExists : bool { No , Yes } |
enum class | CurrentData : bool { Keep , Clear } |
enum class | Inclusion : bool { Include , Exclude } |
enum class | Initialization { Suppress , Perform } |
enum class | Phase { Begin = (1 << 0) , End = (1 << 1) } |
enum class | Propagation : bool { Omit , ToDescendants } |
enum class | Reach : bool { Global , Local } |
enum class | Recursive : bool { No , Yes } |
enum class | ReportExceptions { ErrorWritingReport = 1 } |
enum class | Responsibility : bool { KeepWithSender , Transfer } |
enum class | Safeness : bool { Safe , Unsafe } |
enum class | Side : bool { Left , Right } |
enum class | SortOrder : bool { Ascending , Descending } |
enum class | SourceData : bool { Copy , Move } |
enum class | Switch : bool { Off , On } |
enum class | Timezone : bool { Local , UTC } |
enum class | Timing { Async , Sync } |
enum class | ValueReference { Absolute , Relative } |
enum class | Whitespaces : bool { Trim , Keep } |
Function Index: | |
template<typename TIntegral > | |
constexpr int | BitCount (TIntegral value) |
template<typename T > | |
constexpr int | bitsofval (const T &val) |
template<typename TIntegral > | |
constexpr int | CLZ (TIntegral value) |
template<typename TIntegral > | |
constexpr int | CLZ0 (TIntegral value) |
template<typename TIntegral > | |
constexpr int | CTZ (TIntegral value) |
template<typename TIntegral > | |
constexpr int | CTZ0 (TIntegral value) |
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) |
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE void | debugReportPlugin (const char *file, int line, const char *method, int type, const char *topic, int qtyMsgs, const nchar **msgs) |
template<typename TIntegral > | |
constexpr int | Log2OfSize () |
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) |
template<ShiftOpRHS TWidth, typename TIntegral > | |
constexpr TIntegral | UpperMask () |
template<typename TIntegral > | |
constexpr TIntegral | UpperMask (ShiftOpRHS width) |
Variable Index: | |
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 |
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 alib::uinteger.
int64_t
shown here, is not guaranteed platform specific. Definition at line 50 of file integers.hpp.
using intGap_t = platform_specific |
This type, together with its counterpart alib::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:
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:
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.
Definition at line 106 of file integers.hpp.
using ShiftOpRHS = int |
using uinteger = platform_specific |
Unsigned version of alib::integer. This type should be the same as std::size_t
on all platforms.
Definition at line 56 of file integers.hpp.
using uintGap_t = platform_specific |
Used to complete overwriting methods and template specializations.
See signed sibling type alib::intGap_t for more information.
Definition at line 112 of file integers.hpp.
|
strong |
Denotes Alignments.
Enumerator | |
---|---|
Left | Chooses left alignment. |
Right | Chooses right alignment. |
Center | Chooses centered alignment. |
Definition at line 29 of file commonenumdefs.hpp.
|
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 46 of file commonenumdefs.hpp.
|
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 55 of file commonenumdefs.hpp.
|
strong |
Denotes upper and lower case character treatment.
Definition at line 66 of file commonenumdefs.hpp.
|
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 78 of file commonenumdefs.hpp.
|
strong |
Denotes whether default entities should be created or not.
Enumerator | |
---|---|
No | Do not create. |
Yes | Create default values. |
Definition at line 90 of file commonenumdefs.hpp.
|
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 99 of file commonenumdefs.hpp.
|
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 109 of file commonenumdefs.hpp.
|
strong |
Denotes how members of a set something should be taken into account.
Enumerator | |
---|---|
Include | Chooses inclusion. |
Exclude | Chooses exclusion. |
Definition at line 118 of file commonenumdefs.hpp.
|
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 127 of file commonenumdefs.hpp.
|
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 138 of file commonenumdefs.hpp.
|
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 147 of file commonenumdefs.hpp.
|
strong |
Denotes the reach of something.
Enumerator | |
---|---|
Global | Denotes global reach. |
Local | Denotes local reach. |
Definition at line 156 of file commonenumdefs.hpp.
|
strong |
Denotes whether recursion is performed/allowed or not.
Enumerator | |
---|---|
No | Denotes non-recursive. |
Yes | Denotes recursion. |
Definition at line 165 of file commonenumdefs.hpp.
|
strong |
Exception codes of class Report .
Enumerator | |
---|---|
ErrorWritingReport | Error when writing a report. This typically indicates an erroneous format string in an ALIB_ASSERT_ERROR or related macro. |
Definition at line 36 of file report.hpp.
|
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 176 of file commonenumdefs.hpp.
|
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 185 of file commonenumdefs.hpp.
|
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 194 of file commonenumdefs.hpp.
|
strong |
Denotes sort order.
Enumerator | |
---|---|
Ascending | Chooses ascending sort oder. |
Descending | Chooses descending sort oder. |
Definition at line 203 of file commonenumdefs.hpp.
|
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 212 of file commonenumdefs.hpp.
|
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 221 of file commonenumdefs.hpp.
|
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 230 of file commonenumdefs.hpp.
|
strong |
Denotes if asynchronous tasks become synchronized.
Definition at line 239 of file commonenumdefs.hpp.
|
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 251 of file commonenumdefs.hpp.
|
strong |
Denotes whether a string is trimmed or not
Enumerator | |
---|---|
Trim | Trim whitespaces away. |
Keep | Keep whitespaces in string. |
Definition at line 260 of file commonenumdefs.hpp.
|
constexpr |
Returns the number of bits set in an integral value. Internally, this method uses:
__builtin_popcount
(and variations) which translate to a single assembly instruction, and a constexpression in case value
is known at compile-time.popcount
is used.TIntegral | The integral type to operate on. |
value | The value to test. |
|
inlineconstexpr |
Like C++ keyword sizeof
but returns the number of bits of the type of the given value. The return type is int
instead of size_t
, which satisfies ALib code conventions.
sizeof
, as an exception from the rules, this function is spelled in lower case.val | The (sample) value to deduce the type from. Otherwise ignored. |
T | The type to receive the size in bits from. |
|
constexpr |
Returns the number of the leading 0-bits in an integral type. Internally, this method uses:
__builtin_clz
(or variations) which translate to a single assembly instruction, and a constexpression in case value
is known at compile-time._BitScanReverse
or _BitScanReverse64
is used.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
.TIntegral | The integral type to operate on. |
value | The value to test. Must not be 0 . |
value
.
|
constexpr |
Variant of CLZ which tests given parameter value
on 0
and returns sizeof(TIntegral) * 8
in this case. Otherwise returns the result of CLZ.
TIntegral | The integral type to operate on. |
value | The value to test. May be 0 , which results to the number of bits in TIntegral . |
value
.
|
constexpr |
Returns the number of the trailing 0-bits in an integral type. Internally, this method uses:
__builtin_ctz
(and variations) which translate to a single assembly instruction, and a constexpression in case value
is known at compile-time._BitScanForward
or _BitScanForward64
is used.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 CTZ0, an alternative is given which returns 0
if the input is 0
.TIntegral | The integral type to operate on. |
value | The value to test. Must not be 0 . |
value
.
|
constexpr |
Variant of CTZ which tests given parameter value
on 0
and returns sizeof(TIntegral) * 8
in this case. Otherwise returns the result of CLZ.
TIntegral | The integral type to operate on. |
value | The value to test. May be 0 , which results to the number of bits in TIntegral . |
value
. In case the given value is 0
, sizeof(Tintegral) * 8
is returned.
|
extern |
Overloaded version of DbgSimpleALibMsg which accepts one integral value and writes msg and intValue in sequence.
file | The source file of the message invocation. |
line | The line number within file . |
method | The method invoking this function. |
type | The type of the message. The default implementation does not use this, other than invoking assert(0) in the case this parameter equals 0 . |
topic | The topic of the report. |
msg | The message string. |
intValue | An integer parameter (optional due to overload). |
|
extern |
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 lang::DBG_SIMPLE_ALIB_MSG_PLUGIN is set and if yes, passes the parameters to this method and exits. If module ALib BaseCamp is included in the ALib Distribution , method BaseCamp::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)
.
file | The source file of the message invocation. |
line | The line number within file . |
method | The method invoking this function. |
type | The type of the message. The default implementation does not use this, other than invoking assert(0) in the case this parameter equals 0 . |
topic | The topic of the message. |
msg1 | The first message string. |
msg2 | Optional 2nd message string. |
msg3 | Optional 3rd message string. |
msg4 | Optional 4th message string. |
msg5 | Optional 5th message string. |
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE void debugReportPlugin | ( | const char * | file, |
int | line, | ||
const char * | method, | ||
int | type, | ||
const char * | topic, | ||
int | qtyMsgs, | ||
const nchar ** | msgs ) |
This method is installed with lang::DBG_SIMPLE_ALIB_MSG_PLUGIN in method Camp::bootstrap .
The message strings are simply passed to the default Report . This way, the essential assert, error and message macros are using the ALib report system in the moment that the ALib BaseCamp is included in the ALib Distribution .
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 message. See Message . |
topic | The topic of message. |
qtyMsgs | The number of messages in msgs . |
msgs | A list of strings (this is all that the essential versions of ALib reporting macros provide). |
Definition at line 174 of file basecamp.cpp.
|
inlineconstexpr |
Returns the logarithm base to for the size in bits of the template given integral type.
Precisely, this function returns:
TIntegral | The integral type to count bits in. |
TIntegral
.
|
inlineconstexpr |
Inline namespace function that keeps the given number of lower bits and masks the higher ones out of the given integral value. Parameter width
must not be greater or equal to the width of the given TIntegral
type. In debug compilations, an assertion is raised.
width | The number of lower bits to keep. |
value | The value to mask. |
TIntegral | The integral type to operate on (deduced by the compiler). |
|
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.
value | The value to mask. |
TWidth | The number of lower bits to keep. |
TIntegral | The integral type to operate on (deduced by the compiler). |
|
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.
TWidth | The number of lower bits to set to 1 . |
TIntegral | The integral type to operate on. |
|
inlineconstexpr |
Inline namespace function that returns a mask with bits set to 1
up to the given binary digit, and bits above to 0
. Parameter width
must not be greater or equal to the width of the given TIntegral
type. In debug compilations, an assertion is raised in that case.
TIntegral | The integral type to operate on. |
width | The number of lower bits to set in the mask returned. |
|
constexpr |
Returns the number of the most significant bit in an integral type. Internally, this method uses CLZ and returns
int(sizeof(TIntegral)) * 8 - CLZ(value)
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
.CTZ() + 1
.TIntegral | The integral type to operate on. |
value | The value to test. Must not be 0 . |
value
. The numbering starts with 1
and ends with sizeof(Tintegral) * 8
.
|
constexpr |
Variant of MSB which tests given parameter value
on 0
and returns 0
in this case. Otherwise returns the result of MSB.
TIntegral | The integral type to operate on. |
value | The value to test. May be 0 , which results to 0 . |
value
. The numbering starts with 1
and ends with sizeof(Tintegral)* 8
. If value is 0
, hence no bit is set, 0
is returned.
|
inlineconstexpr |
Inline namespace function that returns a mask with bits set to 0
up to the given binary digit, and bits above to 1
. If parameter TWidth
is greater or equal to the width of the given TIntegral
type, then all bits are set in the returned value.
TWidth | The number of lower bits to clear to 1 . |
TIntegral | The integral type to operate on. |
|
inlineconstexpr |
Inline namespace function that returns a mask with bits set to 0
up to the given binary digit, and bits above to 1
. Parameter width
must not be greater or equal to the width of the given TIntegral
type. In debug compilations, an assertion is raised in that case.
TIntegral | The integral type to operate on. |
width | The number of lower bits to clear in the mask returned. |
void(* DBG_SIMPLE_ALIB_MSG_PLUGIN)(const char *file, int line, const char *method, int type, const char *topic, int qtyMsgs, const char **msgs) | ( | const char * | file, |
int | line, | ||
const char * | method, | ||
int | type, | ||
const char * | topic, | ||
int | qtyMsgs, | ||
const char ** | msgs ) =nullptr |
This function pointer defaults to nullptr
and may be set to replace function DbgSimpleALibMsg. With the use of ALib BaseCamp , the module's bootstrap code (precisely method BaseCamp::bootstrap ) sets this pointer to a small method which creates an Report on the default ReportWriter .