From e34acc39f93526e6ff9ade7539600539be6f5055 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 12 Aug 2015 00:02:47 +0200 Subject: Add support for querying current element, attribute --- xml/serializer.cxx | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'xml/serializer.cxx') diff --git a/xml/serializer.cxx b/xml/serializer.cxx index df31b09..700243f 100644 --- a/xml/serializer.cxx +++ b/xml/serializer.cxx @@ -122,7 +122,7 @@ namespace xml } void serializer:: - handle_error (genxStatus e) + handle_error (genxStatus e) const { switch (e) { @@ -287,7 +287,7 @@ namespace xml } bool serializer:: - lookup_namespace_prefix (const string& ns, string& p) + lookup_namespace_prefix (const string& ns, string& p) const { // Currently Genx will create a namespace mapping if one doesn't // already exist. @@ -304,6 +304,28 @@ namespace xml return true; } + qname serializer:: + current_element () const + { + constUtf8 ns, n; + if (genxStatus e = genxGetCurrentElement (s_, &ns, &n)) + handle_error (e); + + return qname (ns != 0 ? reinterpret_cast (ns) : "", + reinterpret_cast (n)); + } + + qname serializer:: + current_attribute () const + { + constUtf8 ns, n; + if (genxStatus e = genxGetCurrentAttribute (s_, &ns, &n)) + handle_error (e); + + return qname (ns != 0 ? reinterpret_cast (ns) : "", + reinterpret_cast (n)); + } + void serializer:: suspend_indentation () { -- cgit v1.1