mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Started prepare node
This commit is contained in:
@@ -85,6 +85,13 @@ namespace YAML
|
|||||||
void EmitKindTag();
|
void EmitKindTag();
|
||||||
void EmitTag(bool verbatim, const _Tag& tag);
|
void EmitTag(bool verbatim, const _Tag& tag);
|
||||||
|
|
||||||
|
void PrepareNode();
|
||||||
|
void PrepareTopNode();
|
||||||
|
void FlowSeqPrepareNode();
|
||||||
|
void BlockSeqPrepareNode();
|
||||||
|
void FlowMapPrepareNode();
|
||||||
|
void BlockMapPrepareNode();
|
||||||
|
|
||||||
const char *ComputeFullBoolName(bool b) const;
|
const char *ComputeFullBoolName(bool b) const;
|
||||||
bool CanEmitNewline() const;
|
bool CanEmitNewline() const;
|
||||||
|
|
||||||
|
@@ -210,6 +210,8 @@ namespace YAML
|
|||||||
if(!good())
|
if(!good())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PrepareNode();
|
||||||
|
|
||||||
m_pState->BeginGroup(GroupType::Seq);
|
m_pState->BeginGroup(GroupType::Seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +230,8 @@ namespace YAML
|
|||||||
if(!good())
|
if(!good())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PrepareNode();
|
||||||
|
|
||||||
m_pState->BeginGroup(GroupType::Map);
|
m_pState->BeginGroup(GroupType::Map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +256,61 @@ namespace YAML
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put the stream in a state so we can simply write the next node
|
||||||
|
// E.g., if we're in a sequence, write the "- "
|
||||||
|
void Emitter::PrepareNode()
|
||||||
|
{
|
||||||
|
switch(m_pState->CurGroupType()) {
|
||||||
|
case GroupType::None:
|
||||||
|
PrepareTopNode();
|
||||||
|
break;
|
||||||
|
case GroupType::Seq:
|
||||||
|
switch(m_pState->CurGroupFlowType()) {
|
||||||
|
case FlowType::Flow:
|
||||||
|
FlowSeqPrepareNode();
|
||||||
|
break;
|
||||||
|
case FlowType::Block:
|
||||||
|
BlockSeqPrepareNode();
|
||||||
|
break;
|
||||||
|
case FlowType::None:
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GroupType::Map:
|
||||||
|
switch(m_pState->CurGroupFlowType()) {
|
||||||
|
case FlowType::Flow:
|
||||||
|
FlowMapPrepareNode();
|
||||||
|
break;
|
||||||
|
case FlowType::Block:
|
||||||
|
BlockMapPrepareNode();
|
||||||
|
break;
|
||||||
|
case FlowType::None:
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emitter::PrepareTopNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emitter::FlowSeqPrepareNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emitter::BlockSeqPrepareNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emitter::FlowMapPrepareNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emitter::BlockMapPrepareNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// *******************************************************************************************
|
// *******************************************************************************************
|
||||||
// overloads of Write
|
// overloads of Write
|
||||||
|
|
||||||
@@ -260,6 +319,8 @@ namespace YAML
|
|||||||
if(!good())
|
if(!good())
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
PrepareNode();
|
||||||
|
|
||||||
m_pState->BeginScalar();
|
m_pState->BeginScalar();
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@@ -4,11 +4,7 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
out << YAML::BeginDoc;
|
|
||||||
out << YAML::BeginSeq;
|
|
||||||
out << "foo";
|
out << "foo";
|
||||||
out << YAML::EndSeq;
|
|
||||||
out << YAML::EndDoc;
|
|
||||||
|
|
||||||
std::cout << out.c_str() << "\n";
|
std::cout << out.c_str() << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user