//===-- MsgPackDocumentYAML.cpp - MsgPack Document YAML interface -------*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // /// This file implements YAMLIO on a msgpack::Document. // //===----------------------------------------------------------------------===// #include "llvm/BinaryFormat/MsgPackDocument.h" #include "llvm/Support/YAMLTraits.h" usingnamespacellvm; usingnamespacemsgpack; namespace { // Struct used to represent scalar node. (MapDocNode and ArrayDocNode already // exist in MsgPackDocument.h.) struct ScalarDocNode : DocNode { … }; } // namespace /// Convert this DocNode to a string, assuming it is scalar. std::string DocNode::toString() const { … } /// Convert the StringRef and use it to set this DocNode (assuming scalar). If /// it is a string, copy the string into the Document's strings list so we do /// not rely on S having a lifetime beyond this call. Tag is "" or a YAML tag. StringRef DocNode::fromString(StringRef S, StringRef Tag) { … } /// Get the YAML tag for this ScalarDocNode. This normally returns ""; it only /// returns something else if the result of toString would be ambiguous, e.g. /// a string that parses as a number or boolean. StringRef ScalarDocNode::getYAMLTag() const { … } namespace llvm { namespace yaml { /// YAMLIO for DocNode template <> struct PolymorphicTraits<DocNode> { … }; /// YAMLIO for ScalarDocNode template <> struct TaggedScalarTraits<ScalarDocNode> { … }; /// YAMLIO for MapDocNode template <> struct CustomMappingTraits<MapDocNode> { … }; /// YAMLIO for ArrayNode template <> struct SequenceTraits<ArrayDocNode> { … }; } // namespace yaml } // namespace llvm /// Convert MsgPack Document to YAML text. void msgpack::Document::toYAML(raw_ostream &OS) { … } /// Read YAML text into the MsgPack document. Returns false on failure. bool msgpack::Document::fromYAML(StringRef S) { … }