21using namespace msgpack;
113 MapEntry(MapEntry) {}
140 Stack.push_back(
StackLevel(Root, 0, (
size_t)-1));
152 if (!ReadObj.
get()) {
153 if (Multi && Stack.size() == 1) {
197 else if (Stack.back().Node.getKind() ==
Type::Array) {
199 auto &
Array = Stack.back().Node.getArray();
200 DestNode = &
Array[Stack.back().Index++];
202 auto &
Map = Stack.back().Node.getMap();
203 if (!Stack.back().MapEntry) {
205 Stack.back().MapKey = Node;
206 Stack.back().MapEntry = &
Map[Node];
210 DestNode = Stack.back().MapEntry;
211 Stack.back().MapEntry =
nullptr;
212 ++Stack.back().Index;
219 DocNode MapKey = !Stack.empty() && !Stack.back().MapKey.isEmpty()
220 ? Stack.back().MapKey
222 MergeResult =
Merger(DestNode, Node, MapKey);
226 (Node.isArray() && !DestNode->
isArray())));
241 while (!Stack.empty()) {
242 if (Stack.back().MapEntry)
244 if (Stack.back().Index != Stack.back().End)
248 }
while (!Stack.empty());
267 switch (Node.getKind()) {
271 {Node, DocNode::MapTy::iterator(), Node.getArray().begin(),
false});
276 {Node, Node.getMap().begin(), DocNode::ArrayTy::iterator(),
true});
282 MPWriter.
write(Node.getBool());
285 MPWriter.
write(Node.getInt());
288 MPWriter.
write(Node.getUInt());
291 MPWriter.
write(Node.getString());
294 MPWriter.
write(Node.getBinary());
302 while (!Stack.empty()) {
303 if (Stack.back().Node.getKind() ==
Type::Map) {
304 if (Stack.back().MapIt != Stack.back().Node.getMap().end())
307 if (Stack.back().ArrayIt != Stack.back().Node.getArray().end())
315 if (Stack.back().Node.getKind() ==
Type::Map) {
316 if (Stack.back().OnKey) {
318 Node = Stack.back().MapIt->first;
319 Stack.back().OnKey =
false;
321 Node = Stack.back().MapIt->second;
322 ++Stack.back().MapIt;
323 Stack.back().OnKey =
true;
326 Node = *Stack.back().ArrayIt;
327 ++Stack.back().ArrayIt;
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
This file declares a class that exposes a simple in-memory representation of a document of MsgPack ob...
This file contains a MessagePack writer.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
An efficient, type-erasing, non-owning reference to a callable.
DocNode & operator[](size_t Index)
Element access. This extends the array if necessary, with empty nodes.
A node in a MsgPack Document.
DocNode & operator=(const char *Val)
Convenience assignment operators.
Document * getDocument() const
MapDocNode getMapNode()
Create an empty Map node associated with this Document.
DocNode getEmptyNode()
Create an empty node associated with this Document.
DocNode & getRoot()
Get ref to the document's root element.
DocNode getNode()
Create a nil node associated with this Document.
ArrayDocNode getArrayNode()
Create an empty Array node associated with this Document.
void writeToBlob(std::string &Blob)
Write a MsgPack document to a binary MsgPack blob.
bool readFromBlob(StringRef Blob, bool Multi, function_ref< int(DocNode *DestNode, DocNode SrcNode, DocNode MapKey)> Merger=[](DocNode *DestNode, DocNode SrcNode, DocNode MapKey) { return -1;})
Read a document from a binary msgpack blob, merging into anything already in the Document.
MapTy::iterator find(DocNode Key)
DocNode & operator[](StringRef S)
Member access.
Reads MessagePack objects from memory, one at a time.
Expected< bool > read(Object &Obj)
Read one object from the input buffer, advancing past it.
Writes MessagePack objects to an output stream, one at a time.
void writeNil()
Write a Nil to the output stream.
void writeMapSize(uint32_t Size)
Write the header for a Map of the given size.
void writeArraySize(uint32_t Size)
Write the header for an Array of the given size.
void write(bool b)
Write a Boolean to the output stream.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
void consumeError(Error Err)
Consume a Error without doing anything.
StackLevel(DocNode Node, size_t StartIndex, size_t Length, DocNode *MapEntry=nullptr)
DocNode::MapTy::iterator MapIt
DocNode::ArrayTy::iterator ArrayIt
MessagePack object, represented as a tagged union of C++ types.
int64_t Int
Value for Type::Int.
double Float
Value for Type::Float.
StringRef Raw
Value for Type::String and Type::Binary.
uint64_t UInt
Value for Type::Uint.
bool Bool
Value for Type::Boolean.
size_t Length
Value for Type::Array and Type::Map.