mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Fixed when we emit the doc start (only if there already is a document in the stream, and we're about to emit a new node)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct EmitterNodeType { enum value { None, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap }; };
|
||||
struct EmitterNodeType { enum value { None, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap }; };
|
||||
}
|
||||
|
||||
#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
@@ -280,6 +280,7 @@ namespace YAML
|
||||
case EmitterNodeType::BlockMap:
|
||||
BlockMapPrepareNode(child);
|
||||
break;
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
assert(false);
|
||||
break;
|
||||
@@ -288,12 +289,14 @@ namespace YAML
|
||||
|
||||
void Emitter::PrepareTopNode(EmitterNodeType::value child)
|
||||
{
|
||||
if(!m_pState->HasBegunNode() && m_stream.pos() > 0) {
|
||||
EmitBeginDoc();
|
||||
if(m_pState->CurGroupChildCount() > 0 && m_stream.pos() > 0) {
|
||||
if(child != EmitterNodeType::None)
|
||||
EmitBeginDoc();
|
||||
}
|
||||
|
||||
switch(child) {
|
||||
case EmitterNodeType::None:
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
case EmitterNodeType::FlowSeq:
|
||||
case EmitterNodeType::FlowMap:
|
||||
@@ -329,6 +332,7 @@ namespace YAML
|
||||
|
||||
switch(child) {
|
||||
case EmitterNodeType::None:
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
case EmitterNodeType::FlowSeq:
|
||||
case EmitterNodeType::FlowMap:
|
||||
@@ -378,6 +382,7 @@ namespace YAML
|
||||
// key
|
||||
switch(child) {
|
||||
case EmitterNodeType::None:
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
case EmitterNodeType::FlowSeq:
|
||||
case EmitterNodeType::FlowMap:
|
||||
@@ -394,6 +399,7 @@ namespace YAML
|
||||
// value
|
||||
switch(child) {
|
||||
case EmitterNodeType::None:
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
case EmitterNodeType::FlowSeq:
|
||||
case EmitterNodeType::FlowMap:
|
||||
@@ -537,7 +543,7 @@ namespace YAML
|
||||
return *this;
|
||||
}
|
||||
|
||||
PrepareNode(EmitterNodeType::None);
|
||||
PrepareNode(EmitterNodeType::Property);
|
||||
|
||||
if(!Utils::WriteAnchor(m_stream, anchor.content)) {
|
||||
m_pState->SetError(ErrorMsg::INVALID_ANCHOR);
|
||||
@@ -559,7 +565,7 @@ namespace YAML
|
||||
return *this;
|
||||
}
|
||||
|
||||
PrepareNode(EmitterNodeType::None);
|
||||
PrepareNode(EmitterNodeType::Property);
|
||||
|
||||
bool success = false;
|
||||
if(tag.type == _Tag::Type::Verbatim)
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_hasAnchor(false), m_hasTag(false), m_hasNonContent(false)
|
||||
EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_hasAnchor(false), m_hasTag(false), m_hasNonContent(false), m_docCount(0)
|
||||
{
|
||||
// set default global manipulators
|
||||
m_charset.set(EmitNonAscii);
|
||||
@@ -60,7 +60,9 @@ namespace YAML
|
||||
|
||||
void EmitterState::StartedNode()
|
||||
{
|
||||
if(!m_groups.empty())
|
||||
if(m_groups.empty())
|
||||
m_docCount++;
|
||||
else
|
||||
m_groups.top().childCount++;
|
||||
|
||||
m_hasAnchor = false;
|
||||
@@ -161,7 +163,7 @@ namespace YAML
|
||||
|
||||
std::size_t EmitterState::CurGroupChildCount() const
|
||||
{
|
||||
return m_groups.empty() ? 0 : m_groups.top().childCount;
|
||||
return m_groups.empty() ? m_docCount : m_groups.top().childCount;
|
||||
}
|
||||
|
||||
void EmitterState::ClearModifiedSettings()
|
||||
|
@@ -160,6 +160,7 @@ namespace YAML
|
||||
bool m_hasAnchor;
|
||||
bool m_hasTag;
|
||||
bool m_hasNonContent;
|
||||
std::size_t m_docCount;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
Reference in New Issue
Block a user