From 07e88a78cba761bbc1963221b5f1b61e7a108e6f Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Mon, 21 May 2012 23:37:49 -0500 Subject: [PATCH] Added alias --- src/emitter.cpp | 12 ++++++++++++ util/sandbox.cpp | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/emitter.cpp b/src/emitter.cpp index 9869c6e..ca465e2 100644 --- a/src/emitter.cpp +++ b/src/emitter.cpp @@ -512,7 +512,19 @@ namespace YAML { if(!good()) return *this; + + if(m_pState->HasAnchor() || m_pState->HasTag()) { + m_pState->SetError(ErrorMsg::INVALID_ALIAS); + return *this; + } + PrepareNode(EmitterNodeType::Scalar); + + if(!Utils::WriteAlias(m_stream, alias.content)) { + m_pState->SetError(ErrorMsg::INVALID_ALIAS); + return *this; + } + m_pState->BeginScalar(); return *this; diff --git a/util/sandbox.cpp b/util/sandbox.cpp index 32ee902..e40504f 100644 --- a/util/sandbox.cpp +++ b/util/sandbox.cpp @@ -9,13 +9,13 @@ int main() out << "foo"; out << YAML::LocalTag("hi") << "bar"; out << YAML::Anchor("asdf") << YAML::BeginMap; - out << "a" << "b" << "c" << YAML::Newline; + out << "a" << "b" << "c"; out << YAML::Anchor("a") << YAML::BeginMap; - out << "a" << "b"; + out << YAML::Anchor("d") << "a" << "b"; out << YAML::EndMap; out << YAML::EndMap; out << YAML::LocalTag("hi") << YAML::BeginSeq; - out << "a" << "b"; + out << "a" << "b" << YAML::Alias("monkey"); out << YAML::EndSeq; out << YAML::EndSeq;