diff options
author | Nick Kledzik <kledzik@apple.com> | 2013-11-14 00:59:59 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2013-11-14 00:59:59 +0000 |
commit | 4e7c22a90b28828e4a28751b65ae24091f7df4ec (patch) | |
tree | 831df9922e1cdd3f1537c3f9df0fc557eabc5aac /lib/Support | |
parent | 4bd0224887a8de1434186cad2f618c18dea06c0b (diff) | |
download | external_llvm-4e7c22a90b28828e4a28751b65ae24091f7df4ec.zip external_llvm-4e7c22a90b28828e4a28751b65ae24091f7df4ec.tar.gz external_llvm-4e7c22a90b28828e4a28751b65ae24091f7df4ec.tar.bz2 |
Add simple support for tags in YAML I/O
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194644 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/YAMLTraits.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Support/YAMLTraits.cpp b/lib/Support/YAMLTraits.cpp index 19eaed1..415424e 100644 --- a/lib/Support/YAMLTraits.cpp +++ b/lib/Support/YAMLTraits.cpp @@ -81,6 +81,16 @@ bool Input::setCurrentDocument() { void Input::nextDocument() { ++DocIterator; } + +bool Input::mapTag(StringRef Tag, bool Default) { + StringRef foundTag = CurrentNode->_node->getVerbatimTag(); + if (foundTag.empty()) { + // If no tag found and 'Tag' is the default, say it was found. + return Default; + } + // Return true iff found tag matches supplied tag. + return Tag.equals(foundTag); +} void Input::beginMapping() { if (EC) @@ -381,6 +391,14 @@ void Output::beginMapping() { NeedsNewLine = true; } +bool Output::mapTag(StringRef Tag, bool Use) { + if (Use) { + this->output(" "); + this->output(Tag); + } + return Use; +} + void Output::endMapping() { StateStack.pop_back(); } |