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
80823583
Commit
80823583
authored
May 22, 2012
by
Jesse Beder
Browse files
Tweaked spacing for comments
parent
eef692d7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
+29
-15
include/yaml-cpp/emitter.h
include/yaml-cpp/emitter.h
+2
-0
src/emitter.cpp
src/emitter.cpp
+23
-12
util/sandbox.cpp
util/sandbox.cpp
+4
-3
No files found.
include/yaml-cpp/emitter.h
View file @
80823583
...
...
@@ -93,6 +93,8 @@ namespace YAML
void
FlowMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
BlockMapPrepareNode
(
EmitterNodeType
::
value
child
);
void
SpaceOrIndentTo
(
bool
requireSpace
,
unsigned
indent
);
const
char
*
ComputeFullBoolName
(
bool
b
)
const
;
bool
CanEmitNewline
()
const
;
...
...
src/emitter.cpp
View file @
80823583
...
...
@@ -322,8 +322,11 @@ namespace YAML
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
unsigned
nextIndent
=
curIndent
+
m_pState
->
CurGroupIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_pState
->
CurGroupChildCount
()
>
0
)
{
if
(
child
==
EmitterNodeType
::
None
)
return
;
if
(
!
m_pState
->
HasBegunContent
())
{
if
(
m_pState
->
CurGroupChildCount
()
>
0
||
m_stream
.
comment
())
{
m_stream
<<
"
\n
"
;
}
m_stream
<<
IndentTo
(
curIndent
);
...
...
@@ -332,20 +335,18 @@ namespace YAML
switch
(
child
)
{
case
EmitterNodeType
::
None
:
break
;
case
EmitterNodeType
::
Property
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
if
(
m_pState
->
HasBegunContent
())
m_stream
<<
" "
;
else
m_stream
<<
IndentTo
(
nextIndent
);
SpaceOrIndentTo
(
m_pState
->
HasBegunContent
(),
nextIndent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
m_stream
<<
"
\n
"
;
break
;
case
EmitterNodeType
::
BlockMap
:
if
(
m_pState
->
HasBegunContent
())
if
(
m_pState
->
HasBegunContent
()
||
m_stream
.
comment
()
)
m_stream
<<
"
\n
"
;
break
;
}
...
...
@@ -382,14 +383,12 @@ namespace YAML
// key
switch
(
child
)
{
case
EmitterNodeType
::
None
:
break
;
case
EmitterNodeType
::
Property
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
if
(
m_pState
->
HasBegunContent
())
m_stream
<<
" "
;
else
m_stream
<<
IndentTo
(
curIndent
);
SpaceOrIndentTo
(
m_pState
->
HasBegunContent
(),
curIndent
);
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
...
...
@@ -399,11 +398,12 @@ namespace YAML
// value
switch
(
child
)
{
case
EmitterNodeType
::
None
:
break
;
case
EmitterNodeType
::
Property
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
m_stream
<<
" "
;
SpaceOrIndentTo
(
true
,
nextIndent
)
;
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
...
...
@@ -413,6 +413,17 @@ namespace YAML
}
}
// SpaceOrIndentTo
// . Prepares for some more content by proper spacing
void
Emitter
::
SpaceOrIndentTo
(
bool
requireSpace
,
unsigned
indent
)
{
if
(
m_stream
.
comment
())
m_stream
<<
"
\n
"
;
if
(
m_stream
.
col
()
>
0
&&
requireSpace
)
m_stream
<<
" "
;
m_stream
<<
IndentTo
(
indent
);
}
// *******************************************************************************************
// overloads of Write
...
...
util/sandbox.cpp
View file @
80823583
...
...
@@ -6,9 +6,10 @@ int main()
YAML
::
Emitter
out
;
out
<<
YAML
::
Comment
(
"Hello"
);
out
<<
YAML
::
BeginSeq
;
out
<<
"item 1"
;
out
<<
YAML
::
BeginMap
;
out
<<
"pens"
<<
"a"
;
out
<<
YAML
::
Comment
(
"Hello"
);
out
<<
YAML
::
Anchor
(
"a"
)
<<
YAML
::
Comment
(
"anchor"
)
<<
"item 1"
<<
YAML
::
Comment
(
"a"
);
out
<<
YAML
::
BeginMap
<<
YAML
::
Comment
(
"b"
);
out
<<
"pens"
<<
YAML
::
Comment
(
"foo"
)
<<
"a"
<<
YAML
::
Comment
(
"bar"
);
out
<<
"pencils"
<<
"b"
;
out
<<
YAML
::
EndMap
;
out
<<
"item 2"
;
...
...
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