23#ifndef LIBXR_PRINT_ENABLE_INTEGER
24#define LIBXR_PRINT_ENABLE_INTEGER 1
27#ifndef LIBXR_PRINT_ENABLE_TEXT
28#define LIBXR_PRINT_ENABLE_TEXT 1
31#ifndef LIBXR_PRINT_ENABLE_POINTER
32#define LIBXR_PRINT_ENABLE_POINTER 0
35#ifndef LIBXR_PRINT_ENABLE_FLOAT
36#define LIBXR_PRINT_ENABLE_FLOAT 1
39#ifndef LIBXR_PRINT_INTEGER_ENABLE_BASE8_16
40#define LIBXR_PRINT_INTEGER_ENABLE_BASE8_16 1
43#ifndef LIBXR_PRINT_INTEGER_ENABLE_64BIT
44#define LIBXR_PRINT_INTEGER_ENABLE_64BIT 0
47#ifndef LIBXR_PRINT_FLOAT_ENABLE_FIXED
48#define LIBXR_PRINT_FLOAT_ENABLE_FIXED 1
51#ifndef LIBXR_PRINT_FLOAT_ENABLE_DOUBLE
52#define LIBXR_PRINT_FLOAT_ENABLE_DOUBLE 0
55#ifndef LIBXR_PRINT_FLOAT_ENABLE_SCIENTIFIC
56#define LIBXR_PRINT_FLOAT_ENABLE_SCIENTIFIC 0
59#ifndef LIBXR_PRINT_FLOAT_ENABLE_GENERAL
60#define LIBXR_PRINT_FLOAT_ENABLE_GENERAL 0
63#ifndef LIBXR_PRINT_FLOAT_ENABLE_LONG_DOUBLE
64#define LIBXR_PRINT_FLOAT_ENABLE_LONG_DOUBLE 0
67#ifndef LIBXR_PRINT_ENABLE_WIDTH
68#define LIBXR_PRINT_ENABLE_WIDTH 1
71#ifndef LIBXR_PRINT_ENABLE_PRECISION
72#define LIBXR_PRINT_ENABLE_PRECISION 1
75#ifndef LIBXR_PRINT_ENABLE_ALTERNATE
76#define LIBXR_PRINT_ENABLE_ALTERNATE 0
79#ifndef LIBXR_PRINT_ENABLE_EXPLICIT_ARGUMENT_INDEXING
80#define LIBXR_PRINT_ENABLE_EXPLICIT_ARGUMENT_INDEXING 0
83namespace LibXR::Print::Config
86inline constexpr bool enable_integer = LIBXR_PRINT_ENABLE_INTEGER;
88inline constexpr bool enable_text = LIBXR_PRINT_ENABLE_TEXT;
90inline constexpr bool enable_pointer = LIBXR_PRINT_ENABLE_POINTER;
92inline constexpr bool enable_float = LIBXR_PRINT_ENABLE_FLOAT;
95inline constexpr bool enable_integer_base8_16 =
96 enable_integer && LIBXR_PRINT_INTEGER_ENABLE_BASE8_16;
98inline constexpr bool enable_integer_64bit =
99 enable_integer && LIBXR_PRINT_INTEGER_ENABLE_64BIT;
102inline constexpr bool enable_float_fixed =
103 enable_float && LIBXR_PRINT_FLOAT_ENABLE_FIXED;
105inline constexpr bool enable_float_double =
106 enable_float && LIBXR_PRINT_FLOAT_ENABLE_DOUBLE;
108inline constexpr bool enable_float_scientific =
109 enable_float && LIBXR_PRINT_FLOAT_ENABLE_SCIENTIFIC;
111inline constexpr bool enable_float_general =
112 enable_float && LIBXR_PRINT_FLOAT_ENABLE_GENERAL;
114inline constexpr bool enable_float_long_double =
115 enable_float_double && LIBXR_PRINT_FLOAT_ENABLE_LONG_DOUBLE;
118inline constexpr bool enable_width = LIBXR_PRINT_ENABLE_WIDTH;
120inline constexpr bool enable_precision = LIBXR_PRINT_ENABLE_PRECISION;
122inline constexpr bool enable_alternate = LIBXR_PRINT_ENABLE_ALTERNATE;
124inline constexpr bool enable_explicit_argument_indexing =
125 LIBXR_PRINT_ENABLE_EXPLICIT_ARGUMENT_INDEXING;
128namespace LibXR::Print
149enum class FormatArgumentRule : uint8_t
183enum class FormatFlag : uint8_t
191 CenterAlign = 1U << 6,
205enum class FormatOp : uint8_t
211 U32ZeroPadWidth = 0x11,
223enum class FormatType : uint8_t
251 LongDoubleScientific,
263enum class FormatPackKind : uint8_t
285enum class FormatProfile : uint8_t
296[[nodiscard]]
constexpr FormatProfile operator|(FormatProfile left, FormatProfile right)
298 return static_cast<FormatProfile
>(
static_cast<uint8_t
>(left) |
299 static_cast<uint8_t
>(right));
303constexpr FormatProfile& operator|=(FormatProfile& left, FormatProfile right)
310[[nodiscard]]
constexpr bool HasProfile(FormatProfile profile, FormatProfile bit)
312 return (
static_cast<uint8_t
>(profile) &
static_cast<uint8_t
>(bit)) != 0;
346 FormatArgumentRule::None;
349 "LibXR::Print::FormatArgumentInfo must stay tightly packed");
368 FormatType
type = FormatType::End;
371 FormatArgumentRule::None;
386[[nodiscard]]
constexpr size_t FormatArgumentBytes(FormatPackKind pack)
390 case FormatPackKind::I32:
391 return sizeof(int32_t);
392 case FormatPackKind::I64:
393 return sizeof(int64_t);
394 case FormatPackKind::U32:
395 return sizeof(uint32_t);
396 case FormatPackKind::U64:
397 return sizeof(uint64_t);
398 case FormatPackKind::Pointer:
399 return sizeof(uintptr_t);
400 case FormatPackKind::Character:
402 case FormatPackKind::StringView:
403 return sizeof(std::string_view);
404 case FormatPackKind::F32:
405 return sizeof(float);
406 case FormatPackKind::F64:
407 return sizeof(double);
408 case FormatPackKind::LongDouble:
409 return sizeof(
long double);