HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
check.hpp
1
// Copyright Take Vos 2020.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
#pragma once
6
7
#include "exception.hpp"
8
#include "utils.hpp"
9
#include <format>
10
11
namespace
hi::inline v1 {
12
13
#define hi_parse_check(expression, message, ...) \
14
do { \
15
if (!(expression)) { \
16
if constexpr (__VA_OPT__(not ) false) { \
17
throw ::hi::parse_error(std::format(message __VA_OPT__(, ) __VA_ARGS__)); \
18
} else { \
19
throw ::hi::parse_error(message); \
20
} \
21
} \
22
} while (false)
23
24
#define hi_hresult_check(expression) \
25
([](HRESULT result) { \
26
if (FAILED(result)) { \
27
throw ::hi::io_error(std::format("Call to '{}' failed with {:08x}", #expression, result)); \
28
} \
29
return result; \
30
}(expression))
31
32
}
// namespace hi::inline v1
Generated on Mon Apr 22 2024 12:52:40 for HikoGUI by
1.10.0