1
2
3
4
5
6 #ifndef SNGXML_XML_XML_CONTENT_HANDLER
7 #define SNGXML_XML_XML_CONTENT_HANDLER
8 #include <sngxml/xml/XmlApi.hpp>
9 #include <string>
10 #include <vector>
11
12 namespace sngxml { namespace xml {
13
14 class Attribute
15 {
16 public:
17 Attribute(const std::u32string& namespaceUri_, const std::u32string& localName_, const std::u32string& qualifiedName_, const std::u32string& value_);
18 const std::u32string& NamespaceUri() const { return namespaceUri; }
19 const std::u32string& LocalName() const { return localName; }
20 const std::u32string& QualifiedName() const { return qualifiedName; }
21 const std::u32string& Value() const { return value; }
22 private:
23 std::u32string namespaceUri;
24 std::u32string localName;
25 std::u32string qualifiedName;
26 std::u32string value;
27 };
28
29 class Attributes
30 {
31 public:
32 typedef std::vector<Attribute>::const_iterator const_iterator;
33 typedef std::vector<Attribute>::iterator iterator;
34 iterator begin() { return attributes.begin(); }
35 iterator end() { return attributes.end(); }
36 const_iterator begin() const { return attributes.cbegin(); }
37 const_iterator end() const { return attributes.cend(); }
38 const_iterator cbegin() const { return attributes.cbegin(); }
39 const_iterator cend() const { return attributes.cend(); }
40 void Add(const Attribute& attribute);
41 void Clear();
42 size_t Count() const { return attributes.size(); }
43 const std::u32string* GetAttributeValue(const std::u32string& namespaceUri, const std::u32string& localName) const;
44 const std::u32string* GetAttributeValue(const std::u32string& qualifiedName) const;
45 private:
46 std::vector<Attribute> attributes;
47 };
48
49 class XmlContentHandler
50 {
51 public:
52 virtual ~XmlContentHandler();
53 virtual void StartDocument() {}
54 virtual void EndDocument() {}
55 virtual void Version(const std::u32string& xmlVersion) {}
56 virtual void Standalone(bool standalone) {}
57 virtual void Encoding(const std::u32string& encoding) {}
58 virtual void Text(const std::u32string& text) {}
59 virtual void Comment(const std::u32string& comment) {}
60 virtual void PI(const std::u32string& target, const std::u32string& data) {}
61 virtual void CDataSection(const std::u32string& cdata) {}
62 virtual void StartElement(const std::u32string& namespaceUri, const std::u32string& localName, const std::u32string& qualifiedName, const Attributes& attributes) {}
63 virtual void EndElement(const std::u32string& namespaceUri, const std::u32string& localName, const std::u32string& qualifiedName) {}
64 virtual void SkippedEntity(const std::u32string& entityName) {}
65 };
66
67 } }
68
69 #endif // SNGXML_XML_XML_CONTENT_HANDLER
70