Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
9880b608
Commit
9880b608
authored
Jan 24, 2015
by
Jesse Beder
Browse files
Merge from core
parents
1aa25e76
ad712c4f
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
142 additions
and
62 deletions
+142
-62
CMakeLists.txt
CMakeLists.txt
+12
-0
include/yaml-cpp/binary.h
include/yaml-cpp/binary.h
+1
-1
include/yaml-cpp/emitfromevents.h
include/yaml-cpp/emitfromevents.h
+3
-2
include/yaml-cpp/emitterstyle.h
include/yaml-cpp/emitterstyle.h
+20
-0
include/yaml-cpp/eventhandler.h
include/yaml-cpp/eventhandler.h
+5
-3
include/yaml-cpp/yaml.h
include/yaml-cpp/yaml.h
+1
-0
src/binary.cpp
src/binary.cpp
+2
-1
src/contrib/graphbuilderadapter.cpp
src/contrib/graphbuilderadapter.cpp
+4
-2
src/contrib/graphbuilderadapter.h
src/contrib/graphbuilderadapter.h
+3
-2
src/emitfromevents.cpp
src/emitfromevents.cpp
+23
-2
src/nodebuilder.cpp
src/nodebuilder.cpp
+3
-2
src/nodebuilder.h
src/nodebuilder.h
+3
-2
src/nodeevents.cpp
src/nodeevents.cpp
+3
-2
src/regex_yaml.cpp
src/regex_yaml.cpp
+1
-1
src/regex_yaml.h
src/regex_yaml.h
+1
-1
src/scanner.cpp
src/scanner.cpp
+3
-2
src/singledocparser.cpp
src/singledocparser.cpp
+13
-4
src/stream.cpp
src/stream.cpp
+25
-22
test/create-emitter-tests.py
test/create-emitter-tests.py
+4
-4
test/integration/emitter_test.cpp
test/integration/emitter_test.cpp
+12
-9
No files found.
CMakeLists.txt
View file @
9880b608
...
...
@@ -305,6 +305,18 @@ install(
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
)
set
(
PC_FILE
${
CMAKE_BINARY_DIR
}
/yaml-cpp.pc
)
configure_file
(
"yaml-cpp.pc.cmake"
${
PC_FILE
}
@ONLY
)
...
...
include/yaml-cpp/binary.h
View file @
9880b608
...
...
@@ -34,7 +34,7 @@ class YAML_CPP_API Binary {
m_data
.
swap
(
rhs
);
rhs
.
clear
();
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_unownedSize
=
0
;
}
else
{
...
...
include/yaml-cpp/emitfromevents.h
View file @
9880b608
...
...
@@ -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:
...
...
include/yaml-cpp/emitterstyle.h
0 → 100644
View file @
9880b608
#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
include/yaml-cpp/eventhandler.h
View file @
9880b608
...
...
@@ -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
;
};
}
...
...
include/yaml-cpp/yaml.h
View file @
9880b608
...
...
@@ -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"
...
...
src/binary.cpp
View file @
9880b608
...
...
@@ -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
,
};
std
::
vector
<
unsigned
char
>
DecodeBase64
(
const
std
::
string
&
input
)
{
typedef
std
::
vector
<
unsigned
char
>
ret_type
;
...
...
src/contrib/graphbuilderadapter.cpp
View file @
9880b608
...
...
@@ -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
;
...
...
src/contrib/graphbuilderadapter.h
View file @
9880b608
...
...
@@ -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
;
}
...
...
src/emitfromevents.cpp
View file @
9880b608
...
...
@@ -44,9 +44,20 @@ void EmitFromEvents::OnScalar(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
();
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_stateStack
.
push
(
State
::
WaitingForSequenceEntry
);
}
...
...
@@ -58,9 +69,19 @@ void EmitFromEvents::OnSequenceEnd() {
}
void
EmitFromEvents
::
OnMapStart
(
const
Mark
&
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
{
anchor_t
anchor
,
EmitterStyle
::
value
style
)
{
BeginNode
();
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_stateStack
.
push
(
State
::
WaitingForKey
);
}
...
...
src/nodebuilder.cpp
View file @
9880b608
...
...
@@ -49,7 +49,8 @@ void NodeBuilder::OnScalar(const Mark& /* mark */, const std::string& tag,
}
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
);
node
.
set_tag
(
tag
);
node
.
set_type
(
NodeType
::
Sequence
);
...
...
@@ -58,7 +59,7 @@ void NodeBuilder::OnSequenceStart(const Mark& /* mark */,
void
NodeBuilder
::
OnSequenceEnd
()
{
Pop
();
}
void
NodeBuilder
::
OnMapStart
(
const
Mark
&
/* mark */
,
const
std
::
string
&
tag
,
anchor_t
anchor
)
{
anchor_t
anchor
,
EmitterStyle
::
value
style
)
{
detail
::
node
&
node
=
Push
(
anchor
);
node
.
set_type
(
NodeType
::
Map
);
node
.
set_tag
(
tag
);
...
...
src/nodebuilder.h
View file @
9880b608
...
...
@@ -10,6 +10,7 @@
#include <vector>
#include "yaml-cpp/anchor.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/node/ptr.h"
...
...
@@ -39,11 +40,11 @@ class NodeBuilder : 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:
...
...
src/nodeevents.cpp
View file @
9880b608
...
...
@@ -76,14 +76,15 @@ void NodeEvents::Emit(const detail::node& node, EventHandler& handler,
handler
.
OnScalar
(
Mark
(),
node
.
tag
(),
anchor
,
node
.
scalar
());
break
;
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
();
++
it
)
Emit
(
**
it
,
handler
,
am
);
handler
.
OnSequenceEnd
();
break
;
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
();
++
it
)
{
Emit
(
*
it
->
first
,
handler
,
am
);
...
...
src/regex_yaml.cpp
View file @
9880b608
...
...
@@ -16,7 +16,7 @@ RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op) {
}
// combination constructors
RegEx
operator
!
(
const
RegEx
&
ex
)
{
RegEx
operator
!
(
const
RegEx
&
ex
)
{
RegEx
ret
(
REGEX_NOT
);
ret
.
m_params
.
push_back
(
ex
);
return
ret
;
...
...
src/regex_yaml.h
View file @
9880b608
...
...
@@ -34,7 +34,7 @@ class RegEx {
RegEx
(
const
std
::
string
&
str
,
REGEX_OP
op
=
REGEX_SEQ
);
~
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
);
...
...
src/scanner.cpp
View file @
9880b608
...
...
@@ -317,8 +317,9 @@ void Scanner::PopIndentToHere() {
const
IndentMarker
&
indent
=
*
m_indents
.
top
();
if
(
indent
.
column
<
INPUT
.
column
())
break
;
if
(
indent
.
column
==
INPUT
.
column
()
&&
!
(
indent
.
type
==
IndentMarker
::
SEQ
&&
!
Exp
::
BlockEntry
().
Matches
(
INPUT
)))
if
(
indent
.
column
==
INPUT
.
column
()
&&
!
(
indent
.
type
==
IndentMarker
::
SEQ
&&
!
Exp
::
BlockEntry
().
Matches
(
INPUT
)))
break
;
PopIndent
();
...
...
src/singledocparser.cpp
View file @
9880b608
...
...
@@ -7,6 +7,7 @@
#include "singledocparser.h"
#include "tag.h"
#include "token.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/exceptions.h" // IWYU pragma: keep
#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
if
(
m_scanner
.
peek
().
type
==
Token
::
VALUE
)
{
eventHandler
.
OnMapStart
(
mark
,
"?"
,
NullAnchor
);
eventHandler
.
OnMapStart
(
mark
,
"?"
,
NullAnchor
,
EmitterStyle
::
Default
);
HandleMap
(
eventHandler
);
eventHandler
.
OnMapEnd
();
return
;
...
...
@@ -92,14 +93,22 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
m_scanner
.
pop
();
return
;
case
Token
::
FLOW_SEQ_START
:
eventHandler
.
OnSequenceStart
(
mark
,
tag
,
anchor
,
EmitterStyle
::
Flow
);
HandleSequence
(
eventHandler
);
eventHandler
.
OnSequenceEnd
();
return
;
case
Token
::
BLOCK_SEQ_START
:
eventHandler
.
OnSequenceStart
(
mark
,
tag
,
anchor
);
eventHandler
.
OnSequenceStart
(
mark
,
tag
,
anchor
,
EmitterStyle
::
Block
);
HandleSequence
(
eventHandler
);
eventHandler
.
OnSequenceEnd
();
return
;
case
Token
::
FLOW_MAP_START
:
eventHandler
.
OnMapStart
(
mark
,
tag
,
anchor
,
EmitterStyle
::
Flow
);
HandleMap
(
eventHandler
);
eventHandler
.
OnMapEnd
();
return
;
case
Token
::
BLOCK_MAP_START
:
eventHandler
.
OnMapStart
(
mark
,
tag
,
anchor
);
eventHandler
.
OnMapStart
(
mark
,
tag
,
anchor
,
EmitterStyle
::
Block
);
HandleMap
(
eventHandler
);
eventHandler
.
OnMapEnd
();
return
;
...
...
@@ -107,7 +116,7 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
// compact maps can only go in a flow sequence
if
(
m_pCollectionStack
->
GetCurCollectionType
()
==
CollectionType
::
FlowSeq
)
{
eventHandler
.
OnMapStart
(
mark
,
tag
,
anchor
);
eventHandler
.
OnMapStart
(
mark
,
tag
,
anchor
,
EmitterStyle
::
Flow
);
HandleMap
(
eventHandler
);
eventHandler
.
OnMapEnd
();
return
;
...
...
src/stream.cpp
View file @
9880b608
...
...
@@ -7,7 +7,7 @@
#endif
#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)
...
...
@@ -46,25 +46,26 @@ enum UtfIntroCharType {
uictMax
};
static
bool
s_introFinalState
[]
=
{
false
,
// uis_start
false
,
// uis_utfbe_b1
false
,
// uis_utf32be_b2
false
,
// uis_utf32be_bom3
true
,
// uis_utf32be
true
,
// uis_utf16be
false
,
// uis_utf16be_bom1
false
,
// uis_utfle_bom1
false
,
// uis_utf16le_bom2
false
,
// uis_utf32le_bom3
true
,
// uis_utf16le
true
,
// uis_utf32le
false
,
// uis_utf8_imp
false
,
// uis_utf16le_imp
false
,
// uis_utf32le_imp3
false
,
// uis_utf8_bom1
false
,
// uis_utf8_bom2
true
,
// uis_utf8
true
,
// uis_error
static
bool
s_introFinalState
[]
=
{
false
,
// uis_start
false
,
// uis_utfbe_b1
false
,
// uis_utf32be_b2
false
,
// uis_utf32be_bom3
true
,
// uis_utf32be
true
,
// uis_utf16be
false
,
// uis_utf16be_bom1
false
,
// uis_utfle_bom1
false
,
// uis_utf16le_bom2
false
,
// uis_utf32le_bom3
true
,
// uis_utf16le
true
,
// uis_utf32le
false
,
// uis_utf8_imp
false
,
// uis_utf16le_imp
false
,
// uis_utf32le_imp3
false
,
// uis_utf8_bom1
false
,
// uis_utf8_bom2
true
,
// uis_utf8
true
,
// uis_error
};
static
UtfIntroState
s_introTransitions
[][
uictMax
]
=
{
...
...
@@ -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
},
};
static
char
s_introUngetCount
[][
uictMax
]
=
{
// 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
},
{
2
,
0
,
2
,
2
,
2
,
2
,
2
,
2
},
{
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
)
{
if
(
std
::
istream
::
traits_type
::
eof
()
==
ch
)
{
...
...
test/create-emitter-tests.py
View file @
9880b608
...
...
@@ -52,7 +52,7 @@ def scalar(value, tag='', anchor='', anchor_id=0):
def
comment
(
value
):
return
{
'emit'
:
'Comment("%s")'
%
value
,
'handle'
:
''
}
def
seq_start
(
tag
=
''
,
anchor
=
''
,
anchor_id
=
0
):
def
seq_start
(
tag
=
''
,
anchor
=
''
,
anchor_id
=
0
,
style
=
'_'
):
emit
=
[]
if
tag
:
emit
+=
[
'VerbatimTag("%s")'
%
encode
(
tag
)]
...
...
@@ -63,12 +63,12 @@ def seq_start(tag='', anchor='', anchor_id=0):
else
:
out_tag
=
'?'
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
():
return
{
'emit'
:
'EndSeq'
,
'handle'
:
'OnSequenceEnd()'
}
def
map_start
(
tag
=
''
,
anchor
=
''
,
anchor_id
=
0
):
def
map_start
(
tag
=
''
,
anchor
=
''
,
anchor_id
=
0
,
style
=
'_'
):
emit
=
[]
if
tag
:
emit
+=
[
'VerbatimTag("%s")'
%
encode
(
tag
)]
...
...
@@ -79,7 +79,7 @@ def map_start(tag='', anchor='', anchor_id=0):
else
:
out_tag
=
'?'
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
():
return
{
'emit'
:
'EndMap'
,
'handle'
:
'OnMapEnd()'
}
...
...
test/integration/emitter_test.cpp
View file @
9880b608
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep
#include "gtest/gtest.h"
...
...
@@ -14,10 +15,12 @@ class NullEventHandler : public EventHandler {
virtual
void
OnScalar
(
const
Mark
&
,
const
std
::
string
&
,
anchor_t
,
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
OnMapStart
(
const
Mark
&
,
const
std
::
string
&
,
anchor_t
)
{}
virtual
void
OnMapStart
(
const
Mark
&
,
const
std
::
string
&
,
anchor_t
,
EmitterStyle
::
value
style
)
{}
virtual
void
OnMapEnd
()
{}
};
...
...
@@ -775,13 +778,13 @@ TEST_F(EmitterTest, Binary) {
TEST_F
(
EmitterTest
,
LongBinary
)
{
out
<<
Binary
(
reinterpret_cast
<
const
unsigned
char
*>
(
"Man is distinguished, not only by his reason, but by this "
"singular passion from other animals, which is a lust of the "
"mind, that by a perseverance of delight in the continued and "
"indefatigable generation of knowledge, exceeds the short "
"vehemence of any carnal pleasure.
\n
"
),
270
);
reinterpret_cast
<
const
unsigned
char
*>
(
"Man is distinguished, not only by his reason, but by this "
"singular passion from other animals, which is a lust of the "
"mind, that by a perseverance of delight in the continued and "
"indefatigable generation of knowledge, exceeds the short "
"vehemence of any carnal pleasure.
\n
"
),
270
);
ExpectEmit
(
"!!binary "
"
\"
TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS"
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment