Line data Source code
1 : // file : xsd/cxx/tree/elements.ixx
2 : // copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC
3 : // license : GNU GPL v2 + exceptions; see accompanying LICENSE file
4 :
5 : namespace xsd
6 : {
7 : namespace cxx
8 : {
9 : namespace tree
10 : {
11 : // content_order_type
12 : //
13 :
14 : inline bool
15 : operator== (const content_order& x, const content_order& y)
16 : {
17 : return x.id == y.id && x.index == y.index;
18 : }
19 :
20 : inline bool
21 : operator!= (const content_order& x, const content_order& y)
22 : {
23 : return !(x == y);
24 : }
25 :
26 : inline bool
27 : operator< (const content_order& x, const content_order& y)
28 : {
29 : return x.id < y.id || (x.id == y.id && x.index < y.index);
30 : }
31 :
32 : // type
33 : //
34 :
35 0 : inline _type::
36 0 : _type ()
37 0 : : container_ (0)
38 : {
39 0 : }
40 :
41 : template <typename C>
42 : inline _type::
43 : _type (const C*)
44 : : container_ (0)
45 : {
46 : }
47 :
48 0 : inline _type::
49 0 : _type (const type& x, flags f, container* c)
50 0 : : container_ (c)
51 : {
52 0 : if (x.content_.get () != 0)
53 0 : content_ = x.content_->clone ();
54 :
55 0 : if (x.dom_info_.get () != 0 && (f & flags::keep_dom))
56 : {
57 0 : dom_info_ = x.dom_info_->clone (*this, c);
58 : }
59 0 : }
60 :
61 0 : inline const _type::dom_content_optional& _type::
62 : dom_content () const
63 : {
64 0 : const content_type* c (content_.get ());
65 :
66 0 : if (c == 0)
67 : {
68 0 : content_.reset (new dom_content_type);
69 0 : c = content_.get ();
70 : }
71 :
72 : // Accessing non-DOM content via the DOM API.
73 : //
74 0 : assert (dynamic_cast<const dom_content_type*> (c) != 0);
75 :
76 0 : return static_cast<const dom_content_type*> (c)->dom;
77 : }
78 :
79 : inline _type::dom_content_optional& _type::
80 : dom_content ()
81 : {
82 : content_type* c (content_.get ());
83 :
84 : if (c == 0)
85 : {
86 : content_.reset (new dom_content_type);
87 : c = content_.get ();
88 : }
89 :
90 : // Accessing non-DOM content via the DOM API.
91 : //
92 : assert (dynamic_cast<dom_content_type*> (c) != 0);
93 :
94 : return static_cast<dom_content_type*> (c)->dom;
95 : }
96 :
97 : inline void _type::
98 : dom_content (const xercesc::DOMElement& e)
99 : {
100 : content_type* c (content_.get ());
101 :
102 : if (c == 0)
103 : content_.reset (new dom_content_type (e));
104 : else
105 : {
106 : // Accessing non-DOM content via the DOM API.
107 : //
108 : assert (dynamic_cast<dom_content_type*> (c) != 0);
109 : static_cast<dom_content_type*> (c)->dom.set (e);
110 : }
111 : }
112 :
113 : inline void _type::
114 : dom_content (xercesc::DOMElement* e)
115 : {
116 : content_type* c (content_.get ());
117 :
118 : if (c == 0)
119 : content_.reset (new dom_content_type (e));
120 : else
121 : {
122 : // Accessing non-DOM content via the DOM API.
123 : //
124 : assert (dynamic_cast<dom_content_type*> (c) != 0);
125 : static_cast<dom_content_type*> (c)->dom.set (e);
126 : }
127 : }
128 :
129 : inline void _type::
130 : dom_content (const dom_content_optional& d)
131 : {
132 : content_type* c (content_.get ());
133 :
134 : if (c == 0)
135 : content_.reset (new dom_content_type (d));
136 : else
137 : {
138 : // Accessing non-DOM content via the DOM API.
139 : //
140 : assert (dynamic_cast<dom_content_type*> (c) != 0);
141 : static_cast<dom_content_type*> (c)->dom = d;
142 : }
143 : }
144 :
145 : inline const xercesc::DOMDocument& _type::
146 : dom_content_document () const
147 : {
148 : const content_type* c (content_.get ());
149 :
150 : if (c == 0)
151 : {
152 : content_.reset (new dom_content_type);
153 : c = content_.get ();
154 : }
155 :
156 : // Accessing non-DOM content via the DOM API.
157 : //
158 : assert (dynamic_cast<const dom_content_type*> (c) != 0);
159 :
160 : return *static_cast<const dom_content_type*> (c)->doc;
161 : }
162 :
163 : inline xercesc::DOMDocument& _type::
164 : dom_content_document ()
165 : {
166 : content_type* c (content_.get ());
167 :
168 : if (c == 0)
169 : {
170 : content_.reset (new dom_content_type);
171 : c = content_.get ();
172 : }
173 :
174 : // Accessing non-DOM content via the DOM API.
175 : //
176 : assert (dynamic_cast<dom_content_type*> (c) != 0);
177 :
178 : return *static_cast<dom_content_type*> (c)->doc;
179 : }
180 :
181 0 : inline bool _type::
182 : null_content () const
183 : {
184 0 : return content_.get () == 0;
185 : }
186 :
187 : // simple_type
188 : //
189 :
190 : template <typename C, typename B>
191 0 : inline simple_type<C, B>::
192 0 : simple_type ()
193 : {
194 0 : }
195 :
196 : template <typename C, typename B>
197 : inline simple_type<C, B>::
198 : simple_type (const C* s)
199 : {
200 : this->content_.reset (new text_content_type (s));
201 : }
202 :
203 : template <typename C, typename B>
204 : inline simple_type<C, B>::
205 : simple_type (const std::basic_string<C>& s)
206 : {
207 : this->content_.reset (new text_content_type (s));
208 : }
209 :
210 : template <typename C, typename B>
211 : inline const std::basic_string<C>& simple_type<C, B>::
212 : text_content () const
213 : {
214 : const content_type* c (this->content_.get ());
215 :
216 : if (c == 0)
217 : {
218 : this->content_.reset (new text_content_type);
219 : c = this->content_.get ();
220 : }
221 :
222 : // Accessing non-text content via the text API.
223 : //
224 : assert (dynamic_cast<const text_content_type*> (c) != 0);
225 :
226 : return static_cast<const text_content_type*> (c)->text;
227 : }
228 :
229 : template <typename C, typename B>
230 : inline std::basic_string<C>& simple_type<C, B>::
231 : text_content ()
232 : {
233 : content_type* c (this->content_.get ());
234 :
235 : if (c == 0)
236 : {
237 : this->content_.reset (new text_content_type);
238 : c = this->content_.get ();
239 : }
240 :
241 : // Accessing non-text content via the text API.
242 : //
243 : assert (dynamic_cast<text_content_type*> (c) != 0);
244 :
245 : return static_cast<text_content_type*> (c)->text;
246 : }
247 :
248 : template <typename C, typename B>
249 : inline void simple_type<C, B>::
250 : text_content (const std::basic_string<C>& t)
251 : {
252 : content_type* c (this->content_.get ());
253 :
254 : if (c == 0)
255 : this->content_.reset (new text_content_type (t));
256 : else
257 : {
258 : // Accessing non-text content via the text API.
259 : //
260 : assert (dynamic_cast<text_content_type*> (c) != 0);
261 : static_cast<text_content_type*> (c)->text = t;
262 : }
263 : }
264 : }
265 : }
266 : }
|