libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Format< Source > Class Template Reference

Data Structures

struct  Compiled
 一条 brace 风格源串绑定到具体调用点参数后的编译结果 / One brace-style source bound to a concrete call-site argument list More...
 

Public Types

using Error = Print::Detail::FormatFrontend::Error
 面向用户的 brace 风格编译期失败类别 / Public brace-style compile-time failure categories
 
template<typename... Args>
using Compiler = Print::Detail::FormatFrontend::Compiler<Source, Args...>
 绑定到一组具体 C++ 参数类型上的前端适配器 / Frontend adapter bound to one concrete C++ argument list
 

Public Member Functions

template<Print::OutputSink Sink, typename... Args>
ErrorCode WriteTo (Sink &sink, Args &&... args) const
 将当前格式写入一个输出端,并且只返回 sink 状态 / Write this format into one sink and return only the sink status
 

Static Public Member Functions

static constexpr size_t ArgumentCount ()
 返回当前源串会寻址的调用点参数个数 / Returns the required call-site argument count addressed by this source.
 
template<typename... Args>
static consteval bool Matches ()
 判断这条源格式串能否和 Args... 一起通过编译。 / Returns whether this source string can be compiled with Args....
 

Private Types

using SourceError = Print::Detail::FormatFrontend::Error
 

Static Private Attributes

static constexpr auto source_analysis
 

Detailed Description

template<Print::Text Source>
class LibXR::Format< Source >

Definition at line 14 of file format_surface.hpp.

Member Typedef Documentation

◆ Compiler

template<Print::Text Source>
template<typename... Args>
using LibXR::Format< Source >::Compiler = Print::Detail::FormatFrontend::Compiler<Source, Args...>

绑定到一组具体 C++ 参数类型上的前端适配器 / Frontend adapter bound to one concrete C++ argument list

Template Parameters
Args这次调用点对应的 C++ 实参类型列表 / Concrete C++ argument types at one call site

Definition at line 58 of file format_surface.hpp.

◆ Error

template<Print::Text Source>
using LibXR::Format< Source >::Error = Print::Detail::FormatFrontend::Error

面向用户的 brace 风格编译期失败类别 / Public brace-style compile-time failure categories

Definition at line 49 of file format_surface.hpp.

◆ SourceError

template<Print::Text Source>
using LibXR::Format< Source >::SourceError = Print::Detail::FormatFrontend::Error
private

Definition at line 17 of file format_surface.hpp.

Member Function Documentation

◆ ArgumentCount()

template<Print::Text Source>
static constexpr size_t LibXR::Format< Source >::ArgumentCount ( )
inlinestaticnodiscardconstexpr

返回当前源串会寻址的调用点参数个数 / Returns the required call-site argument count addressed by this source.

Returns
Returns the number of call-site arguments actually referenced by this source. / 当前源串实际引用到的调用点参数个数。

Definition at line 175 of file format_surface.hpp.

176 {
177 return source_analysis.required_argument_count;
178 }

◆ Matches()

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

判断这条源格式串能否和 Args... 一起通过编译。 / Returns whether this source string can be compiled with Args....

Template Parameters
ArgsC++ argument types to test. / 待检查的 C++ 实参类型列表。
Returns
Returns true when the source can compile with Args..., otherwise false. / 可编译返回 true,否则返回 false

Definition at line 188 of file format_surface.hpp.

189 {
190 if constexpr (sizeof...(Args) != source_analysis.required_argument_count)
191 {
192 return false;
193 }
194 else
195 {
197 return Print::FormatCompiler<Frontend>::Compile().compile_error == Error::None;
198 }
199 }
Print::Detail::FormatFrontend::Compiler< Source, Args... > Compiler
绑定到一组具体 C++ 参数类型上的前端适配器 / Frontend adapter bound to one concrete C++ argument list
static consteval auto Compile()
把一个前端编译成最终字节流、参数表和 writer 摘要。 / Compiles one frontend into the final byte stream, argument table,...
Frontend
Logger literal frontend selection mode.
Definition literal.hpp:19

◆ WriteTo()

template<Print::Text Source>
template<Print::OutputSink Sink, typename... Args>
ErrorCode LibXR::Format< Source >::WriteTo ( Sink & sink,
Args &&... args ) const
inlinenodiscard

将当前格式写入一个输出端,并且只返回 sink 状态 / Write this format into one sink and return only the sink status

Template Parameters
Sink输出端类型,需满足 Print::OutputSink / Sink type satisfying Print::OutputSink
Args调用点实参类型列表 / Call-site argument types
Parameters
sink输出端 / Destination sink
args本次写出使用的实参 / Arguments used by this write
Returns
sink 写入状态 / Returns the sink write status

Definition at line 212 of file format_surface.hpp.

213 {
214 using Built = Compiled<std::remove_cvref_t<Args>...>;
215 return Print::Writer::template RunArgumentOrder<Sink, Built, Built::ArgumentOrder()>(
216 sink, Built{}, std::forward<Args>(args)...);
217 }

Field Documentation

◆ source_analysis

template<Print::Text Source>
auto LibXR::Format< Source >::source_analysis
inlinestaticconstexprprivate
Initial value:
=
consteval auto Analyze()
对单条 brace 风格字面量执行仅源串分析 / Run source-only analysis for one brace-style literal

Definition at line 18 of file format_surface.hpp.


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