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 "format_protocol.hpp"
10#include "libxr_def.hpp"
11
12namespace LibXR::Print
13{
14
19template <typename Sink>
20concept OutputSink = requires(Sink& output, std::string_view text)
21{
22 { output.Write(text) } -> std::convertible_to<ErrorCode>;
23};
24
29template <typename Frontend>
30concept SourceFrontend = requires
31{
32 typename Frontend::ErrorType;
33 { Frontend::SourceData() } -> std::convertible_to<const char*>;
34 { Frontend::SourceSize() } -> std::convertible_to<size_t>;
35};
36
41template <typename Frontend, typename Visitor>
43 SourceFrontend<Frontend> && requires(Visitor& visitor)
44{
45 { Frontend::Walk(visitor) } -> std::same_as<typename Frontend::ErrorType>;
46};
47
52template <typename Format>
53concept CompiledFormat = requires
54{
55 typename std::remove_cvref_t<decltype(Format::Codes())>::value_type;
56 typename std::remove_cvref_t<decltype(Format::ArgumentList())>::value_type;
57 { Format::Codes().data() } -> std::convertible_to<const uint8_t*>;
58 { Format::Codes().size() } -> std::convertible_to<size_t>;
59 { Format::ArgumentList().size() } -> std::convertible_to<size_t>;
60 { Format::ArgumentOrder().size() } -> std::convertible_to<size_t>;
61 { Format::Profile() } -> std::convertible_to<FormatProfile>;
62} && std::same_as<typename std::remove_cvref_t<decltype(Format::Codes())>::value_type,
63 uint8_t> &&
64 std::same_as<
65 typename std::remove_cvref_t<decltype(Format::ArgumentList())>::value_type,
67
68} // namespace LibXR::Print
Writer 可执行的编译后格式对象。
接收编译格式输出的写入端。
可由共享后端读取源码信息的格式前端。
可向指定 visitor 发射格式事件的前端。
Compiled-format runtime contract consumed by Writer.