Merge from core

This commit is contained in:
Jesse Beder
2015-01-24 12:26:16 -06:00
29 changed files with 1498 additions and 1376 deletions

View File

@@ -305,6 +305,18 @@ install(
FILES_MATCHING PATTERN "*.h" FILES_MATCHING PATTERN "*.h"
) )
export(
TARGETS yaml-cpp
FILE "${PROJECT_BINARY_DIR}/yaml-cpp-targets.cmake")
export(PACKAGE yaml-cpp)
set(EXPORT_TARGETS yaml-cpp CACHE INTERNAL "export targets")
set(CONFIG_INCLUDE_DIRS "${YAML_CPP_SOURCE_DIR}/include")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config.cmake.in
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config-version.cmake.in
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" @ONLY)
if(UNIX) if(UNIX)
set(PC_FILE ${CMAKE_BINARY_DIR}/yaml-cpp.pc) set(PC_FILE ${CMAKE_BINARY_DIR}/yaml-cpp.pc)
configure_file("yaml-cpp.pc.cmake" ${PC_FILE} @ONLY) configure_file("yaml-cpp.pc.cmake" ${PC_FILE} @ONLY)

View File

@@ -34,7 +34,7 @@ class YAML_CPP_API Binary {
m_data.swap(rhs); m_data.swap(rhs);
rhs.clear(); rhs.clear();
rhs.resize(m_unownedSize); rhs.resize(m_unownedSize);
std::copy(m_unownedData, m_unownedData + m_unownedSize, &rhs[0]); std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin());
m_unownedData = 0; m_unownedData = 0;
m_unownedSize = 0; m_unownedSize = 0;
} else { } else {

View File

@@ -10,6 +10,7 @@
#include <stack> #include <stack>
#include "yaml-cpp/anchor.h" #include "yaml-cpp/anchor.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
namespace YAML { namespace YAML {
@@ -32,11 +33,11 @@ class EmitFromEvents : public EventHandler {
anchor_t anchor, const std::string& value); anchor_t anchor, const std::string& value);
virtual void OnSequenceStart(const Mark& mark, const std::string& tag, virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
anchor_t anchor); anchor_t anchor, EmitterStyle::value style);
virtual void OnSequenceEnd(); virtual void OnSequenceEnd();
virtual void OnMapStart(const Mark& mark, const std::string& tag, virtual void OnMapStart(const Mark& mark, const std::string& tag,
anchor_t anchor); anchor_t anchor, EmitterStyle::value style);
virtual void OnMapEnd(); virtual void OnMapEnd();
private: 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 #pragma once
#endif #endif
#include "yaml-cpp/anchor.h"
#include <string> #include <string>
#include "yaml-cpp/anchor.h"
#include "yaml-cpp/emitterstyle.h"
namespace YAML { namespace YAML {
struct Mark; struct Mark;
@@ -26,11 +28,11 @@ class EventHandler {
anchor_t anchor, const std::string& value) = 0; anchor_t anchor, const std::string& value) = 0;
virtual void OnSequenceStart(const Mark& mark, const std::string& tag, 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 OnSequenceEnd() = 0;
virtual void OnMapStart(const Mark& mark, const std::string& tag, 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; virtual void OnMapEnd() = 0;
}; };
} }

View File

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

View File

@@ -60,7 +60,8 @@ static const unsigned char decoding[] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, }; 255,
};
std::vector<unsigned char> DecodeBase64(const std::string &input) { std::vector<unsigned char> DecodeBase64(const std::string &input) {
typedef std::vector<unsigned char> ret_type; typedef std::vector<unsigned char> ret_type;

View File

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

View File

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

View File

@@ -44,9 +44,20 @@ void EmitFromEvents::OnScalar(const Mark&, const std::string& tag,
} }
void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag, void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag,
anchor_t anchor) { anchor_t anchor,
EmitterStyle::value style) {
BeginNode(); BeginNode();
EmitProps(tag, anchor); EmitProps(tag, anchor);
switch (style) {
case EmitterStyle::Block:
m_emitter << Block;
break;
case EmitterStyle::Flow:
m_emitter << Flow;
break;
default:
break;
}
m_emitter << BeginSeq; m_emitter << BeginSeq;
m_stateStack.push(State::WaitingForSequenceEntry); m_stateStack.push(State::WaitingForSequenceEntry);
} }
@@ -58,9 +69,19 @@ void EmitFromEvents::OnSequenceEnd() {
} }
void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag, void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag,
anchor_t anchor) { anchor_t anchor, EmitterStyle::value style) {
BeginNode(); BeginNode();
EmitProps(tag, anchor); EmitProps(tag, anchor);
switch (style) {
case EmitterStyle::Block:
m_emitter << Block;
break;
case EmitterStyle::Flow:
m_emitter << Flow;
break;
default:
break;
}
m_emitter << BeginMap; m_emitter << BeginMap;
m_stateStack.push(State::WaitingForKey); m_stateStack.push(State::WaitingForKey);
} }

View File

@@ -49,7 +49,8 @@ void NodeBuilder::OnScalar(const Mark& /* mark */, const std::string& tag,
} }
void NodeBuilder::OnSequenceStart(const Mark& /* mark */, void NodeBuilder::OnSequenceStart(const Mark& /* mark */,
const std::string& tag, anchor_t anchor) { const std::string& tag, anchor_t anchor,
EmitterStyle::value style) {
detail::node& node = Push(anchor); detail::node& node = Push(anchor);
node.set_tag(tag); node.set_tag(tag);
node.set_type(NodeType::Sequence); node.set_type(NodeType::Sequence);
@@ -58,7 +59,7 @@ void NodeBuilder::OnSequenceStart(const Mark& /* mark */,
void NodeBuilder::OnSequenceEnd() { Pop(); } void NodeBuilder::OnSequenceEnd() { Pop(); }
void NodeBuilder::OnMapStart(const Mark& /* mark */, const std::string& tag, void NodeBuilder::OnMapStart(const Mark& /* mark */, const std::string& tag,
anchor_t anchor) { anchor_t anchor, EmitterStyle::value style) {
detail::node& node = Push(anchor); detail::node& node = Push(anchor);
node.set_type(NodeType::Map); node.set_type(NodeType::Map);
node.set_tag(tag); node.set_tag(tag);

View File

@@ -10,6 +10,7 @@
#include <vector> #include <vector>
#include "yaml-cpp/anchor.h" #include "yaml-cpp/anchor.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
@@ -39,11 +40,11 @@ class NodeBuilder : public EventHandler {
anchor_t anchor, const std::string& value); anchor_t anchor, const std::string& value);
virtual void OnSequenceStart(const Mark& mark, const std::string& tag, virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
anchor_t anchor); anchor_t anchor, EmitterStyle::value style);
virtual void OnSequenceEnd(); virtual void OnSequenceEnd();
virtual void OnMapStart(const Mark& mark, const std::string& tag, virtual void OnMapStart(const Mark& mark, const std::string& tag,
anchor_t anchor); anchor_t anchor, EmitterStyle::value style);
virtual void OnMapEnd(); virtual void OnMapEnd();
private: private:

View File

@@ -76,14 +76,15 @@ void NodeEvents::Emit(const detail::node& node, EventHandler& handler,
handler.OnScalar(Mark(), node.tag(), anchor, node.scalar()); handler.OnScalar(Mark(), node.tag(), anchor, node.scalar());
break; break;
case NodeType::Sequence: case NodeType::Sequence:
handler.OnSequenceStart(Mark(), node.tag(), anchor); handler.OnSequenceStart(Mark(), node.tag(), anchor,
EmitterStyle::Default);
for (detail::const_node_iterator it = node.begin(); it != node.end(); for (detail::const_node_iterator it = node.begin(); it != node.end();
++it) ++it)
Emit(**it, handler, am); Emit(**it, handler, am);
handler.OnSequenceEnd(); handler.OnSequenceEnd();
break; break;
case NodeType::Map: case NodeType::Map:
handler.OnMapStart(Mark(), node.tag(), anchor); handler.OnMapStart(Mark(), node.tag(), anchor, EmitterStyle::Default);
for (detail::const_node_iterator it = node.begin(); it != node.end(); for (detail::const_node_iterator it = node.begin(); it != node.end();
++it) { ++it) {
Emit(*it->first, handler, am); Emit(*it->first, handler, am);

View File

@@ -16,7 +16,7 @@ RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op) {
} }
// combination constructors // combination constructors
RegEx operator!(const RegEx & ex) { RegEx operator!(const RegEx& ex) {
RegEx ret(REGEX_NOT); RegEx ret(REGEX_NOT);
ret.m_params.push_back(ex); ret.m_params.push_back(ex);
return ret; return ret;

View File

@@ -34,7 +34,7 @@ class RegEx {
RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ);
~RegEx() {} ~RegEx() {}
friend RegEx operator!(const RegEx & ex); friend RegEx operator!(const RegEx& ex);
friend RegEx operator||(const RegEx& ex1, const RegEx& ex2); friend RegEx operator||(const RegEx& ex1, const RegEx& ex2);
friend RegEx operator&&(const RegEx& ex1, const RegEx& ex2); friend RegEx operator&&(const RegEx& ex1, const RegEx& ex2);
friend RegEx operator+(const RegEx& ex1, const RegEx& ex2); friend RegEx operator+(const RegEx& ex1, const RegEx& ex2);

View File

@@ -317,7 +317,8 @@ void Scanner::PopIndentToHere() {
const IndentMarker& indent = *m_indents.top(); const IndentMarker& indent = *m_indents.top();
if (indent.column < INPUT.column()) if (indent.column < INPUT.column())
break; break;
if (indent.column == INPUT.column() && !(indent.type == IndentMarker::SEQ && if (indent.column == INPUT.column() &&
!(indent.type == IndentMarker::SEQ &&
!Exp::BlockEntry().Matches(INPUT))) !Exp::BlockEntry().Matches(INPUT)))
break; break;

View File

@@ -7,6 +7,7 @@
#include "singledocparser.h" #include "singledocparser.h"
#include "tag.h" #include "tag.h"
#include "token.h" #include "token.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/exceptions.h" // IWYU pragma: keep #include "yaml-cpp/exceptions.h" // IWYU pragma: keep
#include "yaml-cpp/mark.h" #include "yaml-cpp/mark.h"
@@ -55,7 +56,7 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
// special case: a value node by itself must be a map, with no header // special case: a value node by itself must be a map, with no header
if (m_scanner.peek().type == Token::VALUE) { if (m_scanner.peek().type == Token::VALUE) {
eventHandler.OnMapStart(mark, "?", NullAnchor); eventHandler.OnMapStart(mark, "?", NullAnchor, EmitterStyle::Default);
HandleMap(eventHandler); HandleMap(eventHandler);
eventHandler.OnMapEnd(); eventHandler.OnMapEnd();
return; return;
@@ -92,14 +93,22 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
m_scanner.pop(); m_scanner.pop();
return; return;
case Token::FLOW_SEQ_START: case Token::FLOW_SEQ_START:
eventHandler.OnSequenceStart(mark, tag, anchor, EmitterStyle::Flow);
HandleSequence(eventHandler);
eventHandler.OnSequenceEnd();
return;
case Token::BLOCK_SEQ_START: case Token::BLOCK_SEQ_START:
eventHandler.OnSequenceStart(mark, tag, anchor); eventHandler.OnSequenceStart(mark, tag, anchor, EmitterStyle::Block);
HandleSequence(eventHandler); HandleSequence(eventHandler);
eventHandler.OnSequenceEnd(); eventHandler.OnSequenceEnd();
return; return;
case Token::FLOW_MAP_START: case Token::FLOW_MAP_START:
eventHandler.OnMapStart(mark, tag, anchor, EmitterStyle::Flow);
HandleMap(eventHandler);
eventHandler.OnMapEnd();
return;
case Token::BLOCK_MAP_START: case Token::BLOCK_MAP_START:
eventHandler.OnMapStart(mark, tag, anchor); eventHandler.OnMapStart(mark, tag, anchor, EmitterStyle::Block);
HandleMap(eventHandler); HandleMap(eventHandler);
eventHandler.OnMapEnd(); eventHandler.OnMapEnd();
return; return;
@@ -107,7 +116,7 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
// compact maps can only go in a flow sequence // compact maps can only go in a flow sequence
if (m_pCollectionStack->GetCurCollectionType() == if (m_pCollectionStack->GetCurCollectionType() ==
CollectionType::FlowSeq) { CollectionType::FlowSeq) {
eventHandler.OnMapStart(mark, tag, anchor); eventHandler.OnMapStart(mark, tag, anchor, EmitterStyle::Flow);
HandleMap(eventHandler); HandleMap(eventHandler);
eventHandler.OnMapEnd(); eventHandler.OnMapEnd();
return; return;

View File

@@ -7,7 +7,7 @@
#endif #endif
#define S_ARRAY_SIZE(A) (sizeof(A) / sizeof(*(A))) #define S_ARRAY_SIZE(A) (sizeof(A) / sizeof(*(A)))
#define S_ARRAY_END(A) ((A) + S_ARRAY_SIZE(A)) #define S_ARRAY_END(A) ((A)+S_ARRAY_SIZE(A))
#define CP_REPLACEMENT_CHARACTER (0xFFFD) #define CP_REPLACEMENT_CHARACTER (0xFFFD)
@@ -46,7 +46,8 @@ enum UtfIntroCharType {
uictMax uictMax
}; };
static bool s_introFinalState[] = {false, // uis_start static bool s_introFinalState[] = {
false, // uis_start
false, // uis_utfbe_b1 false, // uis_utfbe_b1
false, // uis_utf32be_b2 false, // uis_utf32be_b2
false, // uis_utf32be_bom3 false, // uis_utf32be_bom3
@@ -105,7 +106,8 @@ static UtfIntroState s_introTransitions[][uictMax] = {
{uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8,
uis_utf8}, uis_utf8},
{uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8,
uis_utf8}, }; uis_utf8},
};
static char s_introUngetCount[][uictMax] = { static char s_introUngetCount[][uictMax] = {
// uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther
@@ -126,7 +128,8 @@ static char s_introUngetCount[][uictMax] = {
{4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4},
{2, 0, 2, 2, 2, 2, 2, 2}, {2, 0, 2, 2, 2, 2, 2, 2},
{3, 3, 0, 3, 3, 3, 3, 3}, {3, 3, 0, 3, 3, 3, 3, 3},
{1, 1, 1, 1, 1, 1, 1, 1}, }; {1, 1, 1, 1, 1, 1, 1, 1},
};
inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) { inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) {
if (std::istream::traits_type::eof() == ch) { if (std::istream::traits_type::eof() == ch) {

View File

@@ -52,7 +52,7 @@ def scalar(value, tag='', anchor='', anchor_id=0):
def comment(value): def comment(value):
return {'emit': 'Comment("%s")' % value, 'handle': ''} return {'emit': 'Comment("%s")' % value, 'handle': ''}
def seq_start(tag='', anchor='', anchor_id=0): def seq_start(tag='', anchor='', anchor_id=0, style='_'):
emit = [] emit = []
if tag: if tag:
emit += ['VerbatimTag("%s")' % encode(tag)] emit += ['VerbatimTag("%s")' % encode(tag)]
@@ -63,12 +63,12 @@ def seq_start(tag='', anchor='', anchor_id=0):
else: else:
out_tag = '?' out_tag = '?'
emit += ['BeginSeq'] emit += ['BeginSeq']
return {'emit': emit, 'handle': 'OnSequenceStart(_, "%s", %s)' % (out_tag, anchor_id)} return {'emit': emit, 'handle': 'OnSequenceStart(_, "%s", %s, %s)' % (out_tag, anchor_id, style)}
def seq_end(): def seq_end():
return {'emit': 'EndSeq', 'handle': 'OnSequenceEnd()'} return {'emit': 'EndSeq', 'handle': 'OnSequenceEnd()'}
def map_start(tag='', anchor='', anchor_id=0): def map_start(tag='', anchor='', anchor_id=0, style='_'):
emit = [] emit = []
if tag: if tag:
emit += ['VerbatimTag("%s")' % encode(tag)] emit += ['VerbatimTag("%s")' % encode(tag)]
@@ -79,7 +79,7 @@ def map_start(tag='', anchor='', anchor_id=0):
else: else:
out_tag = '?' out_tag = '?'
emit += ['BeginMap'] emit += ['BeginMap']
return {'emit': emit, 'handle': 'OnMapStart(_, "%s", %s)' % (out_tag, anchor_id)} return {'emit': emit, 'handle': 'OnMapStart(_, "%s", %s, %s)' % (out_tag, anchor_id, style)}
def map_end(): def map_end():
return {'emit': 'EndMap', 'handle': 'OnMapEnd()'} return {'emit': 'EndMap', 'handle': 'OnMapEnd()'}

View File

@@ -1,3 +1,4 @@
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep #include "yaml-cpp/yaml.h" // IWYU pragma: keep
#include "gtest/gtest.h" #include "gtest/gtest.h"
@@ -14,10 +15,12 @@ class NullEventHandler : public EventHandler {
virtual void OnScalar(const Mark&, const std::string&, anchor_t, virtual void OnScalar(const Mark&, const std::string&, anchor_t,
const std::string&) {} const std::string&) {}
virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t) {} virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t,
EmitterStyle::value style) {}
virtual void OnSequenceEnd() {} virtual void OnSequenceEnd() {}
virtual void OnMapStart(const Mark&, const std::string&, anchor_t) {} virtual void OnMapStart(const Mark&, const std::string&, anchor_t,
EmitterStyle::value style) {}
virtual void OnMapEnd() {} virtual void OnMapEnd() {}
}; };

View File

@@ -95,7 +95,7 @@ class EncodingTest : public HandlerTest {
void Run() { void Run() {
InSequence sequence; InSequence sequence;
EXPECT_CALL(handler, OnDocumentStart(_)); EXPECT_CALL(handler, OnDocumentStart(_));
EXPECT_CALL(handler, OnSequenceStart(_, "?", 0)); EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
for (std::size_t i = 0; i < m_entries.size(); i++) { for (std::size_t i = 0; i < m_entries.size(); i++) {
EXPECT_CALL(handler, OnScalar(_, "!", 0, m_entries[i])); EXPECT_CALL(handler, OnScalar(_, "!", 0, m_entries[i]));
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -11,8 +11,7 @@ using ::testing::_;
ASSERT_THROW(statement, ParserException); \ ASSERT_THROW(statement, ParserException); \
try { \ try { \
statement; \ statement; \
} \ } catch (const ParserException& e) { \
catch (const ParserException& e) { \
EXPECT_EQ(e.msg, message); \ EXPECT_EQ(e.msg, message); \
} }
@@ -26,7 +25,7 @@ TEST_F(HandlerTest, NoEndOfMapFlow) {
TEST_F(HandlerTest, PlainScalarStartingWithQuestionMark) { TEST_F(HandlerTest, PlainScalarStartingWithQuestionMark) {
EXPECT_CALL(handler, OnDocumentStart(_)); EXPECT_CALL(handler, OnDocumentStart(_));
EXPECT_CALL(handler, OnMapStart(_, "?", 0)); EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo")); EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
EXPECT_CALL(handler, OnScalar(_, "?", 0, "?bar")); EXPECT_CALL(handler, OnScalar(_, "?", 0, "?bar"));
EXPECT_CALL(handler, OnMapEnd()); EXPECT_CALL(handler, OnMapEnd());
@@ -36,7 +35,7 @@ TEST_F(HandlerTest, PlainScalarStartingWithQuestionMark) {
TEST_F(HandlerTest, NullStringScalar) { TEST_F(HandlerTest, NullStringScalar) {
EXPECT_CALL(handler, OnDocumentStart(_)); EXPECT_CALL(handler, OnDocumentStart(_));
EXPECT_CALL(handler, OnMapStart(_, "?", 0)); EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo")); EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
EXPECT_CALL(handler, OnNull(_, 0)); EXPECT_CALL(handler, OnNull(_, 0));
EXPECT_CALL(handler, OnMapEnd()); EXPECT_CALL(handler, OnMapEnd());

View File

@@ -1,3 +1,4 @@
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
@@ -14,11 +15,12 @@ class MockEventHandler : public EventHandler {
MOCK_METHOD4(OnScalar, void(const Mark&, const std::string&, anchor_t, MOCK_METHOD4(OnScalar, void(const Mark&, const std::string&, anchor_t,
const std::string&)); const std::string&));
MOCK_METHOD3(OnSequenceStart, MOCK_METHOD4(OnSequenceStart, void(const Mark&, const std::string&, anchor_t,
void(const Mark&, const std::string&, anchor_t)); EmitterStyle::value));
MOCK_METHOD0(OnSequenceEnd, void()); MOCK_METHOD0(OnSequenceEnd, void());
MOCK_METHOD3(OnMapStart, void(const Mark&, const std::string&, anchor_t)); MOCK_METHOD4(OnMapStart, void(const Mark&, const std::string&, anchor_t,
EmitterStyle::value));
MOCK_METHOD0(OnMapEnd, void()); MOCK_METHOD0(OnMapEnd, void());
}; };
} }

View File

@@ -1,5 +1,6 @@
#include <iostream> #include <iostream>
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep #include "yaml-cpp/yaml.h" // IWYU pragma: keep
@@ -16,9 +17,11 @@ class NullEventHandler : public YAML::EventHandler {
virtual void OnAlias(const Mark&, anchor_t) {} virtual void OnAlias(const Mark&, anchor_t) {}
virtual void OnScalar(const Mark&, const std::string&, anchor_t, virtual void OnScalar(const Mark&, const std::string&, anchor_t,
const std::string&) {} const std::string&) {}
virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t) {} virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value style) {}
virtual void OnSequenceEnd() {} virtual void OnSequenceEnd() {}
virtual void OnMapStart(const Mark&, const std::string&, anchor_t) {} virtual void OnMapStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value style) {}
virtual void OnMapEnd() {} virtual void OnMapEnd() {}
}; };

View File

@@ -1,5 +1,6 @@
#include <iostream> #include <iostream>
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h" #include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep #include "yaml-cpp/yaml.h" // IWYU pragma: keep
@@ -16,9 +17,11 @@ class NullEventHandler : public YAML::EventHandler {
virtual void OnAlias(const Mark&, anchor_t) {} virtual void OnAlias(const Mark&, anchor_t) {}
virtual void OnScalar(const Mark&, const std::string&, anchor_t, virtual void OnScalar(const Mark&, const std::string&, anchor_t,
const std::string&) {} const std::string&) {}
virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t) {} virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value style) {}
virtual void OnSequenceEnd() {} virtual void OnSequenceEnd() {}
virtual void OnMapStart(const Mark&, const std::string&, anchor_t) {} virtual void OnMapStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value style) {}
virtual void OnMapEnd() {} virtual void OnMapEnd() {}
}; };

View File

@@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@YAML_CPP_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

14
yaml-cpp-config.cmake.in Normal file
View File

@@ -0,0 +1,14 @@
# - Config file for the yaml-cpp package
# It defines the following variables
# YAML_CPP_INCLUDE_DIR - include directory
# YAML_CPP_LIBRARIES - libraries to link against
# Compute paths
get_filename_component(YAML_CPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(YAML_CPP_INCLUDE_DIR "@CONFIG_INCLUDE_DIRS@")
# Our library dependencies (contains definitions for IMPORTED targets)
include("${YAML_CPP_CMAKE_DIR}/yaml-cpp-targets.cmake")
# These are IMPORTED targets created by yaml-cpp-targets.cmake
set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@")