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
a626424b
Commit
a626424b
authored
May 22, 2012
by
Jesse Beder
Browse files
Split the block map prepare into key/value
parent
80823583
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
43 deletions
+53
-43
include/yaml-cpp/emitter.h
include/yaml-cpp/emitter.h
+2
-0
src/emitter.cpp
src/emitter.cpp
+51
-43
No files found.
include/yaml-cpp/emitter.h
View file @
a626424b
...
...
@@ -92,6 +92,8 @@ namespace YAML
void
BlockSeqPrepareNode
(
EmitterNodeType
::
value
child
);
void
FlowMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareKey
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareValue
(
EmitterNodeType
::
value
child
);
void
SpaceOrIndentTo
(
bool
requireSpace
,
unsigned
indent
);
...
...
src/emitter.cpp
View file @
a626424b
...
...
@@ -357,59 +357,67 @@ namespace YAML
}
void
Emitter
::
BlockMapPrepareNode
(
EmitterNodeType
::
value
child
)
{
const
std
::
size_t
childCount
=
m_pState
->
CurGroupChildCount
();
if
(
childCount
%
2
==
0
)
BlockMapPrepareKey
(
child
);
else
BlockMapPrepareValue
(
child
);
}
void
Emitter
::
BlockMapPrepareKey
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
unsigned
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
const
std
::
size_t
childCount
=
m_pState
->
CurGroupChildCount
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
childCount
%
2
==
0
)
{
// key
if
(
childCount
>
0
)
{
m_stream
<<
"
\n
"
;
}
if
(
false
/* long key */
)
{
}
}
else
{
// value
if
(
false
/* was long key */
)
{
}
else
{
m_stream
<<
":"
;
}
if
(
childCount
>
0
)
{
m_stream
<<
"
\n
"
;
}
if
(
false
/* long key */
)
{
}
}
if
(
childCount
%
2
==
0
)
{
// key
switch
(
child
)
{
case
EmitterNodeType
::
None
:
break
;
case
EmitterNodeType
::
Property
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
SpaceOrIndentTo
(
m_pState
->
HasBegunContent
(),
curIndent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
break
;
}
switch
(
child
)
{
case
EmitterNodeType
::
None
:
break
;
case
EmitterNodeType
::
Property
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
SpaceOrIndentTo
(
m_pState
->
HasBegunContent
(),
curIndent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
break
;
}
}
void
Emitter
::
BlockMapPrepareValue
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
unsigned
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
if
(
false
/* was long key */
)
{
}
else
{
// value
switch
(
child
)
{
case
EmitterNodeType
::
None
:
break
;
case
EmitterNodeType
::
Property
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
SpaceOrIndentTo
(
true
,
nextIndent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
m_stream
<<
"
\n
"
;
break
;
}
m_stream
<<
":"
;
}
switch
(
child
)
{
case
EmitterNodeType
::
None
:
break
;
case
EmitterNodeType
::
Property
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
SpaceOrIndentTo
(
true
,
nextIndent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
m_stream
<<
"
\n
"
;
break
;
}
}
...
...
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