class Document

Declaration

class Document { /* full declaration omitted */ };

Description

Simple in-memory representation of a document of msgpack objects with ability to find and create array and map elements. Does not currently cope with any extension types.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:272

Member Variables

private std::vector<std::unique_ptr<DocNode::MapTy>> Maps
private std::vector<std::unique_ptr<DocNode::ArrayTy>> Arrays
private std::vector<std::unique_ptr<char[]>> Strings
private llvm::msgpack::DocNode Root
private llvm::msgpack::KindAndDocument[11] KindAndDocs
private bool HexMode = false

Method Overview

  • public Document()
  • public llvm::StringRef addString(llvm::StringRef S)
  • public void clear()
  • public bool fromYAML(llvm::StringRef S)
  • public llvm::msgpack::ArrayDocNode getArrayNode()
  • public llvm::msgpack::DocNode getEmptyNode()
  • public bool getHexMode() const
  • public llvm::msgpack::MapDocNode getMapNode()
  • public llvm::msgpack::DocNode getNode(llvm::StringRef V, bool Copy = false)
  • public llvm::msgpack::DocNode getNode(const char * V, bool Copy = false)
  • public llvm::msgpack::DocNode getNode(double V)
  • public llvm::msgpack::DocNode getNode(bool V)
  • public llvm::msgpack::DocNode getNode(unsigned int V)
  • public llvm::msgpack::DocNode getNode(uint64_t V)
  • public llvm::msgpack::DocNode getNode(int V)
  • public llvm::msgpack::DocNode getNode(int64_t V)
  • public llvm::msgpack::DocNode getNode()
  • public llvm::msgpack::DocNode & getRoot()
  • public bool readFromBlob(llvm::StringRef Blob, bool Multi, function_ref<int (llvm::msgpack::DocNode *, llvm::msgpack::DocNode, llvm::msgpack::DocNode)> Merger = [](llvm::msgpack::DocNode *DestNode, llvm::msgpack::DocNode SrcNode, llvm::msgpack::DocNode MapKey) { return -1; })
  • public void setHexMode(bool Val = true)
  • public void toYAML(llvm::raw_ostream & OS)
  • public void writeToBlob(std::string & Blob)

Methods

Document()

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:289

llvm::StringRef addString(llvm::StringRef S)

Description

Copy a string into the Document's strings list, and return the copy that is owned by the Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:422

Parameters

llvm::StringRef S

void clear()

Description

Restore the Document to an empty state.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:299

bool fromYAML(llvm::StringRef S)

Description

Read YAML text into the MsgPack document. Returns false on failure.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:438

Parameters

llvm::StringRef S

llvm::msgpack::ArrayDocNode getArrayNode()

Description

Create an empty Array node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:380

llvm::msgpack::DocNode getEmptyNode()

Description

Create an empty node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:302

bool getHexMode() const

Description

Get Hexmode flag.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:432

llvm::msgpack::MapDocNode getMapNode()

Description

Create an empty Map node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:372

llvm::msgpack::DocNode getNode(llvm::StringRef V,
                               bool Copy = false)

Description

Create a String node associated with this Document. If !Copy, the passed string must remain valid for the lifetime of the Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:357

Parameters

llvm::StringRef V
bool Copy = false

llvm::msgpack::DocNode getNode(const char* V,
                               bool Copy = false)

Description

Create a String node associated with this Document. If !Copy, the passed string must remain valid for the lifetime of the Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:367

Parameters

const char* V
bool Copy = false

llvm::msgpack::DocNode getNode(double V)

Description

Create a Float node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:349

Parameters

double V

llvm::msgpack::DocNode getNode(bool V)

Description

Create a Boolean node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:342

Parameters

bool V

llvm::msgpack::DocNode getNode(unsigned int V)

Description

Create a UInt node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:335

Parameters

unsigned int V

llvm::msgpack::DocNode getNode(uint64_t V)

Description

Create a UInt node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:328

Parameters

uint64_t V

llvm::msgpack::DocNode getNode(int V)

Description

Create an Int node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:321

Parameters

int V

llvm::msgpack::DocNode getNode(int64_t V)

Description

Create an Int node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:314

Parameters

int64_t V

llvm::msgpack::DocNode getNode()

Description

Create a nil node associated with this Document.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:308

llvm::msgpack::DocNode& getRoot()

Description

Get ref to the document's root element.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:296

bool readFromBlob(
    llvm::StringRef Blob,
    bool Multi,
    function_ref<int(llvm::msgpack::DocNode*,
                     llvm::msgpack::DocNode,
                     llvm::msgpack::DocNode)>
        Merger =
            [](llvm::msgpack::DocNode* DestNode,
               llvm::msgpack::DocNode SrcNode,
               llvm::msgpack::DocNode MapKey) {
              return -1;
            })

Description

Read a document from a binary msgpack blob, merging into anything already in the Document. The blob data must remain valid for the lifetime of this Document (because a string object in the document contains a StringRef into the original blob). If Multi, then this sets root to an array and adds top-level objects to it. If !Multi, then it only reads a single top-level object, even if there are more, and sets root to that. Returns false if failed due to illegal format or merge error. The Merger arg is a callback function that is called when the merge has a conflict, that is, it is trying to set an item that is already set. If the conflict cannot be resolved, the callback function returns -1. If the conflict can be resolved, the callback returns a non-negative number and sets *DestNode to the resolved node. The returned non-negative number is significant only for an array node; it is then the array index to start populating at. That allows Merger to choose whether to merge array elements (returns 0) or append new elements (returns existing size). If SrcNode is an array or map, the resolution must be that *DestNode is an array or map respectively, although it could be the array or map (respectively) that was already there. MapKey is the key if *DestNode is a map entry, a nil node otherwise. The default for Merger is to disallow any conflict.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:410

Parameters

llvm::StringRef Blob
bool Multi
function_ref<int(llvm::msgpack::DocNode*, llvm::msgpack::DocNode, llvm::msgpack::DocNode)> Merger = [](llvm::msgpack::DocNode *DestNode, llvm::msgpack::DocNode SrcNode, llvm::msgpack::DocNode MapKey) { return -1; }

void setHexMode(bool Val = true)

Description

Set whether YAML output uses hex for UInt. Default off.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:429

Parameters

bool Val = true

void toYAML(llvm::raw_ostream& OS)

Description

Convert MsgPack Document to YAML text.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:435

Parameters

llvm::raw_ostream& OS

void writeToBlob(std::string& Blob)

Description

Write a MsgPack document to a binary MsgPack blob.

Declared at: llvm/include/llvm/BinaryFormat/MsgPackDocument.h:418

Parameters

std::string& Blob