aboutsummaryrefslogtreecommitdiff
path: root/examples/cxx/hybrid/evolution/passthrough/xml.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-18 11:17:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-18 11:17:51 +0200
commitd80d096ee8743fd6f7382d274272b0b6d7faf9bf (patch)
treed0f0bee1e645cb2b86b6837ac0db8a7d2821e533 /examples/cxx/hybrid/evolution/passthrough/xml.hxx
parent0e4637025fa8d1b4234b0512561d31f0dd023843 (diff)
Support for schema evolution using substitution groups
New examples: hybrid/evolution/ignore and hybrid/evolution/passthrough.
Diffstat (limited to 'examples/cxx/hybrid/evolution/passthrough/xml.hxx')
-rw-r--r--examples/cxx/hybrid/evolution/passthrough/xml.hxx111
1 files changed, 111 insertions, 0 deletions
diff --git a/examples/cxx/hybrid/evolution/passthrough/xml.hxx b/examples/cxx/hybrid/evolution/passthrough/xml.hxx
new file mode 100644
index 0000000..fbcae6e
--- /dev/null
+++ b/examples/cxx/hybrid/evolution/passthrough/xml.hxx
@@ -0,0 +1,111 @@
+// file : examples/cxx/hybrid/evolution/passthrough/xml.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+//
+// In-memory representation for raw XML. The primary goal here is to provide
+// a simple, if not very efficient, implementation. As a result, it probably
+// shouldn't be used in production, especially if performance is important.
+// It also does not support mixed content (interleaved elements and text).
+//
+
+#ifndef XML_HXX
+#define XML_HXX
+
+#include <map>
+#include <vector>
+#include <string>
+
+namespace xml
+{
+ // Qualified name.
+ //
+ class qname
+ {
+ public:
+ qname (const char* name);
+ qname (const std::string& name);
+ qname (const std::string& ns, const std::string& name);
+
+ const std::string&
+ ns () const;
+
+ const std::string&
+ name () const;
+
+ private:
+ std::string ns_;
+ std::string name_;
+ };
+
+ bool
+ operator== (const qname&, const qname&);
+
+ bool
+ operator!= (const qname&, const qname&);
+
+ bool
+ operator< (const qname&, const qname&);
+
+ // Attribute.
+ //
+ typedef std::map<qname, std::string> attributes;
+
+ // Element.
+ //
+ class element;
+ typedef std::vector<element*> elements;
+
+ class element
+ {
+ public:
+ ~element ();
+ element (const qname& name, element* parent);
+ element (const qname& name, const std::string value, element* parent);
+
+ private:
+ element (const element&);
+ element& operator= (const element&);
+
+ public:
+ const qname&
+ name () const;
+
+ const element*
+ parent () const;
+
+ element*
+ parent ();
+
+ typedef xml::attributes attributes_type;
+
+ const attributes_type&
+ attributes () const;
+
+ attributes_type&
+ attributes ();
+
+ const std::string&
+ value () const;
+
+ void
+ value (const std::string&);
+
+ const elements&
+ children () const;
+
+ elements&
+ children ();
+
+ private:
+ qname name_;
+ element* parent_;
+ attributes_type attributes_;
+ std::string value_;
+ elements children_;
+ };
+}
+
+#include "xml.ixx"
+
+#endif // XML_HXX