Line data Source code
1 : // file : xsd/cxx/xml/dom/parsing-source.hxx
2 : // copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC
3 : // license : GNU GPL v2 + exceptions; see accompanying LICENSE file
4 :
5 : #ifndef XSD_CXX_XML_DOM_PARSING_SOURCE_HXX
6 : #define XSD_CXX_XML_DOM_PARSING_SOURCE_HXX
7 :
8 : #include <string>
9 :
10 : #include <xercesc/dom/DOMNode.hpp>
11 : #include <xercesc/dom/DOMAttr.hpp>
12 : #include <xercesc/dom/DOMElement.hpp>
13 : #include <xercesc/dom/DOMDocument.hpp>
14 : #include <xercesc/dom/DOMNamedNodeMap.hpp>
15 : #include <xercesc/dom/DOMErrorHandler.hpp>
16 :
17 : #include <xercesc/sax/InputSource.hpp>
18 :
19 : #include <xsd/cxx/xml/elements.hxx> // properies
20 : #include <xsd/cxx/xml/error-handler.hxx>
21 : #include <xsd/cxx/xml/dom/auto-ptr.hxx>
22 : #include <xsd/cxx/xml/dom/elements.hxx> // name
23 : #include <xsd/cxx/xml/dom/parsing-header.hxx>
24 :
25 : namespace xsd
26 : {
27 : namespace cxx
28 : {
29 : namespace xml
30 : {
31 : namespace dom
32 : {
33 : // Parser state object. Can be used for parsing elements (and
34 : // optionally text), attributes, or both.
35 : //
36 : template <typename C>
37 : class parser
38 : {
39 : public:
40 : parser (const xercesc::DOMElement& e, bool ep, bool tp, bool ap);
41 :
42 : // Content parsing.
43 : //
44 : bool
45 0 : more_content ()
46 : {
47 0 : return next_content_ != 0;
48 : }
49 :
50 : const xercesc::DOMElement&
51 0 : cur_element ()
52 : {
53 0 : return *static_cast<const xercesc::DOMElement*> (next_content_);
54 : }
55 :
56 : const xercesc::DOMText&
57 : cur_text ()
58 : {
59 : return *static_cast<const xercesc::DOMText*> (next_content_);
60 : }
61 :
62 : bool
63 : cur_is_text ()
64 : {
65 : return next_content_->getNodeType () !=
66 : xercesc::DOMNode::ELEMENT_NODE;
67 : }
68 :
69 : void
70 : next_content (bool text);
71 :
72 : // Attribute parsing.
73 : //
74 : bool
75 0 : more_attributes ()
76 : {
77 0 : return as_ > ai_;
78 : }
79 :
80 : const xercesc::DOMAttr&
81 0 : next_attribute ()
82 : {
83 0 : return *static_cast<const xercesc::DOMAttr*> (a_->item (ai_++));
84 : }
85 :
86 : void
87 : reset_attributes ()
88 : {
89 : ai_ = 0;
90 : }
91 :
92 : const xercesc::DOMElement&
93 : element () const
94 : {
95 : return element_;
96 : }
97 :
98 : private:
99 : parser (const parser&);
100 :
101 : parser&
102 : operator= (const parser&);
103 :
104 : private:
105 : const xercesc::DOMElement& element_;
106 : const xercesc::DOMNode* next_content_;
107 :
108 : const xercesc::DOMNamedNodeMap* a_;
109 : XMLSize_t ai_; // Index of the next DOMAttr.
110 : XMLSize_t as_; // Cached size of a_.
111 : };
112 :
113 :
114 : // Parsing flags.
115 : //
116 : const unsigned long dont_validate = 0x00000400UL;
117 : const unsigned long no_muliple_imports = 0x00000800UL;
118 :
119 : template <typename C>
120 : XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
121 : parse (xercesc::InputSource&,
122 : error_handler<C>&,
123 : const properties<C>&,
124 : unsigned long flags);
125 :
126 : template <typename C>
127 : XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
128 : parse (xercesc::InputSource&,
129 : xercesc::DOMErrorHandler&,
130 : const properties<C>&,
131 : unsigned long flags);
132 :
133 : template <typename C>
134 : XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
135 : parse (const std::basic_string<C>& uri,
136 : error_handler<C>&,
137 : const properties<C>&,
138 : unsigned long flags);
139 :
140 : template <typename C>
141 : XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
142 : parse (const std::basic_string<C>& uri,
143 : xercesc::DOMErrorHandler&,
144 : const properties<C>&,
145 : unsigned long flags);
146 : }
147 : }
148 : }
149 : }
150 :
151 : #include <xsd/cxx/xml/dom/parsing-source.txx>
152 :
153 : #endif // XSD_CXX_XML_DOM_PARSING_SOURCE_HXX
|