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
d3801b74
Commit
d3801b74
authored
May 21, 2012
by
Jesse Beder
Browse files
Added newlines, fixed map/map
parent
b0dd0f86
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
4 deletions
+19
-4
src/emitter.cpp
src/emitter.cpp
+5
-1
src/emitterstate.cpp
src/emitterstate.cpp
+7
-1
src/emitterstate.h
src/emitterstate.h
+3
-1
util/sandbox.cpp
util/sandbox.cpp
+4
-1
No files found.
src/emitter.cpp
View file @
d3801b74
...
@@ -249,11 +249,15 @@ namespace YAML
...
@@ -249,11 +249,15 @@ namespace YAML
{
{
if
(
!
good
())
if
(
!
good
())
return
;
return
;
PrepareNode
(
m_pState
->
NextGroupType
(
GroupType
::
None
));
m_stream
<<
"
\n
"
;
m_pState
->
SetNonContent
();
}
}
bool
Emitter
::
CanEmitNewline
()
const
bool
Emitter
::
CanEmitNewline
()
const
{
{
return
fals
e
;
return
tru
e
;
}
}
// Put the stream in a state so we can simply write the next node
// Put the stream in a state so we can simply write the next node
...
...
src/emitterstate.cpp
View file @
d3801b74
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
namespace
YAML
namespace
YAML
{
{
EmitterState
::
EmitterState
()
:
m_isGood
(
true
),
m_curIndent
(
0
),
m_hasAnchor
(
false
),
m_hasTag
(
false
)
EmitterState
::
EmitterState
()
:
m_isGood
(
true
),
m_curIndent
(
0
),
m_hasAnchor
(
false
),
m_hasTag
(
false
)
,
m_hasNonContent
(
false
)
{
{
// set default global manipulators
// set default global manipulators
m_charset
.
set
(
EmitNonAscii
);
m_charset
.
set
(
EmitNonAscii
);
...
@@ -53,6 +53,11 @@ namespace YAML
...
@@ -53,6 +53,11 @@ namespace YAML
m_hasTag
=
true
;
m_hasTag
=
true
;
}
}
void
EmitterState
::
SetNonContent
()
{
m_hasNonContent
=
true
;
}
void
EmitterState
::
BeginNode
()
void
EmitterState
::
BeginNode
()
{
{
if
(
!
m_groups
.
empty
())
if
(
!
m_groups
.
empty
())
...
@@ -60,6 +65,7 @@ namespace YAML
...
@@ -60,6 +65,7 @@ namespace YAML
m_hasAnchor
=
false
;
m_hasAnchor
=
false
;
m_hasTag
=
false
;
m_hasTag
=
false
;
m_hasNonContent
=
false
;
}
}
EmitterNodeType
::
value
EmitterState
::
NextGroupType
(
GroupType
::
value
type
)
const
EmitterNodeType
::
value
EmitterState
::
NextGroupType
(
GroupType
::
value
type
)
const
...
...
src/emitterstate.h
View file @
d3801b74
...
@@ -36,6 +36,7 @@ namespace YAML
...
@@ -36,6 +36,7 @@ namespace YAML
// node handling
// node handling
void
SetAnchor
();
void
SetAnchor
();
void
SetTag
();
void
SetTag
();
void
SetNonContent
();
void
BeginScalar
();
void
BeginScalar
();
void
BeginGroup
(
GroupType
::
value
type
);
void
BeginGroup
(
GroupType
::
value
type
);
void
EndGroup
(
GroupType
::
value
type
);
void
EndGroup
(
GroupType
::
value
type
);
...
@@ -51,7 +52,7 @@ namespace YAML
...
@@ -51,7 +52,7 @@ namespace YAML
int
CurIndent
()
const
{
return
m_curIndent
;
}
int
CurIndent
()
const
{
return
m_curIndent
;
}
bool
HasAnchor
()
const
{
return
m_hasAnchor
;
}
bool
HasAnchor
()
const
{
return
m_hasAnchor
;
}
bool
HasTag
()
const
{
return
m_hasTag
;
}
bool
HasTag
()
const
{
return
m_hasTag
;
}
bool
HasBegunNode
()
const
{
return
m_hasAnchor
||
m_hasTag
;
}
bool
HasBegunNode
()
const
{
return
m_hasAnchor
||
m_hasTag
||
m_hasNonContent
;
}
void
ClearModifiedSettings
();
void
ClearModifiedSettings
();
...
@@ -157,6 +158,7 @@ namespace YAML
...
@@ -157,6 +158,7 @@ namespace YAML
unsigned
m_curIndent
;
unsigned
m_curIndent
;
bool
m_hasAnchor
;
bool
m_hasAnchor
;
bool
m_hasTag
;
bool
m_hasTag
;
bool
m_hasNonContent
;
};
};
template
<
typename
T
>
template
<
typename
T
>
...
...
util/sandbox.cpp
View file @
d3801b74
...
@@ -9,7 +9,10 @@ int main()
...
@@ -9,7 +9,10 @@ int main()
out
<<
"foo"
;
out
<<
"foo"
;
out
<<
YAML
::
LocalTag
(
"hi"
)
<<
"bar"
;
out
<<
YAML
::
LocalTag
(
"hi"
)
<<
"bar"
;
out
<<
YAML
::
Anchor
(
"asdf"
)
<<
YAML
::
BeginMap
;
out
<<
YAML
::
Anchor
(
"asdf"
)
<<
YAML
::
BeginMap
;
out
<<
"a"
<<
"b"
<<
"c"
<<
"d"
;
out
<<
"a"
<<
"b"
<<
"c"
<<
YAML
::
Newline
;
out
<<
YAML
::
Anchor
(
"a"
)
<<
YAML
::
BeginMap
;
out
<<
"a"
<<
"b"
;
out
<<
YAML
::
EndMap
;
out
<<
YAML
::
EndMap
;
out
<<
YAML
::
EndMap
;
out
<<
YAML
::
LocalTag
(
"hi"
)
<<
YAML
::
BeginSeq
;
out
<<
YAML
::
LocalTag
(
"hi"
)
<<
YAML
::
BeginSeq
;
out
<<
"a"
<<
"b"
;
out
<<
"a"
<<
"b"
;
...
...
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