21using namespace msgpack;
108 : Node(Node),
Index(StartIndex), End(StartIndex +
Length),
109 MapEntry(MapEntry) {}
136 Stack.push_back(
StackLevel(Root, 0, (
size_t)-1));
142 if (!MPReader.
read(Obj)) {
143 if (Multi && Stack.size() == 1) {
184 else if (Stack.back().Node.getKind() ==
Type::Array) {
186 auto &
Array = Stack.back().Node.getArray();
187 DestNode = &
Array[Stack.back().Index++];
189 auto &
Map = Stack.back().Node.getMap();
190 if (!Stack.back().MapEntry) {
192 Stack.back().MapKey = Node;
193 Stack.back().MapEntry = &
Map[Node];
197 DestNode = Stack.back().MapEntry;
198 Stack.back().MapEntry =
nullptr;
199 ++Stack.back().Index;
206 DocNode MapKey = !Stack.empty() && !Stack.back().MapKey.isEmpty()
207 ? Stack.back().MapKey
213 (Node.isArray() && !DestNode->
isArray())));
228 while (!Stack.empty()) {
229 if (Stack.back().MapEntry)
231 if (Stack.back().Index != Stack.back().End)
235 }
while (!Stack.empty());
254 switch (Node.getKind()) {
258 {Node, DocNode::MapTy::iterator(), Node.getArray().begin(),
false});
263 {Node, Node.getMap().begin(), DocNode::ArrayTy::iterator(),
true});
269 MPWriter.
write(Node.getBool());
272 MPWriter.
write(Node.getInt());
275 MPWriter.
write(Node.getUInt());
278 MPWriter.
write(Node.getString());
286 while (!Stack.empty()) {
287 if (Stack.back().Node.getKind() ==
Type::Map) {
288 if (Stack.back().MapIt != Stack.back().Node.getMap().end())
291 if (Stack.back().ArrayIt != Stack.back().Node.getArray().end())
299 if (Stack.back().Node.getKind() ==
Type::Map) {
300 if (Stack.back().OnKey) {
302 Node = Stack.back().MapIt->first;
303 Stack.back().OnKey =
false;
305 Node = Stack.back().MapIt->second;
306 ++Stack.back().MapIt;
307 Stack.back().OnKey =
true;
310 Node = *Stack.back().ArrayIt;
311 ++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.