Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
yaml-cpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hwcore
external
yaml-cpp
Commits
32689981
Commit
32689981
authored
15 years ago
by
Jesse Beder
Browse files
Options
Downloads
Patches
Plain Diff
Added overloads for parsing stl maps and vectors
parent
083a97b1
No related branches found
Branches containing commit
Tags
release-0.2.5
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/stlnode.h
+36
-0
36 additions, 0 deletions
include/stlnode.h
include/yaml.h
+1
-0
1 addition, 0 deletions
include/yaml.h
test/spectests.cpp
+3
-3
3 additions, 3 deletions
test/spectests.cpp
with
40 additions
and
3 deletions
include/stlnode.h
0 → 100644
+
36
−
0
View file @
32689981
#pragma once
#ifndef STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#include
<vector>
#include
<map>
namespace
YAML
{
template
<
typename
T
>
void
operator
>>
(
const
Node
&
node
,
std
::
vector
<
T
>&
v
)
{
v
.
clear
();
v
.
resize
(
node
.
size
());
for
(
unsigned
i
=
0
;
i
<
node
.
size
();
++
i
)
node
[
i
]
>>
v
[
i
];
}
template
<
typename
K
,
typename
V
>
void
operator
>>
(
const
Node
&
node
,
std
::
map
<
K
,
V
>&
m
)
{
m
.
clear
();
for
(
Iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
{
K
k
;
V
v
;
it
.
first
()
>>
k
;
it
.
second
()
>>
v
;
m
[
k
]
=
v
;
}
}
}
#endif // STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
This diff is collapsed.
Click to expand it.
include/yaml.h
+
1
−
0
View file @
32689981
...
...
@@ -6,6 +6,7 @@
#include
"parser.h"
#include
"node.h"
#include
"stlnode.h"
#include
"iterator.h"
#include
"emitter.h"
#include
"stlemitter.h"
...
...
This diff is collapsed.
Click to expand it.
test/spectests.cpp
+
3
−
3
View file @
32689981
...
...
@@ -1121,9 +1121,9 @@ namespace Test {
" 0.278"
;
PARSE
(
doc
,
input
);
S
tring
Map
key
;
key
.
_
[
"first"
]
=
"Sammy"
;
key
.
_
[
"last"
]
=
"Sosa"
;
std
::
map
<
std
::
string
,
std
::
s
tring
>
key
;
key
[
"first"
]
=
"Sammy"
;
key
[
"last"
]
=
"Sosa"
;
YAML_ASSERT
(
doc
.
size
()
==
1
);
YAML_ASSERT
(
doc
[
key
].
size
()
==
2
);
YAML_ASSERT
(
doc
[
key
][
"hr"
]
==
65
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment