Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
b8a87c43
Commit
b8a87c43
authored
May 22, 2012
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added flow seq
parent
2670ce8a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
4 deletions
+48
-4
src/emitter.cpp
+36
-0
src/emitterstate.cpp
+8
-0
src/emitterstate.h
+1
-0
util/sandbox.cpp
+3
-4
No files found.
src/emitter.cpp
View file @
b8a87c43
...
@@ -221,6 +221,15 @@ namespace YAML
...
@@ -221,6 +221,15 @@ namespace YAML
if
(
!
good
())
if
(
!
good
())
return
;
return
;
if
(
m_pState
->
CurGroupFlowType
()
==
FlowType
::
Flow
)
{
if
(
m_stream
.
comment
())
m_stream
<<
"
\n
"
;
m_stream
<<
IndentTo
(
m_pState
->
CurIndent
());
if
(
m_pState
->
CurGroupChildCount
()
==
0
)
m_stream
<<
"["
;
m_stream
<<
"]"
;
}
m_pState
->
EndedGroup
(
GroupType
::
Seq
);
m_pState
->
EndedGroup
(
GroupType
::
Seq
);
}
}
...
@@ -315,6 +324,33 @@ namespace YAML
...
@@ -315,6 +324,33 @@ namespace YAML
void
Emitter
::
FlowSeqPrepareNode
(
EmitterNodeType
::
value
child
)
void
Emitter
::
FlowSeqPrepareNode
(
EmitterNodeType
::
value
child
)
{
{
const
unsigned
curIndent
=
m_pState
->
CurIndent
();
const
unsigned
lastIndent
=
m_pState
->
LastIndent
();
if
(
!
m_pState
->
HasBegunNode
())
{
if
(
m_stream
.
comment
())
m_stream
<<
"
\n
"
;
m_stream
<<
IndentTo
(
lastIndent
);
if
(
m_pState
->
CurGroupChildCount
()
==
0
)
m_stream
<<
"["
;
else
m_stream
<<
","
;
}
switch
(
child
)
{
case
EmitterNodeType
:
:
None
:
break
;
case
EmitterNodeType
:
:
Property
:
case
EmitterNodeType
:
:
Scalar
:
case
EmitterNodeType
:
:
FlowSeq
:
case
EmitterNodeType
:
:
FlowMap
:
SpaceOrIndentTo
(
m_pState
->
HasBegunContent
()
||
m_pState
->
CurGroupChildCount
()
>
0
,
curIndent
);
break
;
case
EmitterNodeType
:
:
BlockSeq
:
case
EmitterNodeType
:
:
BlockMap
:
assert
(
false
);
break
;
}
}
}
void
Emitter
::
BlockSeqPrepareNode
(
EmitterNodeType
::
value
child
)
void
Emitter
::
BlockSeqPrepareNode
(
EmitterNodeType
::
value
child
)
...
...
src/emitterstate.cpp
View file @
b8a87c43
...
@@ -188,6 +188,14 @@ namespace YAML
...
@@ -188,6 +188,14 @@ namespace YAML
return
m_groups
.
empty
()
?
false
:
m_groups
.
top
().
longKey
;
return
m_groups
.
empty
()
?
false
:
m_groups
.
top
().
longKey
;
}
}
int
EmitterState
::
LastIndent
()
const
{
if
(
m_groups
.
size
()
<=
1
)
return
0
;
return
m_curIndent
-
m_groups
.
top
(
-
1
).
indent
;
}
void
EmitterState
::
ClearModifiedSettings
()
void
EmitterState
::
ClearModifiedSettings
()
{
{
m_modifiedSettings
.
clear
();
m_modifiedSettings
.
clear
();
...
...
src/emitterstate.h
View file @
b8a87c43
...
@@ -51,6 +51,7 @@ namespace YAML
...
@@ -51,6 +51,7 @@ namespace YAML
std
::
size_t
CurGroupChildCount
()
const
;
std
::
size_t
CurGroupChildCount
()
const
;
bool
CurGroupLongKey
()
const
;
bool
CurGroupLongKey
()
const
;
int
LastIndent
()
const
;
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
;
}
...
...
util/sandbox.cpp
View file @
b8a87c43
...
@@ -4,11 +4,10 @@
...
@@ -4,11 +4,10 @@
int
main
()
int
main
()
{
{
YAML
::
Emitter
out
;
YAML
::
Emitter
out
;
out
<<
YAML
::
BeginMap
;
out
<<
YAML
::
Flow
;
out
<<
YAML
::
LongKey
<<
"a"
<<
"b"
;
out
<<
YAML
::
BeginSeq
;
out
<<
"a"
<<
"b"
;
out
<<
"a"
<<
"b"
;
out
<<
YAML
::
EndMap
;
out
<<
YAML
::
EndSeq
;
out
<<
YAML
::
EndMap
;
std
::
cout
<<
out
.
c_str
()
<<
"
\n
"
;
std
::
cout
<<
out
.
c_str
()
<<
"
\n
"
;
return
0
;
return
0
;
...
...
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