libxr
Embedded C++ framework for bare-metal, RTOS and Linux
Loading...
Searching...
No Matches
LibXR::Print::Printf Class Reference

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

#include <printf.hpp>

Classes

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 

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

MixedIndexing 

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

PositionalArgumentDisabled 

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

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 

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

TextSizeOverflow 

文本长度超出 uint16_t referenced text size no longer fits in 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 

char 长度修饰 / hh

Short 

short 长度修饰 / h

Long 

long 长度修饰 / l

LongLong 

long long 长度修饰 / ll

IntMax 

intmax_t 长度修饰 / j

Size 

size_t 长度修饰 / z

PtrDiff 

ptrdiff_t 长度修饰 / t

LongDouble 

long double 长度修饰 / L

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
long long 长度修饰 / ll
@ IntMax
intmax_t 长度修饰 / j
@ PtrDiff
ptrdiff_t 长度修饰 / t
@ Short
short 长度修饰 / h
@ Size
size_t 长度修饰 / z
@ LongDouble
long double 长度修饰 / L
@ Default
无长度修饰符 / no length modifier
@ Long
long 长度修饰 / l
@ Char
char 长度修饰 / hh

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

125 {
126 return {};
127 }

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

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

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