Add EmitterStyle, which will allow sequence or map style (i.e., flow or block) to be preserved between parsing and emitting

This commit is contained in:
Jesse Beder
2015-01-24 12:19:20 -06:00
parent a397ad2925
commit ad712c4f2d
22 changed files with 1451 additions and 1369 deletions

View File

@@ -30,7 +30,8 @@ void GraphBuilderAdapter::OnScalar(const Mark &mark, const std::string &tag,
void GraphBuilderAdapter::OnSequenceStart(const Mark &mark,
const std::string &tag,
anchor_t anchor) {
anchor_t anchor,
EmitterStyle::value style) {
void *pNode = m_builder.NewSequence(mark, tag, GetCurrentParent());
m_containers.push(ContainerFrame(pNode));
RegisterAnchor(anchor, pNode);
@@ -44,7 +45,8 @@ void GraphBuilderAdapter::OnSequenceEnd() {
}
void GraphBuilderAdapter::OnMapStart(const Mark &mark, const std::string &tag,
anchor_t anchor) {
anchor_t anchor,
EmitterStyle::value style) {
void *pNode = m_builder.NewMap(mark, tag, GetCurrentParent());
m_containers.push(ContainerFrame(pNode, m_pKeyNode));
m_pKeyNode = NULL;

View File

@@ -14,6 +14,7 @@
#include "yaml-cpp/anchor.h"
#include "yaml-cpp/contrib/anchordict.h"
#include "yaml-cpp/contrib/graphbuilder.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h"
namespace YAML {
@@ -36,11 +37,11 @@ class GraphBuilderAdapter : public EventHandler {
anchor_t anchor, const std::string& value);
virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
anchor_t anchor);
anchor_t anchor, EmitterStyle::value style);
virtual void OnSequenceEnd();
virtual void OnMapStart(const Mark& mark, const std::string& tag,
anchor_t anchor);
anchor_t anchor, EmitterStyle::value style);
virtual void OnMapEnd();
void* RootNode() const { return m_pRootNode; }