From 82fa4e71dbfca8db43b7d9ea0dac5267966c94ee Mon Sep 17 00:00:00 2001 From: beder Date: Wed, 7 Sep 2011 14:46:25 -0500 Subject: [PATCH] Implemented is() --- include/yaml-cpp/value/detail/node.h | 2 ++ include/yaml-cpp/value/impl.h | 9 +++++++-- include/yaml-cpp/value/value.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/yaml-cpp/value/detail/node.h b/include/yaml-cpp/value/detail/node.h index 3932129..fdd5ecd 100644 --- a/include/yaml-cpp/value/detail/node.h +++ b/include/yaml-cpp/value/detail/node.h @@ -21,6 +21,8 @@ namespace YAML node(): m_pRef(new node_ref) {} ValueType::value type() const { return m_pRef->type(); } + + bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; } void set_ref(const node& rhs) { m_pRef = rhs.m_pRef; } void set_data(const node& rhs) { m_pRef->set_data(*rhs.m_pRef); } diff --git a/include/yaml-cpp/value/impl.h b/include/yaml-cpp/value/impl.h index 197441d..566e333 100644 --- a/include/yaml-cpp/value/impl.h +++ b/include/yaml-cpp/value/impl.h @@ -57,6 +57,11 @@ namespace YAML } // assignment + inline bool Value::is(const Value& rhs) const + { + return m_pNode->is(*rhs.m_pNode); + } + template inline Value& Value::operator=(const T& rhs) { @@ -88,7 +93,7 @@ namespace YAML inline Value& Value::operator=(const Value& rhs) { - if(is(*this, rhs)) + if(is(rhs)) return *this; AssignNode(rhs); return *this; @@ -213,7 +218,7 @@ namespace YAML inline bool is(const Value& lhs, const Value& rhs) { - return false; + return lhs.is(rhs); } } diff --git a/include/yaml-cpp/value/value.h b/include/yaml-cpp/value/value.h index e269b34..039dfe2 100644 --- a/include/yaml-cpp/value/value.h +++ b/include/yaml-cpp/value/value.h @@ -31,6 +31,7 @@ namespace YAML template const T as() const; // assignment + bool is(const Value& rhs) const; template Value& operator=(const T& rhs); Value& operator=(const Value& rhs);