17using namespace msgpack;
45 OS << (
Bool ?
"true" :
"false");
70 if (
Tag ==
"tag:yaml.org,2002:str")
72 if (
Tag ==
"!int" ||
Tag ==
"") {
78 Err = yaml::ScalarTraits<int64_t>::input(S,
nullptr,
getInt());
80 if (Err ==
"" ||
Tag !=
"")
87 if (
Tag ==
"!bool" ||
Tag ==
"") {
90 if (Err ==
"" ||
Tag !=
"")
93 if (
Tag ==
"!float" ||
Tag ==
"") {
96 if (Err ==
"" ||
Tag !=
"")
99 assert((
Tag ==
"!str" ||
Tag ==
"") &&
"unsupported tag");
101 StringRef Err = yaml::ScalarTraits<std::string>::input(S,
nullptr, V);
110StringRef ScalarDocNode::getYAMLTag()
const {
115 ScalarDocNode
N = getDocument()->getNode();
117 if (
N.getKind() == getKind())
146template <>
struct PolymorphicTraits<
DocNode> {
149 switch (
N.getKind()) {
150 case msgpack::Type::Map:
151 return NodeKind::Map;
152 case msgpack::Type::Array:
153 return NodeKind::Sequence;
155 return NodeKind::Scalar;
167 return *
static_cast<ScalarDocNode *
>(&
N);
172template <>
struct TaggedScalarTraits<ScalarDocNode> {
176 TagOS << S.getYAMLTag();
182 return S.fromString(Str, Tag);
186 switch (S.getKind()) {
188 return ScalarTraits<int64_t>::mustQuote(ScalarStr);
190 return ScalarTraits<uint64_t>::mustQuote(ScalarStr);
192 return ScalarTraits<StringRef>::mustQuote(ScalarStr);
194 return ScalarTraits<bool>::mustQuote(ScalarStr);
196 return ScalarTraits<double>::mustQuote(ScalarStr);
199 return ScalarTraits<std::string>::mustQuote(ScalarStr);
210 ScalarDocNode KeyObj = M.getDocument()->getNode();
211 KeyObj.fromString(Key,
"");
212 IO.mapRequired(Key.str().c_str(), M.getMap()[KeyObj]);
216 for (
auto I : M.getMap()) {
217 IO.mapRequired(
I.first.toString().c_str(),
I.second);
237 yaml::Output Yout(
OS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static DeltaTreeNode * getRoot(void *Root)
This file declares a class that exposes a simple in-memory representation of a document of MsgPack ob...
StringRef - Represent a constant reference to a string, i.e.
A DocNode that is an array.
A node in a MsgPack Document.
LLVM_ABI StringRef fromString(StringRef S, StringRef Tag="")
Convert the StringRef and use it to set this DocNode (assuming scalar).
LLVM_ABI std::string toString() const
Convert this node to a string, assuming it is scalar.
Document * getDocument() const
bool getHexMode() const
Get Hexmode flag.
DocNode getNode()
Create a nil node associated with this Document.
LLVM_ABI void toYAML(raw_ostream &OS)
Convert MsgPack Document to YAML text.
LLVM_ABI bool fromYAML(StringRef S)
Read YAML text into the MsgPack document. Returns false on failure.
This class implements an extremely fast bulk output stream that can only output to a 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.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
const char * toString(DWARFSectionKind Kind)
static void inputOne(IO &IO, StringRef Key, MapDocNode &M)
static void output(IO &IO, MapDocNode &M)
static NodeKind getKind(const DocNode &N)
static ArrayDocNode & getAsSequence(DocNode &N)
static MapDocNode & getAsMap(DocNode &N)
static ScalarDocNode & getAsScalar(DocNode &N)
static size_t size(IO &IO, ArrayDocNode &A)
static DocNode & element(IO &IO, ArrayDocNode &A, size_t Index)
static StringRef input(StringRef Str, StringRef Tag, void *Ctxt, ScalarDocNode &S)
static void output(const ScalarDocNode &S, void *Ctxt, raw_ostream &OS, raw_ostream &TagOS)
static QuotingType mustQuote(const ScalarDocNode &S, StringRef ScalarStr)