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
3405a6fe
Commit
3405a6fe
authored
Oct 29, 2009
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the compact map notation, which made it easy to implement explicit keys for compact maps
parent
d372729b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
20 deletions
+8
-20
src/map.cpp
+6
-15
src/node.cpp
+1
-1
src/simplekey.cpp
+0
-3
test/spectests.cpp
+1
-1
No files found.
src/map.cpp
View file @
3405a6fe
...
@@ -65,7 +65,7 @@ namespace YAML
...
@@ -65,7 +65,7 @@ namespace YAML
switch
(
pScanner
->
peek
().
type
)
{
switch
(
pScanner
->
peek
().
type
)
{
case
Token
:
:
BLOCK_MAP_START
:
ParseBlock
(
pScanner
,
state
);
break
;
case
Token
:
:
BLOCK_MAP_START
:
ParseBlock
(
pScanner
,
state
);
break
;
case
Token
:
:
FLOW_MAP_START
:
ParseFlow
(
pScanner
,
state
);
break
;
case
Token
:
:
FLOW_MAP_START
:
ParseFlow
(
pScanner
,
state
);
break
;
case
Token
:
:
FLOW_MAP_COMPACT
:
ParseCompact
(
pScanner
,
state
);
break
;
case
Token
:
:
KEY
:
ParseCompact
(
pScanner
,
state
);
break
;
case
Token
:
:
VALUE
:
ParseCompactWithNoKey
(
pScanner
,
state
);
break
;
case
Token
:
:
VALUE
:
ParseCompactWithNoKey
(
pScanner
,
state
);
break
;
default
:
break
;
default
:
break
;
}
}
...
@@ -151,23 +151,14 @@ namespace YAML
...
@@ -151,23 +151,14 @@ namespace YAML
}
}
// ParseCompact
// ParseCompact
// . Single
key: value
pair in a flow sequence
// . Single
"key: value"
pair in a flow sequence
void
Map
::
ParseCompact
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
void
Map
::
ParseCompact
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
{
{
// eat start token
pScanner
->
pop
();
if
(
pScanner
->
empty
())
throw
ParserException
(
Mark
::
null
(),
ErrorMsg
::
END_OF_MAP_FLOW
);
Token
&
token
=
pScanner
->
peek
();
std
::
auto_ptr
<
Node
>
pKey
(
new
Node
),
pValue
(
new
Node
);
std
::
auto_ptr
<
Node
>
pKey
(
new
Node
),
pValue
(
new
Node
);
// grab key (if non-null)
// grab key
if
(
token
.
type
==
Token
::
KEY
)
{
pScanner
->
pop
();
pScanner
->
pop
();
pKey
->
Parse
(
pScanner
,
state
);
pKey
->
Parse
(
pScanner
,
state
);
}
// now grab value (optional)
// now grab value (optional)
if
(
!
pScanner
->
empty
()
&&
pScanner
->
peek
().
type
==
Token
::
VALUE
)
{
if
(
!
pScanner
->
empty
()
&&
pScanner
->
peek
().
type
==
Token
::
VALUE
)
{
...
@@ -180,7 +171,7 @@ namespace YAML
...
@@ -180,7 +171,7 @@ namespace YAML
}
}
// ParseCompactWithNoKey
// ParseCompactWithNoKey
// . Single
key: value
pair in a flow sequence
// . Single
": value"
pair in a flow sequence
void
Map
::
ParseCompactWithNoKey
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
void
Map
::
ParseCompactWithNoKey
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
{
{
std
::
auto_ptr
<
Node
>
pKey
(
new
Node
),
pValue
(
new
Node
);
std
::
auto_ptr
<
Node
>
pKey
(
new
Node
),
pValue
(
new
Node
);
...
...
src/node.cpp
View file @
3405a6fe
...
@@ -104,7 +104,7 @@ namespace YAML
...
@@ -104,7 +104,7 @@ namespace YAML
break
;
break
;
case
Token
:
:
FLOW_MAP_START
:
case
Token
:
:
FLOW_MAP_START
:
case
Token
:
:
BLOCK_MAP_START
:
case
Token
:
:
BLOCK_MAP_START
:
case
Token
:
:
FLOW_MAP_COMPACT
:
case
Token
:
:
KEY
:
m_pContent
=
new
Map
;
m_pContent
=
new
Map
;
break
;
break
;
default
:
default
:
...
...
src/simplekey.cpp
View file @
3405a6fe
...
@@ -72,9 +72,6 @@ namespace YAML
...
@@ -72,9 +72,6 @@ namespace YAML
key
.
pMapStart
=
key
.
pIndent
->
pStartToken
;
key
.
pMapStart
=
key
.
pIndent
->
pStartToken
;
key
.
pMapStart
->
status
=
Token
::
UNVERIFIED
;
key
.
pMapStart
->
status
=
Token
::
UNVERIFIED
;
}
}
}
else
if
(
m_flows
.
top
()
==
FLOW_SEQ
)
{
key
.
pMapStart
=
PushToken
(
Token
::
FLOW_MAP_COMPACT
);
key
.
pMapStart
->
status
=
Token
::
UNVERIFIED
;
}
}
// then add the (now unverified) key
// then add the (now unverified) key
...
...
test/spectests.cpp
View file @
3405a6fe
...
@@ -1781,7 +1781,7 @@ namespace Test {
...
@@ -1781,7 +1781,7 @@ namespace Test {
PARSE
(
doc
,
input
);
PARSE
(
doc
,
input
);
YAML_ASSERT
(
doc
.
size
()
==
1
);
YAML_ASSERT
(
doc
.
size
()
==
1
);
YAML_ASSERT
(
doc
[
0
].
size
()
==
1
);
YAML_ASSERT
(
doc
[
0
].
size
()
==
1
);
YAML_ASSERT
(
doc
[
0
][
"foo
"
]
==
"bar
"
);
YAML_ASSERT
(
doc
[
0
][
"foo
bar"
]
==
"baz
"
);
return
true
;
return
true
;
}
}
...
...
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