mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Added Node::clear() function
This commit is contained in:
@@ -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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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;
|
||||||
|
Reference in New Issue
Block a user