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
bf07af52
Commit
bf07af52
authored
May 22, 2012
by
Jesse Beder
Browse files
Added long key
parent
41e4cd33
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
32 deletions
+38
-32
src/emitter.cpp
src/emitter.cpp
+35
-31
util/sandbox.cpp
util/sandbox.cpp
+3
-1
No files found.
src/emitter.cpp
View file @
bf07af52
...
...
@@ -358,22 +358,22 @@ namespace YAML
void
Emitter
::
BlockMapPrepareNode
(
EmitterNodeType
::
value
child
)
{
const
std
::
size_t
childCount
=
m_pState
->
CurGroupChildCount
()
;
if
(
childCount
%
2
==
0
)
{
if
(
m_pState
->
GetMapKeyFormat
()
==
LongKey
||
child
==
EmitterNodeType
::
BlockSeq
||
child
==
EmitterNodeType
::
BlockMap
)
m_pState
->
SetLongKey
();
if
(
m_pState
->
CurGroupLongKey
())
BlockMapPrepareLongKey
(
child
);
else
BlockMapPrepareSimpleKey
(
child
);
}
else
{
if
(
m_pState
->
CurGroupLongKey
())
BlockMapPrepareLongKeyValue
(
child
);
else
BlockMapPrepareSimpleKeyValue
(
child
);
}
if
(
m_pState
->
CurGroupChildCount
()
%
2
==
0
)
{
if
(
m_pState
->
GetMapKeyFormat
()
==
LongKey
)
m_pState
->
SetLongKey
();
if
(
child
==
EmitterNodeType
::
BlockSeq
||
child
==
EmitterNodeType
::
BlockMap
)
m_pState
->
SetLongKey
();
if
(
m_pState
->
CurGroupLongKey
())
BlockMapPrepareLongKey
(
child
);
else
BlockMapPrepareSimpleKey
(
child
);
}
else
{
if
(
m_pState
->
CurGroupLongKey
())
BlockMapPrepareLongKeyValue
(
child
);
else
BlockMapPrepareSimpleKeyValue
(
child
);
}
}
void
Emitter
::
BlockMapPrepareLongKey
(
EmitterNodeType
::
value
child
)
...
...
@@ -410,18 +410,18 @@ namespace YAML
}
}
void
Emitter
::
BlockMapPrepare
SimpleKey
(
EmitterNodeType
::
value
child
)
void
Emitter
::
BlockMapPrepare
LongKeyValue
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
std
::
size_t
childCou
nt
=
m_pState
->
CurGroup
ChildCou
nt
();
const
unsigned
nextIndent
=
curInde
nt
+
m_pState
->
CurGroup
Inde
nt
();
if
(
child
==
EmitterNodeType
::
None
)
return
;
if
(
!
m_pState
->
HasBegun
Node
())
{
if
(
childCount
>
0
)
{
m_stream
<<
"
\n
"
;
}
if
(
!
m_pState
->
HasBegun
Content
())
{
m_stream
<<
"
\n
"
;
m_stream
<<
IndentTo
(
curIndent
)
;
m_stream
<<
":"
;
}
switch
(
child
)
{
...
...
@@ -431,20 +431,25 @@ namespace YAML
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
SpaceOrIndentTo
(
m_pState
->
HasBegunContent
(),
curIndent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
SpaceOrIndentTo
(
true
,
nextIndent
);
break
;
}
}
void
Emitter
::
BlockMapPrepare
LongKeyValue
(
EmitterNodeType
::
value
child
)
void
Emitter
::
BlockMapPrepare
SimpleKey
(
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
(
child
==
EmitterNodeType
::
None
)
return
;
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
childCount
>
0
)
{
m_stream
<<
"
\n
"
;
}
}
switch
(
child
)
{
...
...
@@ -454,15 +459,14 @@ namespace YAML
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
SpaceOrIndentTo
(
true
,
next
Indent
);
SpaceOrIndentTo
(
m_pState
->
HasBegunContent
(),
cur
Indent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
m_stream
<<
"
\n
"
;
break
;
}
}
void
Emitter
::
BlockMapPrepareSimpleKeyValue
(
EmitterNodeType
::
value
child
)
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
...
...
util/sandbox.cpp
View file @
bf07af52
...
...
@@ -8,7 +8,9 @@ int main()
out
<<
YAML
::
BeginMap
;
out
<<
"a"
<<
"b"
;
out
<<
YAML
::
EndMap
;
out
<<
"c"
;
out
<<
YAML
::
BeginMap
;
out
<<
"a"
<<
"b"
;
out
<<
YAML
::
EndMap
;
out
<<
YAML
::
EndMap
;
std
::
cout
<<
out
.
c_str
()
<<
"
\n
"
;
...
...
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