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
50120631
Commit
50120631
authored
Sep 10, 2011
by
Jesse Beder
Browse files
Fixed node iterator
parent
c3b0ba9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
12 deletions
+22
-12
include/yaml-cpp/value/detail/iterator.h
include/yaml-cpp/value/detail/iterator.h
+3
-3
include/yaml-cpp/value/detail/node_iterator.h
include/yaml-cpp/value/detail/node_iterator.h
+9
-5
src/value/valueevents.cpp
src/value/valueevents.cpp
+8
-2
src/value/valueevents.h
src/value/valueevents.h
+2
-2
No files found.
include/yaml-cpp/value/detail/iterator.h
View file @
50120631
...
@@ -47,9 +47,9 @@ namespace YAML
...
@@ -47,9 +47,9 @@ namespace YAML
value_type
dereference
()
const
{
value_type
dereference
()
const
{
const
typename
base_type
::
value_type
&
v
=
*
this
->
base
();
const
typename
base_type
::
value_type
&
v
=
*
this
->
base
();
if
(
v
.
pNode
)
if
(
v
.
pNode
)
return
value_type
(
Value
(
*
v
.
pNode
,
m_pMemory
));
return
value_type
(
Value
(
*
v
,
m_pMemory
));
if
(
v
.
pKey
&&
v
.
pValue
)
if
(
v
.
first
&&
v
.
second
)
return
value_type
(
Value
(
*
v
.
pKey
,
m_pMemory
),
Value
(
*
v
.
pValue
,
m_pMemory
));
return
value_type
(
Value
(
*
v
.
first
,
m_pMemory
),
Value
(
*
v
.
second
,
m_pMemory
));
return
value_type
();
return
value_type
();
}
}
...
...
include/yaml-cpp/value/detail/node_iterator.h
View file @
50120631
...
@@ -21,13 +21,17 @@ namespace YAML
...
@@ -21,13 +21,17 @@ namespace YAML
struct
iterator_type
{
enum
value
{
None
,
Sequence
,
Map
};
};
struct
iterator_type
{
enum
value
{
None
,
Sequence
,
Map
};
};
template
<
typename
V
>
template
<
typename
V
>
struct
node_iterator_value
{
struct
node_iterator_value
:
public
std
::
pair
<
V
*
,
V
*>
{
node_iterator_value
()
:
pNode
(
0
),
pKey
(
0
),
pValue
(
0
)
{}
typedef
std
::
pair
<
V
*
,
V
*>
kv
;
explicit
node_iterator_value
(
V
&
rhs
)
:
pNode
(
&
rhs
),
pKey
(
0
),
pValue
(
0
)
{}
explicit
node_iterator_value
(
V
&
key
,
V
&
value
)
:
pNode
(
0
),
pKey
(
&
key
),
pValue
(
&
value
)
{}
node_iterator_value
()
:
kv
(),
pNode
(
0
)
{}
explicit
node_iterator_value
(
V
&
rhs
)
:
kv
(),
pNode
(
&
rhs
)
{}
explicit
node_iterator_value
(
V
&
key
,
V
&
value
)
:
kv
(
&
key
,
&
value
),
pNode
(
0
)
{}
V
&
operator
*
()
const
{
return
*
pNode
;
}
V
&
operator
->
()
const
{
return
*
pNode
;
}
V
*
pNode
;
V
*
pNode
;
V
*
pKey
,
*
pValue
;
};
};
typedef
std
::
vector
<
node
*>
node_seq
;
typedef
std
::
vector
<
node
*>
node_seq
;
...
...
src/value/valueevents.cpp
View file @
50120631
#include "valueevents.h"
#include "valueevents.h"
#include "yaml-cpp/value.h"
namespace
YAML
namespace
YAML
{
{
...
@@ -7,7 +8,7 @@ namespace YAML
...
@@ -7,7 +8,7 @@ namespace YAML
Visit
(
m_root
);
Visit
(
m_root
);
}
}
void
V
isit
(
detail
::
node
&
node
)
void
V
alueEvents
::
Visit
(
const
detail
::
node
&
node
)
{
{
int
&
refCount
=
m_refCount
[
node
.
ref
()];
int
&
refCount
=
m_refCount
[
node
.
ref
()];
refCount
++
;
refCount
++
;
...
@@ -15,8 +16,13 @@ namespace YAML
...
@@ -15,8 +16,13 @@ namespace YAML
return
;
return
;
if
(
node
.
type
()
==
ValueType
::
Sequence
)
{
if
(
node
.
type
()
==
ValueType
::
Sequence
)
{
for
(
detail
::
const_node_iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
Visit
(
**
it
);
}
else
if
(
node
.
type
()
==
ValueType
::
Map
)
{
}
else
if
(
node
.
type
()
==
ValueType
::
Map
)
{
for
(
detail
::
const_node_iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
{
Visit
(
*
it
->
first
);
Visit
(
*
it
->
second
);
}
}
}
}
}
}
}
src/value/valueevents.h
View file @
50120631
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "yaml-cpp/anchor.h"
#include "yaml-cpp/anchor.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/ptr.h"
#include <m
ultiset
>
#include <m
ap
>
#include <vector>
#include <vector>
namespace
YAML
namespace
YAML
...
@@ -20,7 +20,7 @@ namespace YAML
...
@@ -20,7 +20,7 @@ namespace YAML
ValueEvents
(
const
Value
&
value
);
ValueEvents
(
const
Value
&
value
);
private:
private:
void
Visit
(
detail
::
node
&
node
);
void
Visit
(
const
detail
::
node
&
node
);
private:
private:
detail
::
shared_memory_holder
m_pMemory
;
detail
::
shared_memory_holder
m_pMemory
;
...
...
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