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
901d16a9
Commit
901d16a9
authored
Jul 02, 2008
by
Jesse Beder
Browse files
Overloaded the iterator's -> operator.
parent
d56b54b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
17 deletions
+18
-17
iterator.cpp
iterator.cpp
+8
-0
main.cpp
main.cpp
+7
-11
node.h
node.h
+1
-0
test.yaml
test.yaml
+2
-6
No files found.
iterator.cpp
View file @
901d16a9
...
...
@@ -37,6 +37,14 @@ namespace YAML
throw
BadDereference
();
}
const
Node
*
Node
::
Iterator
::
operator
->
()
{
if
(
type
==
IT_SEQ
)
return
&**
seqIter
;
throw
BadDereference
();
}
const
Node
&
Node
::
Iterator
::
first
()
{
if
(
type
==
IT_MAP
)
...
...
main.cpp
View file @
901d16a9
...
...
@@ -18,17 +18,13 @@ int main()
const
YAML
::
Node
&
root
=
doc
.
GetRoot
();
for
(
YAML
::
Node
::
Iterator
it
=
root
.
begin
();
it
!=
root
.
end
();
++
it
)
{
std
::
string
name
;
(
*
it
)[
"name"
]
>>
name
;
std
::
cout
<<
"Name: "
<<
name
<<
std
::
endl
;
int
age
;
(
*
it
)[
"age"
]
>>
age
;
std
::
cout
<<
"Age: "
<<
age
<<
std
::
endl
;
std
::
string
school
;
(
*
it
)[
"school"
]
>>
school
;
std
::
cout
<<
"School: "
<<
school
<<
std
::
endl
;
std
::
cout
<<
"Sequence:"
;
for
(
YAML
::
Node
::
Iterator
jt
=
it
->
begin
();
jt
!=
it
->
end
();
++
jt
)
{
int
value
;
*
jt
>>
value
;
std
::
cout
<<
" "
<<
value
;
}
std
::
cout
<<
std
::
endl
;
}
}
catch
(
YAML
::
Exception
&
e
)
{
std
::
cout
<<
"Error parsing the yaml!
\n
"
;
...
...
node.h
View file @
901d16a9
...
...
@@ -27,6 +27,7 @@ namespace YAML
friend
bool
operator
!=
(
const
Iterator
&
it
,
const
Iterator
&
jt
);
Iterator
&
operator
++
();
const
Node
&
operator
*
();
const
Node
*
operator
->
();
const
Node
&
first
();
const
Node
&
second
();
...
...
test.yaml
View file @
901d16a9
---
-
name
:
Jesse
age
:
23
school
:
University of Illinois
-
name
:
Naftali
age
:
21
school
:
Rhode Island School of Design
-
[
1
,
2
,
3
]
-
[
2
,
4
,
6
]
...
\ No newline at end of file
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