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

@@ -10,6 +10,7 @@
#include <stack>
#include "yaml-cpp/anchor.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h"
namespace YAML {
@@ -32,11 +33,11 @@ class EmitFromEvents : 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();
private:

View File

@@ -0,0 +1,20 @@
#ifndef EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
namespace YAML {
struct EmitterStyle {
enum value {
Default,
Block,
Flow,
};
};
}
#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -7,9 +7,11 @@
#pragma once
#endif
#include "yaml-cpp/anchor.h"
#include <string>
#include "yaml-cpp/anchor.h"
#include "yaml-cpp/emitterstyle.h"
namespace YAML {
struct Mark;
@@ -26,11 +28,11 @@ class EventHandler {
anchor_t anchor, const std::string& value) = 0;
virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
anchor_t anchor) = 0;
anchor_t anchor, EmitterStyle::value style) = 0;
virtual void OnSequenceEnd() = 0;
virtual void OnMapStart(const Mark& mark, const std::string& tag,
anchor_t anchor) = 0;
anchor_t anchor, EmitterStyle::value style) = 0;
virtual void OnMapEnd() = 0;
};
}

View File

@@ -9,6 +9,7 @@
#include "yaml-cpp/parser.h"
#include "yaml-cpp/emitter.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/stlemitter.h"
#include "yaml-cpp/exceptions.h"