aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-03-27 08:00:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-03-27 08:00:25 +0200
commit1d3d9dfb7b11da8e398f6f9c638291a0539f7bf0 (patch)
tree66d8a5382122e8369016c6a4f0d091629e5e37b8
parent707387b10340c7b95db35c8b791e57a2d02ccbaf (diff)
Add attribute_present() function to XML parser
-rw-r--r--cutl/xml/parser.cxx21
-rw-r--r--cutl/xml/parser.hxx6
-rw-r--r--cutl/xml/parser.ixx6
3 files changed, 33 insertions, 0 deletions
diff --git a/cutl/xml/parser.cxx b/cutl/xml/parser.cxx
index f57d9fd..42ce9ce 100644
--- a/cutl/xml/parser.cxx
+++ b/cutl/xml/parser.cxx
@@ -237,6 +237,27 @@ namespace cutl
return dv;
}
+ bool parser::
+ attribute_present (const qname_type& qn) const
+ {
+ if (const element_entry* e = get_element ())
+ {
+ attribute_map::const_iterator i (e->attr_map_.find (qn));
+
+ if (i != e->attr_map_.end ())
+ {
+ if (!i->second.handled)
+ {
+ i->second.handled = true;
+ e->attr_unhandled_--;
+ }
+ return true;
+ }
+ }
+
+ return false;
+ }
+
void parser::
next_expect (event_type e)
{
diff --git a/cutl/xml/parser.hxx b/cutl/xml/parser.hxx
index 8aed55f..7806041 100644
--- a/cutl/xml/parser.hxx
+++ b/cutl/xml/parser.hxx
@@ -249,6 +249,12 @@ namespace cutl
T
attribute (const qname_type& qname, const T& dv) const;
+ bool
+ attribute_present (const std::string& name) const;
+
+ bool
+ attribute_present (const qname_type& qname) const;
+
// Optional content processing.
//
public:
diff --git a/cutl/xml/parser.ixx b/cutl/xml/parser.ixx
index fa5a7b6..2bedae4 100644
--- a/cutl/xml/parser.ixx
+++ b/cutl/xml/parser.ixx
@@ -41,6 +41,12 @@ namespace cutl
return value_traits<T>::parse (attribute (qn), *this);
}
+ inline bool parser::
+ attribute_present (const std::string& n) const
+ {
+ return attribute_present (qname_type (n));
+ }
+
inline void parser::
next_expect (event_type e, const qname_type& qn)
{