libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
writer_reader.hpp
1#pragma once
2
3#include <cstdint>
4#include <cstring>
5#include <string_view>
6
11{
12 public:
19 explicit CodeReader(const uint8_t* codes);
20
25 [[nodiscard]] FormatOp ReadOp();
26
33 template <typename T>
34 [[nodiscard]] T Read()
35 {
36 T value{};
37 std::memcpy(&value, pos_, sizeof(T));
38 pos_ += sizeof(T);
39 return value;
40 }
41
47 [[nodiscard]] FormatType ReadFormatType();
48
59 [[nodiscard]] Spec ReadSpec();
60
66 [[nodiscard]] std::string_view ReadInlineText();
67
77 [[nodiscard]] std::string_view ReadTextRef();
78
79 private:
80 const uint8_t* pos_ = nullptr;
81 const uint8_t* base_ = nullptr;
82};
83
89{
90 public:
97 explicit ArgumentReader(const uint8_t* data);
98
105 template <typename T>
106 [[nodiscard]] T Read()
107 {
108 T value{};
109 std::memcpy(&value, pos_, sizeof(T));
110 pos_ += sizeof(T);
111 return value;
112 }
113
114 private:
115 const uint8_t* pos_ = nullptr;
116};
运行期参数字节块的顺序读取器 / Sequential reader for the packed runtime argument byte blob
ArgumentReader(const uint8_t *data)
从单个运行期参数打包字节块构造读取器 / Create a reader over one packed runtime argument blob
T Read()
以无对齐要求的方式读取一个已打包参数值 / Read one packed argument value without requiring alignment
编译后记录流的顺序读取器 / Sequential reader for the compiled record stream
std::string_view ReadInlineText()
读取内嵌在记录流中的短文本 / Read a null-terminated short text payload embedded in the record stream
std::string_view ReadTextRef()
读取指向尾部文本池的偏移和长度 / Read an offset-size pair pointing into the trailing text pool
CodeReader(const uint8_t *codes)
从单个编译字节块起点构造读取器 / Create a reader over the beginning of one compiled byte blob
T Read()
读取编译期发射器按本机字节序写入的 POD 值 / Read a native-endian POD value emitted by the compile-time emitter
FormatOp ReadOp()
读取下一条运行期操作码 / Read the next runtime opcode
Spec ReadSpec()
读取紧跟在 GenericField 类型字节后的 4 字节字段载荷 / Read the 4-byte field payload that follows one GenericField type...
FormatType ReadFormatType()
读取 GenericField 载荷中的语义类型字节 / Read the semantic type byte carried by one GenericField payload