libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
print_contract.hpp
1#pragma once
2
3#include <concepts>
4#include <cstddef>
5#include <cstdint>
6#include <string_view>
7#include <type_traits>
8
9#include "../libxr_def.hpp"
10#include "format_protocol.hpp"
11
12namespace LibXR::Print
13{
14
23template <typename Sink>
24concept OutputSink = requires(Sink& output, std::string_view text) {
25 { output.Write(text) } -> std::convertible_to<ErrorCode>;
26};
27
36template <typename Frontend>
37concept SourceFrontend = requires {
38 typename Frontend::ErrorType;
39 { Frontend::SourceData() } -> std::convertible_to<const char*>;
40 { Frontend::SourceSize() } -> std::convertible_to<size_t>;
41};
42
52template <typename Frontend, typename Visitor>
53concept WalkableFrontend = SourceFrontend<Frontend> && requires(Visitor& visitor) {
54 { Frontend::Walk(visitor) } -> std::same_as<typename Frontend::ErrorType>;
55};
56
65template <typename Format>
67 requires {
68 typename std::remove_cvref_t<decltype(Format::Codes())>::value_type;
69 typename std::remove_cvref_t<decltype(Format::ArgumentList())>::value_type;
70 { Format::Codes().data() } -> std::convertible_to<const uint8_t*>;
71 { Format::Codes().size() } -> std::convertible_to<size_t>;
72 { Format::ArgumentList().size() } -> std::convertible_to<size_t>;
73 { Format::ArgumentOrder().size() } -> std::convertible_to<size_t>;
74 { Format::Profile() } -> std::convertible_to<FormatProfile>;
75 } &&
76 std::same_as<typename std::remove_cvref_t<decltype(Format::Codes())>::value_type,
77 uint8_t> &&
78 std::same_as<
79 typename std::remove_cvref_t<decltype(Format::ArgumentList())>::value_type,
81
82} // namespace LibXR::Print
Writer 可执行的编译后格式对象 / Compiled format object executable by Writer.
接收编译格式输出的写入端 / Output endpoint accepted by compiled format writers
可由共享后端读取源码信息的格式前端 / Format frontend exposing source metadata to the shared backend
可向指定 visitor 发射格式事件的前端 / Frontend that can emit format events into the supplied visitor
Writer 消费的编译格式运行期协议。 / Compiled-format runtime contract consumed by Writer.