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

printf 风格前端,输出内部格式表示 / Printf-style frontend that emits the internal format representation More...

#include <printf.hpp>

Data Structures

struct  Compiled
 
class  Compiler
 单个 printf 源字符串的编译期前端,负责解析并降为共享格式语义 / 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
}
 归一化后的 printf 长度修饰符 / Supported printf length modifiers after normalization More...
 
enum class  Error : uint8_t {
  None , NumberOverflow , FloatPrecisionLimitExceeded , UnexpectedEnd ,
  EmbeddedNul , MixedIndexing , PositionalArgumentDisabled , DynamicField ,
  InvalidArgumentIndex , InvalidSpecifier , InvalidLength , ConflictingArgument ,
  TextOffsetOverflow , TextSizeOverflow
}
 通过 static_assert 暴露的编译期解析或构建失败类别 / Compile-time parse or build failure categories surfaced through static_assert More...
 

Static Public Member Functions

template<Text Source>
static consteval Compiled< Source > Build ()
 在编译期解析并校验 printf 格式串 / Parse and validate a printf format at compile time
 
template<Text Source, typename... Args>
static consteval bool Matches ()
 判断 Args... 是否与启用的转换项精确匹配 / Return whether Args... exactly match the enabled conversions
 

Detailed Description

printf 风格前端,输出内部格式表示 / Printf-style frontend that emits the internal format representation

Definition at line 57 of file printf.hpp.

Member Enumeration Documentation

◆ Error

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

通过 static_assert 暴露的编译期解析或构建失败类别 / Compile-time parse or build failure categories surfaced through static_assert

Enumerator
None 

success / 成功

NumberOverflow 

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

FloatPrecisionLimitExceeded 

float precision exceeds the configured frontend limit / 浮点精度超出当前配置的前端上限

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 81 of file printf.hpp.

◆ Length

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

归一化后的 printf 长度修饰符 / Supported printf length modifiers after normalization

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 64 of file printf.hpp.

65 {
66 Default,
67 Char,
68 Short,
69 Long,
70 LongLong,
71 IntMax,
72 Size,
73 PtrDiff,
75 };
@ 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

在编译期解析并校验 printf 格式串 / Parse and validate a printf format at compile time

Template Parameters
Sourceprintf 风格格式串字面量 / Printf-style format literal
Returns
编译后的 printf 格式对象 / Returns the compiled printf format object

Definition at line 123 of file printf.hpp.

124 {
125 return {};
126 }

◆ Matches()

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

判断 Args... 是否与启用的转换项精确匹配 / Return whether Args... exactly match the enabled conversions

Template Parameters
Sourceprintf 风格格式串字面量 / Printf-style format literal
Args待检查的 C++ 实参类型列表 / C++ argument types to test
Returns
完全匹配返回 true,否则返回 false / Returns true when the enabled conversions match Args... exactly, otherwise false

Definition at line 137 of file printf.hpp.

138 {
139 return Compiled<Source>::template Matches<Args...>();
140 }
static consteval bool Matches()
判断 Args... 是否与启用的转换项精确匹配 / Return whether Args... exactly match the enabled conversions
Definition printf.hpp:137

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