10#include "read_port.hpp"
11#include "write_port.hpp"
77 template <
typename CompiledFormat,
typename... Args>
81 std::tuple<Args&&...>
args;
91 auto& compiled_call = *
static_cast<CompiledCall*
>(context);
95 return Print::Write(sink, compiled_call.format,
96 std::forward<
decltype(unpacked)>(unpacked)...);
116 CompiledWriteFun write_fun);
142 template <
typename Call>
161 template <
typename CompiledFormat,
typename... Args>
162 [[nodiscard]]
static int RunCompiled(
const CompiledFormat& format, Args&&... args)
165 format, std::forward_as_tuple(std::forward<Args>(args)...)};
183 size_t retained_size,
199 return RunCompiled(format, std::forward<Args>(args)...);
213 return RunCompiled(format, std::forward<Args>(args)...);
互斥锁类,提供线程同步机制 (Mutex class providing thread synchronization mechanisms).
static consteval Compiled< Source > Build()
在编译期解析并校验 printf 格式串 / Parse and validate a printf format at compile time
ReadPort class for handling read operations.
STDIO 编译格式会话使用的流式截断输出端 / Stream-backed truncating sink used by one STDIO compiled-format session.
WritePort::Stream & stream_
Active stream session receiving retained bytes. 接收保留字节的活动流会话。
ErrorCode Write(std::string_view chunk)
追加一个文本片段;必要时按会话剩余空间直接截断 / Append one text chunk and truncate directly to the remaining session capaci...
bool saturated_
No more bytes should be retained in this session. 当前会话不再继续保留输出。
size_t retained_size_
Bytes retained so far. 当前已保留的字节数。
size_t RetainedSize() const
返回当前会话最终保留下来的字节数 / Return the retained byte count of the current session
CompiledSink(WritePort::Stream &stream)
构造一个绑定到指定流的编译格式输出端 / Construct one compiled-format sink bound to the given stream
提供静态全局的输入输出接口绑定与写会话管理 / STDIO interface for read and write ports
static int Printf(Args &&... args)
将一个编译期 printf 字面量打印到当前 STDIO 输出 / Print one compile-time printf literal to the active STDIO output
static int RunCompiledSession(Call &call)
执行一次模板已知的 STDIO 编译格式会话 / Run one STDIO compiled-format session whose format and argument types are al...
static int Print(Args &&... args)
将一个编译期 brace 字面量打印到当前 STDIO 输出 / Print one compile-time brace literal to the active STDIO output
static int RunCompiled(const CompiledFormat &format, Args &&... args)
用一份已编译格式和一组运行时参数执行一次完整的 STDIO 写会话 / Run one complete STDIO write session with one compiled format and...
static LibXR::WritePort::Stream * write_stream_
Optional externally owned write stream. 可选的外部托管写流。
static LibXR::Mutex * write_mutex_
Write port mutex. 写入端口互斥锁。
static int WriteCompiledToStream(WritePort::Stream &stream, void *context, CompiledWriteFun write_fun)
在指定 Stream 上执行一次完整的 STDIO 编译格式写入与收尾 / Run one complete STDIO compiled-format write and finalize pass ...
static ReadPort * read_
Read port instance. 读取端口。
static int FinishWriteSession(WritePort::Stream &stream, size_t retained_size, ErrorCode format_result)
提交当前编译格式会话的写入流并释放共享会话 / Commit the current compiled-format session stream and release the shared sess...
static int WriteCompiledSession(void *context, CompiledWriteFun write_fun)
执行一次完整的 STDIO 编译格式流会话选择、写入与收尾 / Run one complete STDIO compiled-format stream session: stream selecti...
static WritePort * write_
Write port instance. 写入端口。
static bool BeginWriteSession()
获取一个共享的 STDIO 写入会话 / Acquire one shared STDIO write session
WritePort class for handling write operations.
作为 printf 格式源的结构化字符串字面量包装 / Structural literal wrapper used as the NTTP source for printf formats
一次编译格式 STDIO 调用的模板上下文 / Template context for one compiled-format STDIO call
std::tuple< Args &&... > args
Forwarded runtime arguments. 转发保存的运行时参数。
static ErrorCode Write(void *context, CompiledSink &sink)
将当前模板上下文桥接到编译格式前端写入入口 / Bridge the current template context into the compiled-format write entry
const CompiledFormat & format
Compile-time compiled format object. 编译期已编译的格式对象。