From 498947c71897bfad865d37252df6689c1a78e1d8 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Mon, 18 Oct 2010 16:59:31 +0000 Subject: Fixed internal_object() const-correctness, added xml_node::hash_value and xml_attribute::hash_value functions git-svn-id: http://pugixml.googlecode.com/svn/trunk@767 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 14 ++++++++++++-- src/pugixml.hpp | 10 ++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index febf2eb..1142930 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3420,7 +3420,12 @@ namespace pugi return (_attr && _attr->value) ? _attr->value : PUGIXML_TEXT(""); } - xml_attribute_struct* xml_attribute::internal_object() + size_t xml_attribute::hash_value() const + { + return static_cast(reinterpret_cast(_attr) / sizeof(xml_attribute_struct)); + } + + xml_attribute_struct* xml_attribute::internal_object() const { return _attr; } @@ -4134,7 +4139,12 @@ namespace pugi return walker.end(arg_end); } - xml_node_struct* xml_node::internal_object() + size_t xml_node::hash_value() const + { + return static_cast(reinterpret_cast(_root) / sizeof(xml_node_struct)); + } + + xml_node_struct* xml_node::internal_object() const { return _root; } diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 8fba12a..9b0d0d6 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -321,8 +321,11 @@ namespace pugi xml_attribute next_attribute() const; xml_attribute previous_attribute() const; + // Get hash value (unique for handles to the same object) + size_t hash_value() const; + // Get internal pointer - xml_attribute_struct* internal_object(); + xml_attribute_struct* internal_object() const; }; #ifdef __BORLANDC__ @@ -532,8 +535,11 @@ namespace pugi // Get node offset in parsed file/string (in char_t units) for debugging purposes ptrdiff_t offset_debug() const; + // Get hash value (unique for handles to the same object) + size_t hash_value() const; + // Get internal pointer - xml_node_struct* internal_object(); + xml_node_struct* internal_object() const; }; #ifdef __BORLANDC__ -- cgit v1.2.3