Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
error_codes_pp.hpp File Reference
#include <sysio/vm/config.hpp>
#include <string>
#include <system_error>
#include <type_traits>
Include dependency graph for error_codes_pp.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ERROR_CODE_NAMESPACE   std
 
#define TRUE_TYPE   std::true_type
 
#define GENERATE_ERROR_CATEGORY(CATEGORY, NAME)
 
#define GENERATE_ENUM_ELEM(PARENT, ITEM)
 
#define GENERATE_STR_ELEM(PARENT, ITEM)
 
#define CREATE_ERROR_CODES(CATEGORY, ERRORS)
 

Typedefs

using error_category_t = std::error_category
 
using error_code_t = std::error_code
 

Macro Definition Documentation

◆ CREATE_ERROR_CODES

#define CREATE_ERROR_CODES ( CATEGORY,
ERRORS )
Value:
namespace sysio { namespace vm { \
enum class CATEGORY { ERRORS(GENERATE_ENUM_ELEM) }; \
} \
} \
namespace ERROR_CODE_NAMESPACE { \
template <> \
struct is_error_code_enum<sysio::vm::CATEGORY> : TRUE_TYPE {}; \
} \
namespace sysio { namespace vm { \
inline std::string CATEGORY##_category::message(int ev) const { \
switch (static_cast<CATEGORY>(ev)) { ERRORS(GENERATE_STR_ELEM) } \
return ""; \
} \
inline error_code_t make_error_code(CATEGORY e) noexcept { \
return { static_cast<int>(e), __##CATEGORY##_category }; \
} \
} \
}
#define GENERATE_STR_ELEM(PARENT, ITEM)
std::error_code error_code_t
#define ERROR_CODE_NAMESPACE
#define GENERATE_ENUM_ELEM(PARENT, ITEM)
#define TRUE_TYPE

Definition at line 44 of file error_codes_pp.hpp.

44#define CREATE_ERROR_CODES(CATEGORY, ERRORS) \
45 namespace sysio { namespace vm { \
46 enum class CATEGORY { ERRORS(GENERATE_ENUM_ELEM) }; \
47 } \
48 } \
49 namespace ERROR_CODE_NAMESPACE { \
50 template <> \
51 struct is_error_code_enum<sysio::vm::CATEGORY> : TRUE_TYPE {}; \
52 } \
53 namespace sysio { namespace vm { \
54 inline std::string CATEGORY##_category::message(int ev) const { \
55 switch (static_cast<CATEGORY>(ev)) { ERRORS(GENERATE_STR_ELEM) } \
56 return ""; \
57 } \
58 inline error_code_t make_error_code(CATEGORY e) noexcept { \
59 return { static_cast<int>(e), __##CATEGORY##_category }; \
60 } \
61 } \
62 }

◆ ERROR_CODE_NAMESPACE

#define ERROR_CODE_NAMESPACE   std

Definition at line 19 of file error_codes_pp.hpp.

◆ GENERATE_ENUM_ELEM

#define GENERATE_ENUM_ELEM ( PARENT,
ITEM )
Value:
ITEM,

Definition at line 38 of file error_codes_pp.hpp.

◆ GENERATE_ERROR_CATEGORY

#define GENERATE_ERROR_CATEGORY ( CATEGORY,
NAME )
Value:
namespace sysio { namespace vm { \
struct CATEGORY##_category : error_category_t { \
const char* name() const noexcept override { return #NAME; } \
std::string message(int ev) const override; \
}; \
const CATEGORY##_category __##CATEGORY##_category{}; \
template <typename T> \
static inline constexpr auto is_a(const error_code_t& ec) \
-> std::enable_if_t<std::is_same_v<T, CATEGORY##_category>, bool> { \
return ec.category() == __##CATEGORY##_category; \
} \
} \
}
std::string name
#define NAME(s)
std::error_category error_category_t

Definition at line 23 of file error_codes_pp.hpp.

23#define GENERATE_ERROR_CATEGORY(CATEGORY, NAME) \
24 namespace sysio { namespace vm { \
25 struct CATEGORY##_category : error_category_t { \
26 const char* name() const noexcept override { return #NAME; } \
27 std::string message(int ev) const override; \
28 }; \
29 const CATEGORY##_category __##CATEGORY##_category{}; \
30 template <typename T> \
31 static inline constexpr auto is_a(const error_code_t& ec) \
32 -> std::enable_if_t<std::is_same_v<T, CATEGORY##_category>, bool> { \
33 return ec.category() == __##CATEGORY##_category; \
34 } \
35 } \
36 }

◆ GENERATE_STR_ELEM

#define GENERATE_STR_ELEM ( PARENT,
ITEM )
Value:
case PARENT::ITEM: \
return #ITEM;

Definition at line 40 of file error_codes_pp.hpp.

40#define GENERATE_STR_ELEM(PARENT, ITEM) \
41 case PARENT::ITEM: \
42 return #ITEM;

◆ TRUE_TYPE

#define TRUE_TYPE   std::true_type

Definition at line 20 of file error_codes_pp.hpp.

Typedef Documentation

◆ error_category_t

typedef std::error_category error_category_t = std::error_category

Definition at line 17 of file error_codes_pp.hpp.

◆ error_code_t

typedef std::error_code error_code_t = std::error_code

Definition at line 18 of file error_codes_pp.hpp.