mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
macro.hpp File Reference

Defines macros and constants for various purposes. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_EX(ENUM_TYPE, ENUM_TYPE_UNDERLYING)
 This macro is used to declare the bitwise operators for an enum class so it is easier to use it as a bitfield with a specified underlying type.
 
#define MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS(ENUM_TYPE)    MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_EX(ENUM_TYPE, std::underlying_type_t<ENUM_TYPE>)
 This macro is used to declare the bitwise operators for an enum class so it is easier to use it as a bitfield with the default underlying type.
 
#define MAL_TOOLKIT_DECLARE_ENUM_BIT_FUNCTIONS(ENUM_TYPE)
 This macro is used to declare the bitwise functions for an enum class so it is easier to use it as a bitfield.
 
#define MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_AND_FUNCTIONS(ENUM_TYPE)
 This macro is used to declare both the bitwise operators and functions for an enum class so it is easier to use it as a bitfield.
 

Detailed Description

Defines macros and constants for various purposes.

Definition in file macro.hpp.

Macro Definition Documentation

◆ MAL_TOOLKIT_DECLARE_ENUM_BIT_FUNCTIONS

#define MAL_TOOLKIT_DECLARE_ENUM_BIT_FUNCTIONS ( ENUM_TYPE)
Value:
template <typename T> \
inline bool HasFlag(ENUM_TYPE a, T b) \
{ \
return (a & b) == b; \
} \
template <typename T> \
inline bool HasAnyFlag(ENUM_TYPE a, T b) \
{ \
return (a & b) != 0; \
} \
template <typename T> \
inline bool HasAllFlags(ENUM_TYPE a, T b) \
{ \
return (a & b) == a; \
} \
template <typename T> \
inline ENUM_TYPE SetFlag(ENUM_TYPE a, T b) \
{ \
return a | b; \
} \
template <typename T> \
inline ENUM_TYPE ClearFlag(ENUM_TYPE a, T b) \
{ \
return a & ~b; \
} \
template <typename T> \
inline ENUM_TYPE FlipFlag(ENUM_TYPE a, T b) \
{ \
return a ^ b; \
}

This macro is used to declare the bitwise functions for an enum class so it is easier to use it as a bitfield.

Parameters
ENUM_TYPEThe enum class type.

Definition at line 90 of file macro.hpp.

◆ MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS

#define MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS ( ENUM_TYPE)     MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_EX(ENUM_TYPE, std::underlying_type_t<ENUM_TYPE>)

This macro is used to declare the bitwise operators for an enum class so it is easier to use it as a bitfield with the default underlying type.

Parameters
ENUM_TYPEThe enum class type.

Definition at line 82 of file macro.hpp.

◆ MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_AND_FUNCTIONS

#define MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_AND_FUNCTIONS ( ENUM_TYPE)
Value:
MAL_TOOLKIT_DECLARE_ENUM_BIT_FUNCTIONS(ENUM_TYPE)
#define MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS(ENUM_TYPE)
This macro is used to declare the bitwise operators for an enum class so it is easier to use it as a ...
Definition macro.hpp:82

This macro is used to declare both the bitwise operators and functions for an enum class so it is easier to use it as a bitfield.

Parameters
ENUM_TYPEThe enum class type.

Definition at line 127 of file macro.hpp.

◆ MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_EX

#define MAL_TOOLKIT_DECLARE_ENUM_BIT_OPERATORS_EX ( ENUM_TYPE,
ENUM_TYPE_UNDERLYING )

This macro is used to declare the bitwise operators for an enum class so it is easier to use it as a bitfield with a specified underlying type.

Parameters
ENUM_TYPEThe enum class type.
ENUM_TYPE_UNDERLYINGThe underlying type of the enum class.
Note
This macro is used when the underlying type of the enum class is not the default one.

Definition at line 14 of file macro.hpp.