diff --git a/include/yaml-cpp/node/detail/impl.h b/include/yaml-cpp/node/detail/impl.h index c64f6d8..f997e02 100644 --- a/include/yaml-cpp/node/detail/impl.h +++ b/include/yaml-cpp/node/detail/impl.h @@ -56,6 +56,19 @@ struct get_idx >::type> { } }; +template +inline bool node::equals(const T& rhs, shared_memory_holder pMemory) { + T lhs; + if (convert::decode(Node(*this, pMemory), lhs)) { + return lhs == rhs; + } + return false; +} + +inline bool node::equals(const char* rhs, shared_memory_holder pMemory) { + return equals(rhs, pMemory); +} + // indexing template inline node* node_data::get(const Key& key, @@ -75,8 +88,9 @@ inline node* node_data::get(const Key& key, } for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (equals(*it->first, key, pMemory)) + if (it->first->equals(key, pMemory)) { return it->second; + } } return NULL; @@ -102,8 +116,9 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { } for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (equals(*it->first, key, pMemory)) + if (it->first->equals(key, pMemory)) { return *it->second; + } } node& k = convert_to_node(key, pMemory); @@ -148,20 +163,6 @@ inline void node_data::force_insert(const Key& key, const Value& value, insert_map_pair(k, v); } -template -inline bool node_data::equals(node& node, const T& rhs, - shared_memory_holder pMemory) { - T lhs; - if (convert::decode(Node(node, pMemory), lhs)) - return lhs == rhs; - return false; -} - -inline bool node_data::equals(node& node, const char* rhs, - shared_memory_holder pMemory) { - return equals(node, rhs, pMemory); -} - template inline node& node_data::convert_to_node(const T& rhs, shared_memory_holder pMemory) { diff --git a/include/yaml-cpp/node/detail/node.h b/include/yaml-cpp/node/detail/node.h index 59338f7..830958f 100644 --- a/include/yaml-cpp/node/detail/node.h +++ b/include/yaml-cpp/node/detail/node.h @@ -31,6 +31,10 @@ class node : private boost::noncopyable { const std::string& tag() const { return m_pRef->tag(); } EmitterStyle::value style() const { return m_pRef->style(); } + template + bool equals(const T& rhs, shared_memory_holder pMemory); + bool equals(const char* rhs, shared_memory_holder pMemory); + void mark_defined() { if (is_defined()) return; diff --git a/include/yaml-cpp/node/detail/node_data.h b/include/yaml-cpp/node/detail/node_data.h index 6023aab..10108cb 100644 --- a/include/yaml-cpp/node/detail/node_data.h +++ b/include/yaml-cpp/node/detail/node_data.h @@ -92,10 +92,6 @@ class YAML_CPP_API node_data : private boost::noncopyable { void convert_to_map(shared_memory_holder pMemory); void convert_sequence_to_map(shared_memory_holder pMemory); - template - static bool equals(node& node, const T& rhs, shared_memory_holder pMemory); - static bool equals(node& node, const char* rhs, shared_memory_holder pMemory); - template static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); diff --git a/include/yaml-cpp/node/node.h b/include/yaml-cpp/node/node.h index 15de6f0..b32b456 100644 --- a/include/yaml-cpp/node/node.h +++ b/include/yaml-cpp/node/node.h @@ -30,6 +30,7 @@ class YAML_CPP_API Node { friend class NodeBuilder; friend class NodeEvents; friend struct detail::iterator_value; + friend class detail::node; friend class detail::node_data; template friend class detail::iterator_base;