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
98acc5a8
"profiler/src/profile_convnd_bwd_weight.cpp" did not exist on "d3051d75175268ee8d6beb64b0177d4c08733291"
Unverified
Commit
98acc5a8
authored
Jul 28, 2020
by
Chen
Committed by
GitHub
Jul 27, 2020
Browse files
Emit the correct Alias on the key (#908) (#929)
parent
1c9abc8f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
0 deletions
+30
-0
src/emitter.cpp
src/emitter.cpp
+8
-0
src/emitterstate.cpp
src/emitterstate.cpp
+4
-0
src/emitterstate.h
src/emitterstate.h
+3
-0
test/integration/emitter_test.cpp
test/integration/emitter_test.cpp
+15
-0
No files found.
src/emitter.cpp
View file @
98acc5a8
...
@@ -504,6 +504,9 @@ void Emitter::FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
...
@@ -504,6 +504,9 @@ void Emitter::FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
if
(
m_stream
.
comment
())
if
(
m_stream
.
comment
())
m_stream
<<
"
\n
"
;
m_stream
<<
"
\n
"
;
m_stream
<<
IndentTo
(
lastIndent
);
m_stream
<<
IndentTo
(
lastIndent
);
if
(
m_pState
->
HasAlias
())
{
m_stream
<<
" "
;
}
m_stream
<<
":"
;
m_stream
<<
":"
;
}
}
...
@@ -643,6 +646,9 @@ void Emitter::BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
...
@@ -643,6 +646,9 @@ void Emitter::BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
const
std
::
size_t
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
const
std
::
size_t
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_pState
->
HasAlias
())
{
m_stream
<<
" "
;
}
m_stream
<<
":"
;
m_stream
<<
":"
;
}
}
...
@@ -864,6 +870,8 @@ Emitter& Emitter::Write(const _Alias& alias) {
...
@@ -864,6 +870,8 @@ Emitter& Emitter::Write(const _Alias& alias) {
StartedScalar
();
StartedScalar
();
m_pState
->
SetAlias
();
return
*
this
;
return
*
this
;
}
}
...
...
src/emitterstate.cpp
View file @
98acc5a8
...
@@ -29,6 +29,7 @@ EmitterState::EmitterState()
...
@@ -29,6 +29,7 @@ EmitterState::EmitterState()
m_groups
{},
m_groups
{},
m_curIndent
(
0
),
m_curIndent
(
0
),
m_hasAnchor
(
false
),
m_hasAnchor
(
false
),
m_hasAlias
(
false
),
m_hasTag
(
false
),
m_hasTag
(
false
),
m_hasNonContent
(
false
),
m_hasNonContent
(
false
),
m_docCount
(
0
)
{}
m_docCount
(
0
)
{}
...
@@ -53,6 +54,8 @@ void EmitterState::SetLocalValue(EMITTER_MANIP value) {
...
@@ -53,6 +54,8 @@ void EmitterState::SetLocalValue(EMITTER_MANIP value) {
void
EmitterState
::
SetAnchor
()
{
m_hasAnchor
=
true
;
}
void
EmitterState
::
SetAnchor
()
{
m_hasAnchor
=
true
;
}
void
EmitterState
::
SetAlias
()
{
m_hasAlias
=
true
;
}
void
EmitterState
::
SetTag
()
{
m_hasTag
=
true
;
}
void
EmitterState
::
SetTag
()
{
m_hasTag
=
true
;
}
void
EmitterState
::
SetNonContent
()
{
m_hasNonContent
=
true
;
}
void
EmitterState
::
SetNonContent
()
{
m_hasNonContent
=
true
;
}
...
@@ -87,6 +90,7 @@ void EmitterState::StartedNode() {
...
@@ -87,6 +90,7 @@ void EmitterState::StartedNode() {
}
}
m_hasAnchor
=
false
;
m_hasAnchor
=
false
;
m_hasAlias
=
false
;
m_hasTag
=
false
;
m_hasTag
=
false
;
m_hasNonContent
=
false
;
m_hasNonContent
=
false
;
}
}
...
...
src/emitterstate.h
View file @
98acc5a8
...
@@ -43,6 +43,7 @@ class EmitterState {
...
@@ -43,6 +43,7 @@ class EmitterState {
// node handling
// node handling
void
SetAnchor
();
void
SetAnchor
();
void
SetAlias
();
void
SetTag
();
void
SetTag
();
void
SetNonContent
();
void
SetNonContent
();
void
SetLongKey
();
void
SetLongKey
();
...
@@ -65,6 +66,7 @@ class EmitterState {
...
@@ -65,6 +66,7 @@ class EmitterState {
std
::
size_t
LastIndent
()
const
;
std
::
size_t
LastIndent
()
const
;
std
::
size_t
CurIndent
()
const
{
return
m_curIndent
;
}
std
::
size_t
CurIndent
()
const
{
return
m_curIndent
;
}
bool
HasAnchor
()
const
{
return
m_hasAnchor
;
}
bool
HasAnchor
()
const
{
return
m_hasAnchor
;
}
bool
HasAlias
()
const
{
return
m_hasAlias
;
}
bool
HasTag
()
const
{
return
m_hasTag
;
}
bool
HasTag
()
const
{
return
m_hasTag
;
}
bool
HasBegunNode
()
const
{
bool
HasBegunNode
()
const
{
return
m_hasAnchor
||
m_hasTag
||
m_hasNonContent
;
return
m_hasAnchor
||
m_hasTag
||
m_hasNonContent
;
...
@@ -187,6 +189,7 @@ class EmitterState {
...
@@ -187,6 +189,7 @@ class EmitterState {
std
::
vector
<
std
::
unique_ptr
<
Group
>>
m_groups
;
std
::
vector
<
std
::
unique_ptr
<
Group
>>
m_groups
;
std
::
size_t
m_curIndent
;
std
::
size_t
m_curIndent
;
bool
m_hasAnchor
;
bool
m_hasAnchor
;
bool
m_hasAlias
;
bool
m_hasTag
;
bool
m_hasTag
;
bool
m_hasNonContent
;
bool
m_hasNonContent
;
std
::
size_t
m_docCount
;
std
::
size_t
m_docCount
;
...
...
test/integration/emitter_test.cpp
View file @
98acc5a8
...
@@ -430,6 +430,21 @@ TEST_F(EmitterTest, AliasAndAnchor) {
...
@@ -430,6 +430,21 @@ TEST_F(EmitterTest, AliasAndAnchor) {
ExpectEmit
(
"- &fred
\n
name: Fred
\n
age: 42
\n
- *fred"
);
ExpectEmit
(
"- &fred
\n
name: Fred
\n
age: 42
\n
- *fred"
);
}
}
TEST_F
(
EmitterTest
,
AliasOnKey
)
{
out
<<
BeginSeq
;
out
<<
Anchor
(
"name"
)
<<
"Name"
;
out
<<
BeginMap
;
out
<<
Key
<<
Alias
(
"name"
)
<<
Value
<<
"Fred"
;
out
<<
EndMap
;
out
<<
Flow
<<
BeginMap
;
out
<<
Key
<<
Alias
(
"name"
)
<<
Value
<<
"Mike"
;
out
<<
EndMap
;
out
<<
EndSeq
;
ExpectEmit
(
R"(- &name Name
- *name : Fred
- {*name : Mike})"
);
}
TEST_F
(
EmitterTest
,
AliasAndAnchorWithNull
)
{
TEST_F
(
EmitterTest
,
AliasAndAnchorWithNull
)
{
out
<<
BeginSeq
;
out
<<
BeginSeq
;
out
<<
Anchor
(
"fred"
)
<<
Null
;
out
<<
Anchor
(
"fred"
)
<<
Null
;
...
...
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