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
0f3f1e26
Commit
0f3f1e26
authored
May 21, 2012
by
Jesse Beder
Browse files
Fixed map/value
parent
f72e325c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
24 deletions
+16
-24
src/emitter.cpp
src/emitter.cpp
+9
-12
src/emitterstate.h
src/emitterstate.h
+2
-1
util/sandbox.cpp
util/sandbox.cpp
+5
-11
No files found.
src/emitter.cpp
View file @
0f3f1e26
...
@@ -299,7 +299,7 @@ namespace YAML
...
@@ -299,7 +299,7 @@ namespace YAML
case
EmitterNodeType
::
FlowMap
:
case
EmitterNodeType
::
FlowMap
:
// TODO: if we were writing null, and
// TODO: if we were writing null, and
// we wanted it blank, we wouldn't want a space
// we wanted it blank, we wouldn't want a space
if
(
m_pState
->
HasBegun
Node
())
if
(
m_pState
->
HasBegun
Content
())
m_stream
<<
" "
;
m_stream
<<
" "
;
break
;
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockSeq
:
...
@@ -332,16 +332,16 @@ namespace YAML
...
@@ -332,16 +332,16 @@ namespace YAML
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
case
EmitterNodeType
::
FlowMap
:
if
(
m_stream
.
col
()
<
nextIndent
)
if
(
m_pState
->
HasBegunContent
())
m_stream
<<
IndentTo
(
nextIndent
);
else
m_stream
<<
" "
;
m_stream
<<
" "
;
else
m_stream
<<
IndentTo
(
nextIndent
);
break
;
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockSeq
:
m_stream
<<
"
\n
"
;
m_stream
<<
"
\n
"
;
break
;
break
;
case
EmitterNodeType
::
BlockMap
:
case
EmitterNodeType
::
BlockMap
:
if
(
m_pState
->
HasBegun
Node
())
if
(
m_pState
->
HasBegun
Content
())
m_stream
<<
"
\n
"
;
m_stream
<<
"
\n
"
;
break
;
break
;
}
}
...
@@ -381,10 +381,10 @@ namespace YAML
...
@@ -381,10 +381,10 @@ namespace YAML
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
case
EmitterNodeType
::
FlowMap
:
if
(
m_stream
.
col
()
<
curIndent
)
if
(
m_pState
->
HasBegunContent
())
m_stream
<<
IndentTo
(
curIndent
);
else
m_stream
<<
" "
;
m_stream
<<
" "
;
else
m_stream
<<
IndentTo
(
curIndent
);
break
;
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockMap
:
case
EmitterNodeType
::
BlockMap
:
...
@@ -397,9 +397,6 @@ namespace YAML
...
@@ -397,9 +397,6 @@ namespace YAML
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
Scalar
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowSeq
:
case
EmitterNodeType
::
FlowMap
:
case
EmitterNodeType
::
FlowMap
:
if
(
m_stream
.
col
()
<
nextIndent
)
m_stream
<<
IndentTo
(
nextIndent
);
else
m_stream
<<
" "
;
m_stream
<<
" "
;
break
;
break
;
case
EmitterNodeType
::
BlockSeq
:
case
EmitterNodeType
::
BlockSeq
:
...
...
src/emitterstate.h
View file @
0f3f1e26
...
@@ -31,7 +31,7 @@ namespace YAML
...
@@ -31,7 +31,7 @@ namespace YAML
// basic state checking
// basic state checking
bool
good
()
const
{
return
m_isGood
;
}
bool
good
()
const
{
return
m_isGood
;
}
const
std
::
string
GetLastError
()
const
{
return
m_lastError
;
}
const
std
::
string
GetLastError
()
const
{
return
m_lastError
;
}
void
SetError
(
const
std
::
string
&
error
)
{
throw
std
::
runtime_error
(
error
);
m_isGood
=
false
;
m_lastError
=
error
;
}
void
SetError
(
const
std
::
string
&
error
)
{
m_isGood
=
false
;
m_lastError
=
error
;
}
// node handling
// node handling
void
SetAnchor
();
void
SetAnchor
();
...
@@ -53,6 +53,7 @@ namespace YAML
...
@@ -53,6 +53,7 @@ namespace YAML
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
||
m_hasNonContent
;
}
bool
HasBegunNode
()
const
{
return
m_hasAnchor
||
m_hasTag
||
m_hasNonContent
;
}
bool
HasBegunContent
()
const
{
return
m_hasAnchor
||
m_hasTag
;
}
void
ClearModifiedSettings
();
void
ClearModifiedSettings
();
...
...
util/sandbox.cpp
View file @
0f3f1e26
...
@@ -4,19 +4,13 @@
...
@@ -4,19 +4,13 @@
int
main
()
int
main
()
{
{
YAML
::
Emitter
out
;
YAML
::
Emitter
out
;
out
<<
YAML
::
Anchor
(
"monkey"
)
<<
YAML
::
LocalTag
(
"a"
);
out
<<
YAML
::
BeginSeq
;
out
<<
YAML
::
BeginSeq
;
out
<<
"foo"
;
out
<<
"item 1"
;
out
<<
YAML
::
LocalTag
(
"hi"
)
<<
"bar"
;
out
<<
YAML
::
BeginMap
;
out
<<
YAML
::
Anchor
(
"asdf"
)
<<
YAML
::
BeginMap
;
out
<<
"pens"
<<
"a"
;
out
<<
"a"
<<
"b"
<<
"c"
;
out
<<
"pencils"
<<
"b"
;
out
<<
YAML
::
Anchor
(
"a"
)
<<
YAML
::
BeginMap
;
out
<<
YAML
::
Anchor
(
"d"
)
<<
"a"
<<
"b"
;
out
<<
YAML
::
EndMap
;
out
<<
YAML
::
EndMap
;
out
<<
YAML
::
EndMap
;
out
<<
"item 2"
;
out
<<
YAML
::
LocalTag
(
"hi"
)
<<
YAML
::
BeginSeq
;
out
<<
"a"
<<
"b"
<<
YAML
::
Alias
(
"monkey"
);
out
<<
YAML
::
EndSeq
;
out
<<
YAML
::
EndSeq
;
out
<<
YAML
::
EndSeq
;
std
::
cout
<<
out
.
c_str
()
<<
"
\n
"
;
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