libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Print::Printf Class Reference

Printf-style frontend that emits the internal format representation. More...

#include <printf.hpp>

Data Structures

struct  Compiled
 
class  Compiler
 Compile-time printf frontend that parses and lowers one source string. More...
 

Public Types

enum class  Length : uint8_t {
  Default , Char , Short , Long ,
  LongLong , IntMax , Size , PtrDiff ,
  LongDouble
}
 Supported printf length modifiers after normalization. More...
 
enum class  Error : uint8_t {
  None , NumberOverflow , UnexpectedEnd , EmbeddedNul ,
  MixedIndexing , PositionalArgumentDisabled , DynamicField , InvalidArgumentIndex ,
  InvalidSpecifier , InvalidLength , ConflictingArgument , TextOffsetOverflow ,
  TextSizeOverflow
}
 Compile-time parse/build failure categories surfaced through static_assert. More...
 

Static Public Member Functions

template<Text Source>
static consteval Compiled< Source > Build ()
 Parses and validates a printf format at compile time.
 
template<Text Source, typename... Args>
static consteval bool Matches ()
 Returns true when Args... exactly match the enabled conversions.
 

Detailed Description

Printf-style frontend that emits the internal format representation.

printf 风格前端,输出内部格式表示。

Definition at line 43 of file printf.hpp.

Member Enumeration Documentation

◆ Error

enum class LibXR::Print::Printf::Error : uint8_t
strong

Compile-time parse/build failure categories surfaced through static_assert.

通过 static_assert 暴露的编译期解析/构建失败类别。

Enumerator
None 

success / 成功

NumberOverflow 

width / precision literal does not fit in its field / 宽度或精度字面量超出字段范围

UnexpectedEnd 

format string ended in the middle of one conversion / 格式串在转换项中途结束

EmbeddedNul 

format literal contains an embedded NUL byte / 格式串字面量内部包含嵌入式 NUL 字节

MixedIndexing 

positional and sequential arguments were mixed / 混用了位置参数与顺序参数

PositionalArgumentDisabled 

positional n$ indexing is disabled by configuration / 位置参数 n$ 索引已被配置关闭

DynamicField 
  • width / precision is not supported / 不支持 * 宽度或精度
InvalidArgumentIndex 

positional argument index is invalid / 位置参数索引非法

InvalidSpecifier 

unsupported or disabled conversion specifier / 转换说明符无效或被禁用

InvalidLength 

length modifier is incompatible with the conversion / 长度修饰符与转换说明不兼容

ConflictingArgument 

one positional argument was reused with incompatible rules / 同一位置参数被不兼容的规则重复使用

TextOffsetOverflow 

referenced text offset no longer fits in uint16_t / 文本池偏移超出 uint16_t

TextSizeOverflow 

referenced text size no longer fits in uint16_t / 文本长度超出 uint16_t

Definition at line 67 of file printf.hpp.

68 {
69 None,
82 };
@ TextOffsetOverflow
referenced text offset no longer fits in uint16_t / 文本池偏移超出 uint16_t
@ UnexpectedEnd
format string ended in the middle of one conversion / 格式串在转换项中途结束
@ TextSizeOverflow
referenced text size no longer fits in uint16_t / 文本长度超出 uint16_t
@ InvalidArgumentIndex
positional argument index is invalid / 位置参数索引非法
@ NumberOverflow
width / precision literal does not fit in its field / 宽度或精度字面量超出字段范围
@ None
success / 成功
@ MixedIndexing
positional and sequential arguments were mixed / 混用了位置参数与顺序参数
@ InvalidLength
length modifier is incompatible with the conversion / 长度修饰符与转换说明不兼容
@ EmbeddedNul
format literal contains an embedded NUL byte / 格式串字面量内部包含嵌入式 NUL 字节
@ InvalidSpecifier
unsupported or disabled conversion specifier / 转换说明符无效或被禁用
@ PositionalArgumentDisabled
positional n$ indexing is disabled by configuration / 位置参数 n$ 索引已被配置关闭
@ ConflictingArgument
one positional argument was reused with incompatible rules / 同一位置参数被不兼容的规则重复使用

◆ Length

enum class LibXR::Print::Printf::Length : uint8_t
strong

Supported printf length modifiers after normalization.

归一化后的 printf 长度修饰符。

Enumerator
Default 

no length modifier / 无长度修饰符

Char 

hh / char 长度修饰

Short 

h / short 长度修饰

Long 

l / long 长度修饰

LongLong 

ll / long long 长度修饰

IntMax 

j / intmax_t 长度修饰

Size 

z / size_t 长度修饰

PtrDiff 

t / ptrdiff_t 长度修饰

LongDouble 

L / long double 长度修饰

Definition at line 50 of file printf.hpp.

51 {
52 Default,
53 Char,
54 Short,
55 Long,
56 LongLong,
57 IntMax,
58 Size,
59 PtrDiff,
61 };
@ LongLong
ll / long long 长度修饰
@ IntMax
j / intmax_t 长度修饰
@ PtrDiff
t / ptrdiff_t 长度修饰
@ Short
h / short 长度修饰
@ Size
z / size_t 长度修饰
@ LongDouble
L / long double 长度修饰
@ Default
no length modifier / 无长度修饰符
@ Long
l / long 长度修饰
@ Char
hh / char 长度修饰

Member Function Documentation

◆ Build()

template<Text Source>
static consteval Compiled< Source > LibXR::Print::Printf::Build ( )
inlinestaticnodiscardconsteval

Parses and validates a printf format at compile time.

在编译期解析并校验 printf 格式串。

Definition at line 95 of file printf.hpp.

96 {
97 return {};
98 }

◆ Matches()

template<Text Source, typename... Args>
static consteval bool LibXR::Print::Printf::Matches ( )
inlinestaticnodiscardconsteval

Returns true when Args... exactly match the enabled conversions.

当 Args... 与启用的转换项精确匹配时返回 true。

Definition at line 105 of file printf.hpp.

106 {
107 return Compiled<Source>::template Matches<Args...>();
108 }
static consteval bool Matches()
Returns true when Args... exactly match the enabled conversions.
Definition printf.hpp:105

The documentation for this class was generated from the following file: