"vscode:/vscode.git/clone" did not exist on "f8e1a7be3b156a83ffb04f7eb4e8e35356b68242"
Commit bcdda402 authored by Jesse Beder's avatar Jesse Beder
Browse files

Added Node::clear() function

parent eb02dd8d
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace YAML namespace YAML
{ {
inline Node::Node(): m_pNode(0) inline Node::Node(): m_pNode(NULL)
{ {
} }
...@@ -168,6 +168,11 @@ namespace YAML ...@@ -168,6 +168,11 @@ namespace YAML
return *this; return *this;
} }
inline void Node::clear()
{
m_pNode = NULL;
}
template<typename T> template<typename T>
inline void Node::Assign(const T& rhs) inline void Node::Assign(const T& rhs)
{ {
......
...@@ -56,6 +56,7 @@ namespace YAML ...@@ -56,6 +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();
// size/iterator // size/iterator
std::size_t size() const; std::size_t size() const;
......
...@@ -443,6 +443,15 @@ namespace Test ...@@ -443,6 +443,15 @@ namespace Test
YAML_ASSERT(xy); YAML_ASSERT(xy);
return true; return true;
} }
TEST ClearNode()
{
YAML::Node node = YAML::Load("[1, 2, 3]");
YAML_ASSERT(!node.IsNull());
node.clear();
YAML_ASSERT(node.IsNull());
return true;
}
} }
void RunNodeTest(TEST (*test)(), const std::string& name, int& passed, int& total) { void RunNodeTest(TEST (*test)(), const std::string& name, int& passed, int& total) {
...@@ -501,6 +510,7 @@ namespace Test ...@@ -501,6 +510,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::ClearNode, "clear 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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment