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
04824635
Commit
04824635
authored
Apr 02, 2013
by
Jesse Beder
Browse files
Rename clear() to reset(), and it now takes an optional node parameter.
parent
5dbcf7ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
include/yaml-cpp/node/impl.h
include/yaml-cpp/node/impl.h
+3
-2
include/yaml-cpp/node/node.h
include/yaml-cpp/node/node.h
+1
-1
test/new-api/nodetests.cpp
test/new-api/nodetests.cpp
+8
-3
No files found.
include/yaml-cpp/node/impl.h
View file @
04824635
...
@@ -168,9 +168,10 @@ namespace YAML
...
@@ -168,9 +168,10 @@ namespace YAML
return
*
this
;
return
*
this
;
}
}
inline
void
Node
::
clear
(
)
inline
void
Node
::
reset
(
const
YAML
::
Node
&
rhs
)
{
{
m_pNode
=
NULL
;
m_pMemory
=
rhs
.
m_pMemory
;
m_pNode
=
rhs
.
m_pNode
;
}
}
template
<
typename
T
>
template
<
typename
T
>
...
...
include/yaml-cpp/node/node.h
View file @
04824635
...
@@ -56,7 +56,7 @@ namespace YAML
...
@@ -56,7 +56,7 @@ namespace YAML
bool
is
(
const
Node
&
rhs
)
const
;
bool
is
(
const
Node
&
rhs
)
const
;
template
<
typename
T
>
Node
&
operator
=
(
const
T
&
rhs
);
template
<
typename
T
>
Node
&
operator
=
(
const
T
&
rhs
);
Node
&
operator
=
(
const
Node
&
rhs
);
Node
&
operator
=
(
const
Node
&
rhs
);
void
clear
(
);
void
reset
(
const
Node
&
rhs
=
Node
()
);
// size/iterator
// size/iterator
std
::
size_t
size
()
const
;
std
::
size_t
size
()
const
;
...
...
test/new-api/nodetests.cpp
View file @
04824635
...
@@ -444,12 +444,17 @@ namespace Test
...
@@ -444,12 +444,17 @@ namespace Test
return
true
;
return
true
;
}
}
TEST
Clear
Node
()
TEST
Reset
Node
()
{
{
YAML
::
Node
node
=
YAML
::
Load
(
"[1, 2, 3]"
);
YAML
::
Node
node
=
YAML
::
Load
(
"[1, 2, 3]"
);
YAML_ASSERT
(
!
node
.
IsNull
());
YAML_ASSERT
(
!
node
.
IsNull
());
node
.
clear
();
YAML
::
Node
other
=
node
;
node
.
reset
();
YAML_ASSERT
(
node
.
IsNull
());
YAML_ASSERT
(
node
.
IsNull
());
YAML_ASSERT
(
!
other
.
IsNull
());
node
.
reset
(
other
);
YAML_ASSERT
(
!
node
.
IsNull
());
YAML_ASSERT
(
other
==
node
);
return
true
;
return
true
;
}
}
}
}
...
@@ -510,7 +515,7 @@ namespace Test
...
@@ -510,7 +515,7 @@ namespace Test
RunNodeTest
(
&
Node
::
CloneMap
,
"clone map"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
CloneMap
,
"clone map"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
CloneAlias
,
"clone alias"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
CloneAlias
,
"clone alias"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
ForceInsertIntoMap
,
"force insert into map"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
ForceInsertIntoMap
,
"force insert into map"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
Clear
Node
,
"
clear
node"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
Reset
Node
,
"
reset
node"
,
passed
,
total
);
std
::
cout
<<
"Node tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
std
::
cout
<<
"Node tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
return
passed
==
total
;
return
passed
==
total
;
...
...
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