42template <Pr
int::Text Source>
45 for (
size_t i = 0; i < Source.Size(); ++i)
47 if (Source.data[i] ==
'{' || Source.data[i] ==
'}')
59template <Pr
int::Text Source>
62 for (
size_t i = 0; i < Source.Size(); ++i)
64 if (Source.data[i] ==
'%')
76template <Pr
int::Text Source>
79 return Print::Detail::FormatFrontend::Analyze<Source>().error ==
80 Print::Detail::FormatFrontend::Error::None;
87template <Pr
int::Text Source>
90 return Print::Detail::PrintfCompile::Analyze<Source>().error ==
91 Print::Printf::Error::None;
105template <Print::Text Source,
typename... Args>
123template <Print::Text Source,
typename... Args>
132 return Print::Printf::template Matches<Source, Args...>();
141template <
Frontend Forced, Print::Text Source,
typename... Args>
144 constexpr bool format_match =
FormatMatches<Source, Args...>();
145 constexpr bool printf_match =
PrintfMatches<Source, Args...>();
155 else if constexpr (format_match && !printf_match)
159 else if constexpr (!format_match && printf_match)
163 else if constexpr (!format_match && !printf_match)
172 if constexpr (format_uses_syntax && !printf_uses_syntax)
176 else if constexpr (!format_uses_syntax && printf_uses_syntax)
180 else if constexpr (!format_uses_syntax && !printf_uses_syntax)
196template <
Frontend Forced, Print::Text Source,
typename... Args>
199 constexpr auto resolution =
ResolveFrontend<Forced, Source, Args...>();
205 "LibXR::Logger: XR_FMT(...) literal is not accepted by the brace frontend");
212 "LibXR::Logger: XR_PRINTF(...) literal is not accepted by the printf frontend");
226 "LibXR::Logger: literal is ambiguous between brace and printf "
227 "frontends; use XR_FMT(...) or XR_PRINTF(...)");
233 "LibXR::Logger: literal matches neither brace nor printf frontend");
Logger 的字面量前端选择片段 Literal-frontend selection fragment of Logger
consteval bool UsesPrintfSyntax()
判断一条合法 printf 字面量是否真的使用了 printf 语法。 Returns whether one valid printf literal actually uses printf syn...
consteval Resolution ResolveFrontend()
为一条 logger 字面量及一组具体参数选择前端。 Selects the logger frontend for one literal plus one concrete argument lis...
Frontend
Logger 字面量前端选择模式 / Logger literal frontend selection mode.
@ Auto
自动选择 brace 或 printf / select brace or printf automatically
@ Format
强制使用 brace 风格前端 / force brace-style frontend
@ Printf
强制使用 printf 风格前端 / force printf-style frontend
consteval bool FormatSourceValid()
判断一条 brace 风格源串在源级上是否合法。 Returns whether one brace-style source is source-level valid.
consteval bool FormatMatches()
判断一组参数是否能被 brace 前端接受;会先做源级合法性保护。 Returns whether one argument list is accepted by the brace frontend...
consteval bool PrintfMatches()
判断一组参数是否能被 printf 前端接受;会先做源级合法性保护。 Returns whether one argument list is accepted by the printf fronte...
consteval bool UsesFormatSyntax()
判断一条合法 brace 字面量是否真的使用了 brace 语法。 Returns whether one valid brace literal actually uses brace syntax.
Resolution
将一条 logger 字面量与可用前端进行解析后的结果。 Result of resolving one logger literal against the available frontends.
@ Format
选择 brace 风格前端 / select brace-style frontend
@ None
两个前端都不匹配 / matches neither frontend
@ Printf
选择 printf 风格前端 / select printf-style frontend
consteval Frontend SelectFrontend()
在校验解析结果后,选择最终 logger 前端。 Selects the final logger frontend after validating the resolution result.
consteval bool PrintfSourceValid()
判断一条 printf 风格源串在源级上是否合法。 Returns whether one printf-style source is source-level valid.