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)
62 template<
typename It,
typename... Args>
63 [[nodiscard]]
constexpr parse_error(It first, It last,
int tab_size,
char const *msg, Args
const&...args) noexcept :
64 runtime_error(make_what(first, last, tab_size, msg, args...))
75 template<
typename It,
typename... Args>
76 [[nodiscard]]
constexpr parse_error(It first, It last,
char const *msg, Args
const&...args) noexcept :
92 auto column_nr = 0_uz;
94 auto c32 =
char32_t{};
95 auto continue_count =
int{};
96 while (first != last) {
97 hilet c8 = char_cast<char8_t>(*first++);
99 if ((c8 & 0xc0) == 0x80) {
104 }
else if (c8 & 0x80) {
105 continue_count = std::countl_one(c8) - 1;
106 c32 = c8 & (0b00'111'111 >> continue_count);
113 if (not continue_count) {
128 column_nr /= tab_size;
129 column_nr *= tab_size;
136 return {line_nr, column_nr};
140 template<
typename It,
typename... Args>
142 make_what(It first, It last,
size_t tab_size,
char const *msg, Args
const&...args)
noexcept
144 hilet[line_nr, column_nr] = get_line_position(first, last, tab_size);
145 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() noexcept
Get the OS error message from the last error received on this thread.
Exception thrown during parsing on an error.
Definition exception.hpp:50
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:76
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:89
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:63
Exception thrown when an item was not found.
Definition exception.hpp:151
Exception thrown during execution of a dynamic operation.
Definition exception.hpp:163
Exception thrown during I/O on an error.
Definition exception.hpp:175
Exception thrown during an operating system call.
Definition exception.hpp:186
Definition exception.hpp:191
Definition exception.hpp:196
Definition exception.hpp:201
Definition exception.hpp:206
Cancel error is caused by user pressing cancel.
Definition exception.hpp:215
T runtime_error(T... args)