diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-18 11:44:57 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-18 11:44:57 +0000 |
commit | f57ab5289453e8323dc0aca03ee94fb5ee6ac696 (patch) | |
tree | b44be2108c1a1e6693b7714c658ce98884afdd45 /src/pugixml.cpp | |
parent | 9bc19368f2fe81fec271c57ac1583c6a9eb1d014 (diff) |
Added offset_debug
git-svn-id: http://pugixml.googlecode.com/svn/trunk@108 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r-- | src/pugixml.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 06bd0ba..4ea08a9 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -203,11 +203,12 @@ namespace pugi struct xml_document_struct: public xml_node_struct
{
- xml_document_struct(): xml_node_struct(node_document), allocator(0)
+ xml_document_struct(): xml_node_struct(node_document), allocator(0), buffer(0)
{
}
xml_allocator allocator;
+ const char* buffer;
};
xml_document_struct* xml_allocator::allocate_document()
@@ -2620,6 +2621,36 @@ namespace pugi node_output(buffered_writer, *this, indent, flags, depth);
}
+ int xml_node::offset_debug() const
+ {
+ xml_node_struct* r = root()._root;
+
+ if (!r) return -1;
+
+ const char* buffer = static_cast<xml_document_struct*>(r)->buffer;
+
+ if (!buffer) return -1;
+
+ switch (type())
+ {
+ case node_document:
+ return 0;
+
+ case node_element:
+ case node_declaration:
+ return _root->name_insitu ? _root->name - buffer : -1;
+
+ case node_pcdata:
+ case node_cdata:
+ case node_comment:
+ case node_pi:
+ return _root->value_insitu ? _root->value - buffer : -1;
+
+ default:
+ return -1;
+ }
+ }
+
#ifdef __BORLANDC__
bool operator&&(const xml_node& lhs, bool rhs)
{
@@ -2891,6 +2922,9 @@ namespace pugi {
destroy();
+ // for offset_debug
+ static_cast<xml_document_struct*>(_root)->buffer = xmlstr;
+
xml_allocator& alloc = static_cast<xml_document_struct*>(_root)->allocator;
xml_parser parser(alloc);
|