summaryrefslogtreecommitdiff
path: root/src/common/common_funcs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/common_funcs.h')
-rw-r--r--src/common/common_funcs.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 53bd7da60..4c1e29de6 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -4,9 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <algorithm>
8#include <array> 7#include <array>
9#include <string> 8#include <iterator>
10 9
11#if !defined(ARCHITECTURE_x86_64) 10#if !defined(ARCHITECTURE_x86_64)
12#include <cstdlib> // for exit 11#include <cstdlib> // for exit
@@ -49,16 +48,6 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
49 48
50#endif // _MSC_VER ndef 49#endif // _MSC_VER ndef
51 50
52// Generic function to get last error message.
53// Call directly after the command or use the error num.
54// This function might change the error code.
55// Defined in misc.cpp.
56[[nodiscard]] std::string GetLastErrorMsg();
57
58// Like GetLastErrorMsg(), but passing an explicit error code.
59// Defined in misc.cpp.
60[[nodiscard]] std::string NativeErrorToString(int e);
61
62#define DECLARE_ENUM_FLAG_OPERATORS(type) \ 51#define DECLARE_ENUM_FLAG_OPERATORS(type) \
63 [[nodiscard]] constexpr type operator|(type a, type b) noexcept { \ 52 [[nodiscard]] constexpr type operator|(type a, type b) noexcept { \
64 using T = std::underlying_type_t<type>; \ 53 using T = std::underlying_type_t<type>; \
@@ -72,6 +61,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
72 using T = std::underlying_type_t<type>; \ 61 using T = std::underlying_type_t<type>; \
73 return static_cast<type>(static_cast<T>(a) ^ static_cast<T>(b)); \ 62 return static_cast<type>(static_cast<T>(a) ^ static_cast<T>(b)); \
74 } \ 63 } \
64 [[nodiscard]] constexpr type operator<<(type a, type b) noexcept { \
65 using T = std::underlying_type_t<type>; \
66 return static_cast<type>(static_cast<T>(a) << static_cast<T>(b)); \
67 } \
68 [[nodiscard]] constexpr type operator>>(type a, type b) noexcept { \
69 using T = std::underlying_type_t<type>; \
70 return static_cast<type>(static_cast<T>(a) >> static_cast<T>(b)); \
71 } \
75 constexpr type& operator|=(type& a, type b) noexcept { \ 72 constexpr type& operator|=(type& a, type b) noexcept { \
76 a = a | b; \ 73 a = a | b; \
77 return a; \ 74 return a; \
@@ -84,6 +81,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
84 a = a ^ b; \ 81 a = a ^ b; \
85 return a; \ 82 return a; \
86 } \ 83 } \
84 constexpr type& operator<<=(type& a, type b) noexcept { \
85 a = a << b; \
86 return a; \
87 } \
88 constexpr type& operator>>=(type& a, type b) noexcept { \
89 a = a >> b; \
90 return a; \
91 } \
87 [[nodiscard]] constexpr type operator~(type key) noexcept { \ 92 [[nodiscard]] constexpr type operator~(type key) noexcept { \
88 using T = std::underlying_type_t<type>; \ 93 using T = std::underlying_type_t<type>; \
89 return static_cast<type>(~static_cast<T>(key)); \ 94 return static_cast<type>(~static_cast<T>(key)); \