21using namespace msgpack;
113 MapEntry(MapEntry) {}
140 Stack.push_back(
StackLevel(Root, 0, (
size_t)-1));
146 if (!MPReader.
read(Obj)) {
147 if (Multi && Stack.size() == 1) {
191 else if (Stack.back().Node.getKind() ==
Type::Array) {
193 auto &
Array = Stack.back().Node.getArray();
194 DestNode = &
Array[Stack.back().Index++];
196 auto &
Map = Stack.back().Node.getMap();
197 if (!Stack.back().MapEntry) {
199 Stack.back().MapKey = Node;
200 Stack.back().MapEntry = &
Map[Node];
204 DestNode = Stack.back().MapEntry;
205 Stack.back().MapEntry =
nullptr;
206 ++Stack.back().Index;
213 DocNode MapKey = !Stack.empty() && !Stack.back().MapKey.isEmpty()
214 ? Stack.back().MapKey
220 (Node.isArray() && !DestNode->
isArray())));
235 while (!Stack.empty()) {
236 if (Stack.back().MapEntry)
238 if (Stack.back().Index != Stack.back().End)
242 }
while (!Stack.empty());
261 switch (Node.getKind()) {
265 {Node, DocNode::MapTy::iterator(), Node.getArray().begin(),
false});
270 {Node, Node.getMap().begin(), DocNode::ArrayTy::iterator(),
true});
276 MPWriter.
write(Node.getBool());
279 MPWriter.
write(Node.getInt());
282 MPWriter.
write(Node.getUInt());
285 MPWriter.
write(Node.getString());
288 MPWriter.
write(Node.getBinary());
296 while (!Stack.empty()) {
297 if (Stack.back().Node.getKind() ==
Type::Map) {
298 if (Stack.back().MapIt != Stack.back().Node.getMap().end())
301 if (Stack.back().ArrayIt != Stack.back().Node.getArray().end())
309 if (Stack.back().Node.getKind() ==
Type::Map) {
310 if (Stack.back().OnKey) {
312 Node = Stack.back().MapIt->first;
313 Stack.back().OnKey =
false;
315 Node = Stack.back().MapIt->second;
316 ++Stack.back().MapIt;
317 Stack.back().OnKey =
true;
320 Node = *Stack.back().ArrayIt;
321 ++Stack.back().ArrayIt;
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())
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.
sampleprof_error MergeResult(sampleprof_error &Accumulator, sampleprof_error Result)
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.