1 | // file : xsd/cxx/xml/dom/parsing-source.hxx |
---|
2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
---|
3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
---|
4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
---|
5 | |
---|
6 | #ifndef XSD_CXX_XML_DOM_PARSING_SOURCE_HXX |
---|
7 | #define XSD_CXX_XML_DOM_PARSING_SOURCE_HXX |
---|
8 | |
---|
9 | #include <string> |
---|
10 | |
---|
11 | #include <xercesc/dom/DOMNode.hpp> |
---|
12 | #include <xercesc/dom/DOMAttr.hpp> |
---|
13 | #include <xercesc/dom/DOMElement.hpp> |
---|
14 | #include <xercesc/dom/DOMDocument.hpp> |
---|
15 | #include <xercesc/dom/DOMNamedNodeMap.hpp> |
---|
16 | #include <xercesc/dom/DOMErrorHandler.hpp> |
---|
17 | |
---|
18 | #include <xercesc/sax/InputSource.hpp> |
---|
19 | |
---|
20 | #include <xsd/cxx/xml/elements.hxx> // properies |
---|
21 | #include <xsd/cxx/xml/error-handler.hxx> |
---|
22 | |
---|
23 | #include <xsd/cxx/xml/dom/auto-ptr.hxx> |
---|
24 | #include <xsd/cxx/xml/dom/elements.hxx> // name |
---|
25 | #include <xsd/cxx/xml/dom/parsing-header.hxx> |
---|
26 | |
---|
27 | namespace xsd |
---|
28 | { |
---|
29 | namespace cxx |
---|
30 | { |
---|
31 | namespace xml |
---|
32 | { |
---|
33 | namespace dom |
---|
34 | { |
---|
35 | template <typename C> |
---|
36 | class parser |
---|
37 | { |
---|
38 | public: |
---|
39 | parser (const xercesc::DOMElement& e); |
---|
40 | |
---|
41 | bool |
---|
42 | more_elements () const |
---|
43 | { |
---|
44 | return next_element_ != 0; |
---|
45 | } |
---|
46 | |
---|
47 | const xercesc::DOMElement& |
---|
48 | cur_element () |
---|
49 | { |
---|
50 | return *static_cast<const xercesc::DOMElement*> (next_element_); |
---|
51 | } |
---|
52 | |
---|
53 | void |
---|
54 | next_element (); |
---|
55 | |
---|
56 | bool |
---|
57 | more_attributes () const |
---|
58 | { |
---|
59 | return a_->getLength () > ai_; |
---|
60 | } |
---|
61 | |
---|
62 | const xercesc::DOMAttr& |
---|
63 | next_attribute () |
---|
64 | { |
---|
65 | return *static_cast<const xercesc::DOMAttr*> (a_->item (ai_++)); |
---|
66 | } |
---|
67 | |
---|
68 | void |
---|
69 | reset_attributes () |
---|
70 | { |
---|
71 | ai_ = 0; |
---|
72 | } |
---|
73 | |
---|
74 | const xercesc::DOMElement& |
---|
75 | element () const |
---|
76 | { |
---|
77 | return element_; |
---|
78 | } |
---|
79 | |
---|
80 | private: |
---|
81 | parser (const parser&); |
---|
82 | |
---|
83 | parser& |
---|
84 | operator= (const parser&); |
---|
85 | |
---|
86 | private: |
---|
87 | const xercesc::DOMElement& element_; |
---|
88 | const xercesc::DOMNode* next_element_; |
---|
89 | |
---|
90 | const xercesc::DOMNamedNodeMap* a_; |
---|
91 | unsigned long ai_; // Index of the next DOMAttr. |
---|
92 | }; |
---|
93 | |
---|
94 | |
---|
95 | // Parsing flags. |
---|
96 | // |
---|
97 | const unsigned long dont_validate = 0x00000400UL; |
---|
98 | |
---|
99 | template <typename C> |
---|
100 | xml::dom::auto_ptr<xercesc::DOMDocument> |
---|
101 | parse (xercesc::InputSource&, |
---|
102 | error_handler<C>&, |
---|
103 | const properties<C>&, |
---|
104 | unsigned long flags); |
---|
105 | |
---|
106 | template <typename C> |
---|
107 | xml::dom::auto_ptr<xercesc::DOMDocument> |
---|
108 | parse (xercesc::InputSource&, |
---|
109 | xercesc::DOMErrorHandler&, |
---|
110 | const properties<C>&, |
---|
111 | unsigned long flags); |
---|
112 | |
---|
113 | template <typename C> |
---|
114 | xml::dom::auto_ptr<xercesc::DOMDocument> |
---|
115 | parse (const std::basic_string<C>& uri, |
---|
116 | error_handler<C>&, |
---|
117 | const properties<C>&, |
---|
118 | unsigned long flags); |
---|
119 | |
---|
120 | template <typename C> |
---|
121 | xml::dom::auto_ptr<xercesc::DOMDocument> |
---|
122 | parse (const std::basic_string<C>& uri, |
---|
123 | xercesc::DOMErrorHandler&, |
---|
124 | const properties<C>&, |
---|
125 | unsigned long flags); |
---|
126 | } |
---|
127 | } |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | #include <xsd/cxx/xml/dom/parsing-source.txx> |
---|
132 | |
---|
133 | #endif // XSD_CXX_XML_DOM_PARSING_SOURCE_HXX |
---|