mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-01 04:31:57 -07:00
logging: implement std::formatter for some types (#3380)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "helpers/MiscFunctions.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include <cmath>
|
||||
#include <csignal>
|
||||
#include <utility>
|
||||
@@ -66,6 +64,32 @@
|
||||
|
||||
#define ASSERT(expr) RASSERT(expr, "?")
|
||||
|
||||
// absolutely ridiculous formatter spec parsing
|
||||
#define FORMAT_PARSE(specs__, type__) \
|
||||
template <typename FormatContext> \
|
||||
constexpr auto parse(FormatContext& ctx) { \
|
||||
auto it = ctx.begin(); \
|
||||
for (; it != ctx.end() && *it != '}'; it++) { \
|
||||
switch (*it) { specs__ default : throw std::format_error("invalid format specification"); } \
|
||||
} \
|
||||
return it; \
|
||||
}
|
||||
|
||||
#define FORMAT_FLAG(spec__, flag__) \
|
||||
case spec__: (flag__) = true; break;
|
||||
|
||||
#define FORMAT_NUMBER(buf__) \
|
||||
case '0': \
|
||||
case '1': \
|
||||
case '2': \
|
||||
case '3': \
|
||||
case '4': \
|
||||
case '5': \
|
||||
case '6': \
|
||||
case '7': \
|
||||
case '8': \
|
||||
case '9': (buf__).push_back(*it); break;
|
||||
|
||||
#if ISDEBUG
|
||||
#define UNREACHABLE() \
|
||||
{ \
|
||||
|
Reference in New Issue
Block a user