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
7c4a8dad
Commit
7c4a8dad
authored
Oct 29, 2009
by
jbeder
Browse files
Added case for parsing a compact key: value pair in a flow sequence with a null key
parent
011a608b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
src/map.cpp
src/map.cpp
+15
-0
src/map.h
src/map.h
+1
-0
src/node.cpp
src/node.cpp
+7
-0
No files found.
src/map.cpp
View file @
7c4a8dad
...
@@ -66,6 +66,7 @@ namespace YAML
...
@@ -66,6 +66,7 @@ namespace YAML
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
::
FLOW_MAP_COMPACT
:
ParseCompact
(
pScanner
,
state
);
break
;
case
Token
::
VALUE
:
ParseCompactWithNoKey
(
pScanner
,
state
);
break
;
default:
break
;
default:
break
;
}
}
}
}
...
@@ -178,6 +179,20 @@ namespace YAML
...
@@ -178,6 +179,20 @@ namespace YAML
m_data
[
pKey
.
release
()]
=
pValue
.
release
();
m_data
[
pKey
.
release
()]
=
pValue
.
release
();
}
}
// ParseCompactWithNoKey
// . Single key: value pair in a flow sequence
void
Map
::
ParseCompactWithNoKey
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
{
std
::
auto_ptr
<
Node
>
pKey
(
new
Node
),
pValue
(
new
Node
);
// grab value
pScanner
->
pop
();
pValue
->
Parse
(
pScanner
,
state
);
// assign the map with the actual pointers
m_data
[
pKey
.
release
()]
=
pValue
.
release
();
}
void
Map
::
Write
(
Emitter
&
out
)
const
void
Map
::
Write
(
Emitter
&
out
)
const
{
{
out
<<
BeginMap
;
out
<<
BeginMap
;
...
...
src/map.h
View file @
7c4a8dad
...
@@ -42,6 +42,7 @@ namespace YAML
...
@@ -42,6 +42,7 @@ namespace YAML
void
ParseBlock
(
Scanner
*
pScanner
,
const
ParserState
&
state
);
void
ParseBlock
(
Scanner
*
pScanner
,
const
ParserState
&
state
);
void
ParseFlow
(
Scanner
*
pScanner
,
const
ParserState
&
state
);
void
ParseFlow
(
Scanner
*
pScanner
,
const
ParserState
&
state
);
void
ParseCompact
(
Scanner
*
pScanner
,
const
ParserState
&
state
);
void
ParseCompact
(
Scanner
*
pScanner
,
const
ParserState
&
state
);
void
ParseCompactWithNoKey
(
Scanner
*
pScanner
,
const
ParserState
&
state
);
private:
private:
node_map
m_data
;
node_map
m_data
;
...
...
src/node.cpp
View file @
7c4a8dad
...
@@ -64,6 +64,13 @@ namespace YAML
...
@@ -64,6 +64,13 @@ namespace YAML
// save location
// save location
m_mark
=
pScanner
->
peek
().
mark
;
m_mark
=
pScanner
->
peek
().
mark
;
// special case: a value node by itself must be a map, with no header
if
(
pScanner
->
peek
().
type
==
Token
::
VALUE
)
{
m_pContent
=
new
Map
;
m_pContent
->
Parse
(
pScanner
,
state
);
return
;
}
ParseHeader
(
pScanner
,
state
);
ParseHeader
(
pScanner
,
state
);
...
...
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