mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Added newlines, fixed map/map
This commit is contained in:
@@ -249,11 +249,15 @@ namespace YAML
|
|||||||
{
|
{
|
||||||
if(!good())
|
if(!good())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PrepareNode(m_pState->NextGroupType(GroupType::None));
|
||||||
|
m_stream << "\n";
|
||||||
|
m_pState->SetNonContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Emitter::CanEmitNewline() const
|
bool Emitter::CanEmitNewline() const
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the stream in a state so we can simply write the next node
|
// Put the stream in a state so we can simply write the next node
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace YAML
|
namespace YAML
|
||||||
{
|
{
|
||||||
EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_hasAnchor(false), m_hasTag(false)
|
EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_hasAnchor(false), m_hasTag(false), m_hasNonContent(false)
|
||||||
{
|
{
|
||||||
// set default global manipulators
|
// set default global manipulators
|
||||||
m_charset.set(EmitNonAscii);
|
m_charset.set(EmitNonAscii);
|
||||||
@@ -53,6 +53,11 @@ namespace YAML
|
|||||||
m_hasTag = true;
|
m_hasTag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmitterState::SetNonContent()
|
||||||
|
{
|
||||||
|
m_hasNonContent = true;
|
||||||
|
}
|
||||||
|
|
||||||
void EmitterState::BeginNode()
|
void EmitterState::BeginNode()
|
||||||
{
|
{
|
||||||
if(!m_groups.empty())
|
if(!m_groups.empty())
|
||||||
@@ -60,6 +65,7 @@ namespace YAML
|
|||||||
|
|
||||||
m_hasAnchor = false;
|
m_hasAnchor = false;
|
||||||
m_hasTag = false;
|
m_hasTag = false;
|
||||||
|
m_hasNonContent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmitterNodeType::value EmitterState::NextGroupType(GroupType::value type) const
|
EmitterNodeType::value EmitterState::NextGroupType(GroupType::value type) const
|
||||||
|
@@ -36,6 +36,7 @@ namespace YAML
|
|||||||
// node handling
|
// node handling
|
||||||
void SetAnchor();
|
void SetAnchor();
|
||||||
void SetTag();
|
void SetTag();
|
||||||
|
void SetNonContent();
|
||||||
void BeginScalar();
|
void BeginScalar();
|
||||||
void BeginGroup(GroupType::value type);
|
void BeginGroup(GroupType::value type);
|
||||||
void EndGroup(GroupType::value type);
|
void EndGroup(GroupType::value type);
|
||||||
@@ -51,7 +52,7 @@ namespace YAML
|
|||||||
int CurIndent() const { return m_curIndent; }
|
int CurIndent() const { return m_curIndent; }
|
||||||
bool HasAnchor() const { return m_hasAnchor; }
|
bool HasAnchor() const { return m_hasAnchor; }
|
||||||
bool HasTag() const { return m_hasTag; }
|
bool HasTag() const { return m_hasTag; }
|
||||||
bool HasBegunNode() const { return m_hasAnchor || m_hasTag; }
|
bool HasBegunNode() const { return m_hasAnchor || m_hasTag || m_hasNonContent; }
|
||||||
|
|
||||||
void ClearModifiedSettings();
|
void ClearModifiedSettings();
|
||||||
|
|
||||||
@@ -157,6 +158,7 @@ namespace YAML
|
|||||||
unsigned m_curIndent;
|
unsigned m_curIndent;
|
||||||
bool m_hasAnchor;
|
bool m_hasAnchor;
|
||||||
bool m_hasTag;
|
bool m_hasTag;
|
||||||
|
bool m_hasNonContent;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@@ -9,7 +9,10 @@ int main()
|
|||||||
out << "foo";
|
out << "foo";
|
||||||
out << YAML::LocalTag("hi") << "bar";
|
out << YAML::LocalTag("hi") << "bar";
|
||||||
out << YAML::Anchor("asdf") << YAML::BeginMap;
|
out << YAML::Anchor("asdf") << YAML::BeginMap;
|
||||||
out << "a" << "b" << "c" << "d";
|
out << "a" << "b" << "c" << YAML::Newline;
|
||||||
|
out << YAML::Anchor("a") << YAML::BeginMap;
|
||||||
|
out << "a" << "b";
|
||||||
|
out << YAML::EndMap;
|
||||||
out << YAML::EndMap;
|
out << YAML::EndMap;
|
||||||
out << YAML::LocalTag("hi") << YAML::BeginSeq;
|
out << YAML::LocalTag("hi") << YAML::BeginSeq;
|
||||||
out << "a" << "b";
|
out << "a" << "b";
|
||||||
|
Reference in New Issue
Block a user