Enigma  3.2.0
A Simple, Reliable and Efficient Encryption Tool
Macros.hpp File Reference

Go to the source code of this file.

Macros

#define ENIGMA_MACROS_H
 
#define NS_ENIGMA_BEGIN   namespace Enigma {
 Enable/Disable Assertions. More...
 
#define NS_ENIGMA_END   }
 
#define USING_NS_ENIGMA   using namespace Enigma;
 Enigma NAME SPACE DECLARATION. More...
 
#define enigma   Enigma
 
#define ENIGMA_BIND_FUN(fun)   [this](auto&&...args) -> decltype(auto) { return this->fun(std::forward<decltype(args)>(args)...); }
 Bind Event function call back macro (alternative to std::bind for modern & better c++) More...
 
#define ENIGMA_ASSERT(x, ...)
 Asserts. More...
 
#define ENIGMA_ASSERT(x, ...)
 Asserts. More...
 
#define ENIGMA_ASSERT_OR_THROW(x, msg)
 
#define ENIGMA_ASSERT_OR_RETURN(x, msg, ret)
 
#define ENIGMA_SAFE_DELETE_PTR(ptr)
 Enigma Memory Safe Operations. More...
 
#define ENIGMA_SAFE_DELETE_ARRAY_PTR(ptr)
 
#define ENIGMA_SAFE_DELETE_LIST_PTR(list)
 
#define BIT(x)   (1 << x)
 Bit Shift. More...
 
#define ENIGMA_ARRAY_SIZE(arr)   static_cast<::Enigma::std::size_t>(sizeof(arr) / sizeof((arr)[0]))
 Array Size. More...
 
#define ENIGMA_IS_BETWEEN(v, mi, ma)   (v >= mi && v <= ma)
 Check if value is between or equal a range. More...
 
#define ENIGMA_CURRENT_FUNCTION   "<unknown function>"
 
#define ENIGMA_NON_COPYABLE(Class)
 Prevent class copying or moving. More...
 
#define ENIGMA_NON_MOVEABLE(Class)    Class& operator=(Class&& obj) = delete;
 
#define ENIGMA_STATIC_CLASS(Class)
 Makes a class static, which will prevent creating instances from it and only use it as Class::Func().. More...
 
#define ENIGMA_BEGIN_TIMER(var)   const auto var = std::chrono::steady_clock::now()
 Begin and end timer with a unit. More...
 
#define ENIGMA_END_TIMER(var, type, unit)   std::chrono::duration_cast<std::chrono::duration<type, unit>>(std::chrono::steady_clock::now() - var).count()
 
#define ENIGMA_TRACE_CURRENT_FUNCTION()
 Logs current function for debugging. More...
 
#define ENIGMA_ENUM_DECLARE_BEGIN_END(begin)
 Allows looping over an enum by providing a BEGIN and END enum values NOTE: should be placed at the end of the enum, providing the first element of the enum. More...
 
#define ENIGMA_ENUM_CLASS_BITWISE_OPERATORS(_enum, _type)
 Implements bitwise operators for enum classes. More...
 

Macro Definition Documentation

◆ BIT

#define BIT (   x)    (1 << x)

Bit Shift.

Definition at line 74 of file Macros.hpp.

◆ enigma

#define enigma   Enigma

Definition at line 20 of file Macros.hpp.

◆ ENIGMA_ARRAY_SIZE

#define ENIGMA_ARRAY_SIZE (   arr)    static_cast<::Enigma::std::size_t>(sizeof(arr) / sizeof((arr)[0]))

Array Size.

Definition at line 78 of file Macros.hpp.

◆ ENIGMA_ASSERT [1/2]

#define ENIGMA_ASSERT (   x,
  ... 
)

Asserts.

Definition at line 38 of file Macros.hpp.

◆ ENIGMA_ASSERT [2/2]

#define ENIGMA_ASSERT (   x,
  ... 
)

Asserts.

Definition at line 38 of file Macros.hpp.

◆ ENIGMA_ASSERT_OR_RETURN

#define ENIGMA_ASSERT_OR_RETURN (   x,
  msg,
  ret 
)
Value:
if (!(x)) { \
return ret; \
} \

Definition at line 46 of file Macros.hpp.

◆ ENIGMA_ASSERT_OR_THROW

#define ENIGMA_ASSERT_OR_THROW (   x,
  msg 
)
Value:
if (!(x)) { \
throw std::runtime_error(msg); \
}

Definition at line 41 of file Macros.hpp.

◆ ENIGMA_BEGIN_TIMER

#define ENIGMA_BEGIN_TIMER (   var)    const auto var = std::chrono::steady_clock::now()

Begin and end timer with a unit.

Definition at line 132 of file Macros.hpp.

◆ ENIGMA_BIND_FUN

#define ENIGMA_BIND_FUN (   fun)    [this](auto&&...args) -> decltype(auto) { return this->fun(std::forward<decltype(args)>(args)...); }

Bind Event function call back macro (alternative to std::bind for modern & better c++)

Definition at line 25 of file Macros.hpp.

◆ ENIGMA_CURRENT_FUNCTION

#define ENIGMA_CURRENT_FUNCTION   "<unknown function>"

Resolve which function signature macro will be used. Note that this only is resolved when the (pre)compiler starts, so the syntax highlighting could mark the wrong one in your editor!

Definition at line 105 of file Macros.hpp.

◆ ENIGMA_END_TIMER

#define ENIGMA_END_TIMER (   var,
  type,
  unit 
)    std::chrono::duration_cast<std::chrono::duration<type, unit>>(std::chrono::steady_clock::now() - var).count()

Definition at line 133 of file Macros.hpp.

◆ ENIGMA_ENUM_CLASS_BITWISE_OPERATORS

#define ENIGMA_ENUM_CLASS_BITWISE_OPERATORS (   _enum,
  _type 
)
Value:
friend inline constexpr _enum operator~(const _enum i) noexcept { return static_cast<_enum>(~static_cast<const _type>(i)); } \
friend inline constexpr _enum operator|(const _enum a, const _enum b) noexcept { return static_cast<_enum>(static_cast<const _type>(a) | static_cast<const _type>(b)); } \
friend inline constexpr _enum operator&(const _enum a, const _enum b) noexcept { return static_cast<_enum>(static_cast<const _type>(a) & static_cast<const _type>(b)); } \
friend inline constexpr _enum operator^(const _enum a, const _enum b) noexcept { return static_cast<_enum>(static_cast<const _type>(a) ^ static_cast<const _type>(b)); } \
friend inline constexpr _enum& operator|=(_enum& a, const _enum b) noexcept { \
a = a | b; \
return a; \
} \
friend inline constexpr _enum& operator&=(_enum& a, const _enum b) noexcept { \
a = a & b; \
return a; \
} \
friend inline constexpr _enum& operator^=(_enum& a, const _enum b) noexcept { \
a = a ^ b; \
return a; \
}
std::uint32_t operator|(const EventType a, const EventType b)
Definition: Event.hpp:44
std::uint32_t operator&(const EventType a, const EventType b)
Definition: Event.hpp:45

Implements bitwise operators for enum classes.

Definition at line 155 of file Macros.hpp.

◆ ENIGMA_ENUM_DECLARE_BEGIN_END

#define ENIGMA_ENUM_DECLARE_BEGIN_END (   begin)
Value:
__HALT__, \
BEGIN = begin, \
END = __HALT__ - 1

Allows looping over an enum by providing a BEGIN and END enum values NOTE: should be placed at the end of the enum, providing the first element of the enum.

Definition at line 148 of file Macros.hpp.

◆ ENIGMA_IS_BETWEEN

#define ENIGMA_IS_BETWEEN (   v,
  mi,
  ma 
)    (v >= mi && v <= ma)

Check if value is between or equal a range.

Definition at line 82 of file Macros.hpp.

◆ ENIGMA_MACROS_H

#define ENIGMA_MACROS_H

Definition at line 3 of file Macros.hpp.

◆ ENIGMA_NON_COPYABLE

#define ENIGMA_NON_COPYABLE (   Class)
Value:
Class& operator=(const Class& obj) = delete; \
Class(const Class& obj) = delete;

Prevent class copying or moving.

Definition at line 111 of file Macros.hpp.

◆ ENIGMA_NON_MOVEABLE

#define ENIGMA_NON_MOVEABLE (   Class)     Class& operator=(Class&& obj) = delete;

Definition at line 114 of file Macros.hpp.

◆ ENIGMA_SAFE_DELETE_ARRAY_PTR

#define ENIGMA_SAFE_DELETE_ARRAY_PTR (   ptr)
Value:
if ((ptr)) { \
delete[] (ptr); \
(ptr) = nullptr; \
}

Definition at line 60 of file Macros.hpp.

◆ ENIGMA_SAFE_DELETE_LIST_PTR

#define ENIGMA_SAFE_DELETE_LIST_PTR (   list)
Value:
if (((list)[0])) { \
for (auto& ptr: list) \
ENIGMA_SAFE_DELETE_PTR(ptr); \
} \

Definition at line 66 of file Macros.hpp.

◆ ENIGMA_SAFE_DELETE_PTR

#define ENIGMA_SAFE_DELETE_PTR (   ptr)
Value:
if ((ptr)) { \
delete (ptr); \
(ptr) = nullptr; \
}

Enigma Memory Safe Operations.

Definition at line 54 of file Macros.hpp.

◆ ENIGMA_STATIC_CLASS

#define ENIGMA_STATIC_CLASS (   Class)
Value:
public: \
ENIGMA_NON_COPYABLE(Class) \
ENIGMA_NON_MOVEABLE(Class) \
Class() = delete; \
~Class() = delete; \
\
private:

Makes a class static, which will prevent creating instances from it and only use it as Class::Func()..

Definition at line 120 of file Macros.hpp.

◆ ENIGMA_TRACE_CURRENT_FUNCTION

#define ENIGMA_TRACE_CURRENT_FUNCTION ( )

Logs current function for debugging.

Definition at line 143 of file Macros.hpp.

◆ NS_ENIGMA_BEGIN

#define NS_ENIGMA_BEGIN   namespace Enigma {

Enable/Disable Assertions.

Enigma NAME SPACE DEFINITION

Definition at line 13 of file Macros.hpp.

◆ NS_ENIGMA_END

#define NS_ENIGMA_END   }

Definition at line 14 of file Macros.hpp.

◆ USING_NS_ENIGMA

#define USING_NS_ENIGMA   using namespace Enigma;

Enigma NAME SPACE DECLARATION.

Definition at line 19 of file Macros.hpp.