17#ifndef LLVM_BINARYFORMAT_MSGPACKDOCUMENT_H
18#define LLVM_BINARYFORMAT_MSGPACKDOCUMENT_H
43 typedef std::map<DocNode, DocNode>
MapTy;
82 return KindAndDoc->Kind;
86 return KindAndDoc->Doc;
190 assert(
false &&
"bad map key type");
202 return !(Lhs == Rhs);
249 MapTy::iterator
end() {
return Map->end(); }
252 MapTy::iterator
erase(MapTy::const_iterator
I) {
return Map->erase(
I); }
255 MapTy::const_iterator Second) {
296 std::vector<std::unique_ptr<DocNode::MapTy>> Maps;
297 std::vector<std::unique_ptr<DocNode::ArrayTy>> Arrays;
298 std::vector<std::unique_ptr<char[]>> Strings;
307 bool HexMode =
false;
313 KindAndDocs[
T] = {
this,
Type(
T)};
395 auto Raw = V.getBuffer();
406 Maps.push_back(std::make_unique<DocNode::MapTy>());
407 N.Map = Maps.back().get();
414 Arrays.push_back(std::make_unique<DocNode::ArrayTy>());
415 N.Array = Arrays.back().get();
461 Strings.push_back(std::unique_ptr<
char[]>(
new char[S.
size()]));
462 memcpy(&Strings.back()[0], S.
data(), S.
size());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This is a MessagePack reader.
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
An efficient, type-erasing, non-owning reference to a callable.
A DocNode that is an array.
void push_back(DocNode N)
LLVM_ABI DocNode & operator[](size_t Index)
Element access. This extends the array if necessary, with empty nodes.
ArrayTy::iterator begin()
A node in a MsgPack Document.
MapDocNode & getMap(bool Convert=false)
Get a MapDocNode for a map node.
LLVM_ABI StringRef fromString(StringRef S, StringRef Tag="")
Convert the StringRef and use it to set this DocNode (assuming scalar).
friend bool operator!=(const DocNode &Lhs, const DocNode &Rhs)
Inequality operator.
std::map< DocNode, DocNode > MapTy
ArrayDocNode & getArray(bool Convert=false)
Get an ArrayDocNode for an array node.
MemoryBufferRef getBinary() const
StringRef getString() const
LLVM_ABI std::string toString() const
Convert this node to a string, assuming it is scalar.
std::vector< DocNode > ArrayTy
LLVM_ABI friend bool operator==(const DocNode &Lhs, const DocNode &Rhs)
Equality operator.
DocNode & operator=(const char *Val)
Convenience assignment operators.
friend bool operator<(const DocNode &Lhs, const DocNode &Rhs)
Comparison operator, used for map keys.
Document * getDocument() const
Simple in-memory representation of a document of msgpack objects with ability to find and create arra...
bool getHexMode() const
Get Hexmode flag.
DocNode getNode(unsigned V)
Create a UInt node associated with this Document.
DocNode getNode(StringRef V, bool Copy=false)
Create a String node associated with this Document.
DocNode getNode(double V)
Create a Float node associated with this Document.
LLVM_ABI DocNode copyNode(DocNode Src)
Deep copy a DocNode from any Document into this Document.
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(uint64_t V)
Create a UInt node associated with this Document.
void clear()
Restore the Document to an empty state.
DocNode getNode()
Create a nil node associated with this Document.
ArrayDocNode getArrayNode()
Create an empty Array node associated with this Document.
DocNode getNode(int64_t V)
Create an Int node associated with this Document.
void setHexMode(bool Val=true)
Set whether YAML output uses hex for UInt. Default off.
LLVM_ABI void toYAML(raw_ostream &OS)
Convert MsgPack Document to YAML text.
DocNode getNode(bool V)
Create a Boolean node associated with this Document.
LLVM_ABI void writeToBlob(std::string &Blob)
Write a MsgPack document to a binary MsgPack blob.
LLVM_ABI 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.
StringRef addString(StringRef S)
Copy a string into the Document's strings list, and return the copy that is owned by the Document.
DocNode getNode(int V)
Create an Int node associated with this Document.
LLVM_ABI bool fromYAML(StringRef S)
Read YAML text into the MsgPack document. Returns false on failure.
DocNode getNode(const char *V, bool Copy=false)
Create a String node associated with this Document.
DocNode getNode(MemoryBufferRef V, bool Copy=false)
Create a Binary node associated with this Document.
MapTy::iterator find(DocNode Key)
MapTy::iterator erase(MapTy::const_iterator First, MapTy::const_iterator Second)
size_t erase(DocNode Key)
LLVM_ABI DocNode & operator[](StringRef S)
Member access.
MapTy::iterator erase(MapTy::const_iterator I)
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI bool operator==(const DocNode &Lhs, const DocNode &Rhs)
Namespace-scope declaration for the out-of-line friend operator==.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
The kind of a DocNode and its owning Document.