yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
macro.h
Go to the documentation of this file.
1#ifndef YAZE_UTIL_MACRO_H
2#define YAZE_UTIL_MACRO_H
3
4using uint = unsigned int;
5
6#define TAB_ITEM(w) if (ImGui::BeginTabItem(w)) {
7#define END_TAB_ITEM() \
8 ImGui::EndTabItem(); \
9 }
10
11#define BEGIN_TABLE(l, n, f) if (ImGui::BeginTable(l, n, f, ImVec2(0, 0))) {
12#define SETUP_COLUMN(l) ImGui::TableSetupColumn(l);
13
14#define TABLE_HEADERS() \
15 ImGui::TableHeadersRow(); \
16 ImGui::TableNextRow();
17
18#define NEXT_COLUMN() ImGui::TableNextColumn();
19
20#define END_TABLE() \
21 ImGui::EndTable(); \
22 }
23
24#define HOVER_HINT(string) \
25 if (ImGui::IsItemHovered()) ImGui::SetTooltip(string)
26
27#define PRINT_IF_ERROR(expression) \
28 { \
29 auto error = expression; \
30 if (!error.ok()) { \
31 std::cout << error.ToString() << std::endl; \
32 } \
33 }
34
35#define EXIT_IF_ERROR(expression) \
36 { \
37 auto error = expression; \
38 if (!error.ok()) { \
39 std::cout << error.ToString() << std::endl; \
40 return EXIT_FAILURE; \
41 } \
42 }
43
44#define RETURN_VOID_IF_ERROR(expression) \
45 { \
46 auto error = expression; \
47 if (!error.ok()) { \
48 std::cout << error.ToString() << std::endl; \
49 return; \
50 } \
51 }
52
53#define RETURN_IF_ERROR(expression) \
54 { \
55 auto error = expression; \
56 if (!error.ok()) { \
57 return error; \
58 } \
59 }
60
61#define ASSIGN_OR_RETURN(type_variable_name, expression) \
62 ASSIGN_OR_RETURN_IMPL(APPEND_NUMBER(error_or_value, __LINE__), \
63 type_variable_name, expression)
64
65#define ASSIGN_OR_RETURN_IMPL(error_or_value, type_variable_name, expression) \
66 auto error_or_value = expression; \
67 if (!error_or_value.ok()) { \
68 return error_or_value.status(); \
69 } \
70 type_variable_name = std::move(*error_or_value)
71
72#define ASSIGN_OR_LOG_ERROR(type_variable_name, expression) \
73 ASSIGN_OR_LOG_ERROR_IMPL(APPEND_NUMBER(error_or_value, __LINE__), \
74 type_variable_name, expression)
75
76#define ASSIGN_OR_LOG_ERROR_IMPL(error_or_value, type_variable_name, \
77 expression) \
78 auto error_or_value = expression; \
79 if (!error_or_value.ok()) { \
80 std::cout << error_or_value.status().ToString() << std::endl; \
81 } \
82 type_variable_name = std::move(*error_or_value);
83
84#define APPEND_NUMBER(expression, number) \
85 APPEND_NUMBER_INNER(expression, number)
86
87#define APPEND_NUMBER_INNER(expression, number) expression##number
88
89#define TEXT_WITH_SEPARATOR(text) \
90 ImGui::Text(text); \
91 ImGui::Separator();
92
93#define TABLE_BORDERS_RESIZABLE \
94 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable
95
96#define CLEAR_AND_RETURN_STATUS(status) \
97 if (!status.ok()) { \
98 auto temp = status; \
99 status = absl::OkStatus(); \
100 return temp; \
101 }
102
103#define RETURN_IF_EXCEPTION(expression) \
104 try { \
105 expression; \
106 } catch (const std::exception &e) { \
107 std::cerr << e.what() << std::endl; \
108 return EXIT_FAILURE; \
109 }
110
111#define SDL_RETURN_IF_ERROR() \
112 if (SDL_GetError() != nullptr) { \
113 return absl::InternalError(SDL_GetError()); \
114 }
115
116#endif // YAZE_UTIL_MACRO_H
unsigned int uint
Definition macro.h:4