17namespace hi {
inline namespace v1 {
30#define hi_set_terminate_message(...) \
31 ::hi::terminate_message.store(__FILE__ ":" hi_stringify(__LINE__) ":" __VA_ARGS__, std::memory_order::relaxed)
75 template<
typename It,
typename... Args>
76 [[nodiscard]]
constexpr parse_error(It first, It last,
int tab_size,
char const *msg, Args
const&...args) noexcept :
77 runtime_error(make_what(first, last, tab_size, msg, args...))
88 template<
typename It,
typename... Args>
89 [[nodiscard]]
constexpr parse_error(It first, It last,
char const *msg, Args
const&...args) noexcept :
101 template<
typename It>
105 auto column_nr = 0_uz;
107 auto c32 =
char32_t{};
108 auto continue_count =
int{};
109 while (first != last) {
110 hilet c8 = char_cast<char8_t>(*first++);
112 if ((c8 & 0xc0) == 0x80) {
117 }
else if (c8 & 0x80) {
118 continue_count = std::countl_one(c8) - 1;
119 c32 = c8 & (0b00'111'111 >> continue_count);
126 if (not continue_count) {
141 column_nr /= tab_size;
142 column_nr *= tab_size;
149 return {line_nr, column_nr};
153 template<
typename It,
typename... Args>
155 make_what(It first, It last,
size_t tab_size,
char const *msg, Args
const&...args)
noexcept
157 hilet[line_nr, column_nr] = get_line_position(first, last, tab_size);
158 return {std::format(
"{}:{}: {}", line_nr + 1, column_nr + 1, std::format(msg, args...))};
Utilities used by the HikoGUI library itself.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
std::atomic< char const * > terminate_message
Message to show when the application is terminated.
Definition exception.hpp:21
std::string get_last_error_message()
Get the OS error message from the last error received on this thread.
uint32_t get_last_error_code() noexcept
Get the OS error code from the last error received on this thread.
Exception thrown during parsing on an error.
Definition exception.hpp:63
constexpr parse_error(It first, It last, char const *msg, Args const &...args) noexcept
Create a parse error at a specific point in UTF-8 encoded text.
Definition exception.hpp:89
static constexpr std::pair< size_t, size_t > get_line_position(It first, It last, size_t tab_size) noexcept
Get the line and column position of an iterator in a UTF-8 string.
Definition exception.hpp:102
constexpr parse_error(It first, It last, int tab_size, char const *msg, Args const &...args) noexcept
Create a parse error at a specific point in UTF-8 encoded text.
Definition exception.hpp:76
Exception thrown when an item was not found.
Definition exception.hpp:164
Exception thrown during execution of a dynamic operation.
Definition exception.hpp:176
Exception thrown during I/O on an error.
Definition exception.hpp:188
Exception thrown during an operating system call.
Definition exception.hpp:199
Definition exception.hpp:204
Definition exception.hpp:209
Definition exception.hpp:214
Definition exception.hpp:219
Cancel error is caused by user pressing cancel.
Definition exception.hpp:228
T runtime_error(T... args)