24 : InputBuffer(InputBuffer), Current(InputBuffer.getBufferStart()),
25 End(InputBuffer.getBufferEnd()) {}
33 uint8_t FB =
static_cast<uint8_t
>(*Current++);
43 case FirstByte::False:
49 return readInt<int8_t>(Obj);
50 case FirstByte::Int16:
52 return readInt<int16_t>(Obj);
53 case FirstByte::Int32:
55 return readInt<int32_t>(Obj);
56 case FirstByte::Int64:
58 return readInt<int64_t>(Obj);
61 return readUInt<uint8_t>(Obj);
62 case FirstByte::UInt16:
64 return readUInt<uint16_t>(Obj);
65 case FirstByte::UInt32:
67 return readUInt<uint32_t>(Obj);
68 case FirstByte::UInt64:
70 return readUInt<uint64_t>(Obj);
71 case FirstByte::Float32:
73 if (
sizeof(
float) > remainingSpace())
74 return make_error<StringError>(
75 "Invalid Float32 with insufficient payload",
78 Current +=
sizeof(float);
80 case FirstByte::Float64:
82 if (
sizeof(
double) > remainingSpace())
83 return make_error<StringError>(
84 "Invalid Float64 with insufficient payload",
87 Current +=
sizeof(double);
91 return readRaw<uint8_t>(Obj);
92 case FirstByte::Str16:
94 return readRaw<uint16_t>(Obj);
95 case FirstByte::Str32:
97 return readRaw<uint32_t>(Obj);
100 return readRaw<uint8_t>(Obj);
101 case FirstByte::Bin16:
103 return readRaw<uint16_t>(Obj);
104 case FirstByte::Bin32:
106 return readRaw<uint32_t>(Obj);
107 case FirstByte::Array16:
109 return readLength<uint16_t>(Obj);
110 case FirstByte::Array32:
112 return readLength<uint32_t>(Obj);
113 case FirstByte::Map16:
115 return readLength<uint16_t>(Obj);
116 case FirstByte::Map32:
118 return readLength<uint32_t>(Obj);
119 case FirstByte::FixExt1:
121 return createExt(Obj, FixLen::Ext1);
122 case FirstByte::FixExt2:
124 return createExt(Obj, FixLen::Ext2);
125 case FirstByte::FixExt4:
127 return createExt(Obj, FixLen::Ext4);
128 case FirstByte::FixExt8:
130 return createExt(Obj, FixLen::Ext8);
131 case FirstByte::FixExt16:
133 return createExt(Obj, FixLen::Ext16);
134 case FirstByte::Ext8:
136 return readExt<uint8_t>(Obj);
137 case FirstByte::Ext16:
139 return readExt<uint16_t>(Obj);
140 case FirstByte::Ext32:
142 return readExt<uint32_t>(Obj);
145 if ((FB & FixBitsMask::NegativeInt) == FixBits::NegativeInt) {
148 static_assert(
sizeof(I) ==
sizeof(FB),
"Unexpected type sizes");
149 memcpy(&I, &FB,
sizeof(FB));
154 if ((FB & FixBitsMask::PositiveInt) == FixBits::PositiveInt) {
160 if ((FB & FixBitsMask::String) == FixBits::String) {
163 return createRaw(Obj, Size);
166 if ((FB & FixBitsMask::Array) == FixBits::Array) {
172 if ((FB & FixBitsMask::Map) == FixBits::Map) {
178 return make_error<StringError>(
183 if (
sizeof(
T) > remainingSpace())
184 return make_error<StringError>(
185 "Invalid Raw with insufficient payload",
187 T Size = endian::read<T, Endianness>(Current);
188 Current +=
sizeof(
T);
189 return createRaw(Obj, Size);
193 if (
sizeof(
T) > remainingSpace())
194 return make_error<StringError>(
195 "Invalid Int with insufficient payload",
197 Obj.
Int =
static_cast<int64_t
>(endian::read<T, Endianness>(Current));
198 Current +=
sizeof(
T);
203 if (
sizeof(
T) > remainingSpace())
204 return make_error<StringError>(
205 "Invalid Int with insufficient payload",
207 Obj.
UInt =
static_cast<uint64_t
>(endian::read<T, Endianness>(Current));
208 Current +=
sizeof(
T);
213 if (
sizeof(
T) > remainingSpace())
214 return make_error<StringError>(
215 "Invalid Map/Array with invalid length",
217 Obj.
Length =
static_cast<size_t>(endian::read<T, Endianness>(Current));
218 Current +=
sizeof(
T);
223 if (
sizeof(
T) > remainingSpace())
224 return make_error<StringError>(
225 "Invalid Ext with invalid length",
227 T Size = endian::read<T, Endianness>(Current);
228 Current +=
sizeof(
T);
229 return createExt(Obj, Size);
233 if (Size > remainingSpace())
234 return make_error<StringError>(
235 "Invalid Raw with insufficient payload",
244 return make_error<StringError>(
245 "Invalid Ext with no type",
248 if (Size > remainingSpace())
249 return make_error<StringError>(
250 "Invalid Ext with insufficient payload",
ExtensionType Extension
Value for Type::Extension.
Expected< bool > read(Object &Obj)
Read one object from the input buffer, advancing past it.
This class represents lattice values for constants.
float BitsToFloat(uint32_t Bits)
This function takes a 32-bit integer and returns the bit equivalent float.
std::error_code make_error_code(BitcodeError E)
Tagged union holding either a T or a Error.
MessagePack object, represented as a tagged union of C++ types.
Reads MessagePack objects from memory, one at a time.
double Float
Value for Type::Float.
This is a MessagePack reader.
double BitsToDouble(uint64_t Bits)
This function takes a 64-bit integer and returns the bit equivalent double.
int8_t Type
User-defined extension type.
StringRef Raw
Value for Type::String and Type::Binary.
int64_t Int
Value for Type::Int.
This file contains constants used for implementing MessagePack support.
StringRef Bytes
Raw bytes of the extension object.
bool Bool
Value for Type::Boolean.
StringRef - Represent a constant reference to a string, i.e.
uint64_t UInt
Value for Type::Uint.
size_t Length
Value for Type::Array and Type::Map.
Reader(MemoryBufferRef InputBuffer)
Construct a reader, keeping a reference to the InputBuffer.