1 | // file : xsd/cxx/tree/types.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 | /** |
---|
7 | * @file |
---|
8 | * |
---|
9 | * @brief Contains C++ class definitions for XML Schema built-in types. |
---|
10 | * |
---|
11 | * This is an internal header and is included by the generated code. You |
---|
12 | * normally should not include it directly. |
---|
13 | * |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef XSD_CXX_TREE_TYPES_HXX |
---|
17 | #define XSD_CXX_TREE_TYPES_HXX |
---|
18 | |
---|
19 | #include <string> |
---|
20 | #include <cstddef> // std::size_t |
---|
21 | |
---|
22 | #include <xercesc/dom/DOMAttr.hpp> |
---|
23 | #include <xercesc/dom/DOMElement.hpp> |
---|
24 | |
---|
25 | #include <xsd/cxx/tree/elements.hxx> |
---|
26 | #include <xsd/cxx/tree/list.hxx> |
---|
27 | #include <xsd/cxx/tree/buffer.hxx> |
---|
28 | #include <xsd/cxx/tree/istream-fwd.hxx> |
---|
29 | |
---|
30 | #include <xsd/cxx/tree/date-time.hxx> |
---|
31 | |
---|
32 | namespace xsd |
---|
33 | { |
---|
34 | namespace cxx |
---|
35 | { |
---|
36 | /** |
---|
37 | * @brief C++/Tree mapping runtime namespace. |
---|
38 | * |
---|
39 | * This is an internal namespace and normally should not be referenced |
---|
40 | * directly. Instead you should use the aliases for types in this |
---|
41 | * namespaces that are created in the generated code. |
---|
42 | * |
---|
43 | */ |
---|
44 | namespace tree |
---|
45 | { |
---|
46 | /** |
---|
47 | * @brief Class corresponding to the XML Schema %string built-in |
---|
48 | * type. |
---|
49 | * |
---|
50 | * The %string class publicly inherits from and has the same set |
---|
51 | * of constructors as @c std::basic_string. It therefore can be |
---|
52 | * used as @c std::string (or @c std::wstring if you are using |
---|
53 | * @c wchar_t as the character type). |
---|
54 | * |
---|
55 | * @nosubgrouping |
---|
56 | */ |
---|
57 | template <typename C, typename B> |
---|
58 | class string: public B, public std::basic_string<C> |
---|
59 | { |
---|
60 | typedef std::basic_string<C> base_type; |
---|
61 | |
---|
62 | base_type& |
---|
63 | base () |
---|
64 | { |
---|
65 | return *this; |
---|
66 | } |
---|
67 | |
---|
68 | public: |
---|
69 | /** |
---|
70 | * @name Constructors |
---|
71 | */ |
---|
72 | //@{ |
---|
73 | |
---|
74 | /** |
---|
75 | * @brief Default constructor creates an empty %string. |
---|
76 | */ |
---|
77 | string () |
---|
78 | { |
---|
79 | } |
---|
80 | |
---|
81 | /** |
---|
82 | * @brief Initialize an instance with a copy of a C %string. |
---|
83 | * |
---|
84 | * @param s A C %string to copy. |
---|
85 | */ |
---|
86 | string (const C* s) |
---|
87 | : base_type (s) |
---|
88 | { |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * @brief Initialize an instance with a character array. |
---|
93 | * |
---|
94 | * @param s A character array to copy. |
---|
95 | * @param n A number of character to copy. |
---|
96 | */ |
---|
97 | string (const C* s, std::size_t n) |
---|
98 | : base_type (s, n) |
---|
99 | { |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * @brief Initialize an instance with multiple copies of the same |
---|
104 | * character. |
---|
105 | * |
---|
106 | * @param n A number of copies to create. |
---|
107 | * @param c A character to copy. |
---|
108 | */ |
---|
109 | string (std::size_t n, C c) |
---|
110 | : base_type (n, c) |
---|
111 | { |
---|
112 | } |
---|
113 | |
---|
114 | /** |
---|
115 | * @brief Initialize an instance with a copy of a standard %string. |
---|
116 | * |
---|
117 | * @param s A standard %string to copy. |
---|
118 | */ |
---|
119 | string (const std::basic_string<C>& s) |
---|
120 | : base_type (s) |
---|
121 | { |
---|
122 | } |
---|
123 | |
---|
124 | /** |
---|
125 | * @brief Initialize an instance with a copy of a substring. |
---|
126 | * |
---|
127 | * @param s A standard %string to copy the substring from. |
---|
128 | * @param pos An index of the first character to copy from. |
---|
129 | * @param n A number of characters to copy. |
---|
130 | */ |
---|
131 | string (const std::basic_string<C>& s, |
---|
132 | std::size_t pos, |
---|
133 | std::size_t n = std::basic_string<C>::npos) |
---|
134 | : base_type (s, pos, n) |
---|
135 | { |
---|
136 | } |
---|
137 | |
---|
138 | public: |
---|
139 | /** |
---|
140 | * @brief Copy constructor. |
---|
141 | * |
---|
142 | * @param x An instance to make a copy of. |
---|
143 | * @param f Flags to create the copy with. |
---|
144 | * @param c A pointer to the object that will contain the copy. |
---|
145 | * |
---|
146 | * For polymorphic object models use the @c _clone function instead. |
---|
147 | */ |
---|
148 | string (const string& x, flags f = 0, container* c = 0) |
---|
149 | : B (x, f, c), base_type (x) |
---|
150 | { |
---|
151 | } |
---|
152 | |
---|
153 | /** |
---|
154 | * @brief Copy the instance polymorphically. |
---|
155 | * |
---|
156 | * @param f Flags to create the copy with. |
---|
157 | * @param c A pointer to the object that will contain the copy. |
---|
158 | * @return A pointer to the dynamically allocated copy. |
---|
159 | * |
---|
160 | * This function ensures that the dynamic type of the instance |
---|
161 | * is used for copying and should be used for polymorphic object |
---|
162 | * models instead of the copy constructor. |
---|
163 | */ |
---|
164 | virtual string* |
---|
165 | _clone (flags f = 0, container* c = 0) const; |
---|
166 | |
---|
167 | public: |
---|
168 | /** |
---|
169 | * @brief Create an instance from a data representation |
---|
170 | * stream. |
---|
171 | * |
---|
172 | * @param s A stream to extract the data from. |
---|
173 | * @param f Flags to create the new instance with. |
---|
174 | * @param c A pointer to the object that will contain the new |
---|
175 | * instance. |
---|
176 | */ |
---|
177 | template <typename S> |
---|
178 | string (istream<S>& s, flags f = 0, container* c = 0); |
---|
179 | |
---|
180 | /** |
---|
181 | * @brief Create an instance from a DOM element. |
---|
182 | * |
---|
183 | * @param e A DOM element to extract the data from. |
---|
184 | * @param f Flags to create the new instance with. |
---|
185 | * @param c A pointer to the object that will contain the new |
---|
186 | * instance. |
---|
187 | */ |
---|
188 | string (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
189 | |
---|
190 | /** |
---|
191 | * @brief Create an instance from a DOM Attribute. |
---|
192 | * |
---|
193 | * @param a A DOM attribute to extract the data from. |
---|
194 | * @param f Flags to create the new instance with. |
---|
195 | * @param c A pointer to the object that will contain the new |
---|
196 | * instance. |
---|
197 | */ |
---|
198 | string (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
199 | |
---|
200 | /** |
---|
201 | * @brief Create an instance from a %string fragment. |
---|
202 | * |
---|
203 | * @param s A %string fragment to extract the data from. |
---|
204 | * @param e A pointer to DOM element containing the %string fragment. |
---|
205 | * @param f Flags to create the new instance with. |
---|
206 | * @param c A pointer to the object that will contain the new |
---|
207 | * instance. |
---|
208 | */ |
---|
209 | string (const std::basic_string<C>& s, |
---|
210 | const xercesc::DOMElement* e, |
---|
211 | flags f = 0, |
---|
212 | container* c = 0); |
---|
213 | //@} |
---|
214 | |
---|
215 | public: |
---|
216 | /** |
---|
217 | * @brief Assign a character to the instance. |
---|
218 | * |
---|
219 | * The resulting %string has only one character. |
---|
220 | * |
---|
221 | * @param c A character to assign. |
---|
222 | * @return A reference to the instance. |
---|
223 | */ |
---|
224 | string& |
---|
225 | operator= (C c) |
---|
226 | { |
---|
227 | base () = c; |
---|
228 | return *this; |
---|
229 | } |
---|
230 | |
---|
231 | /** |
---|
232 | * @brief Assign a C %string to the instance. |
---|
233 | * |
---|
234 | * The resulting %string contains a copy of the C %string. |
---|
235 | * |
---|
236 | * @param s A C %string to assign. |
---|
237 | * @return A reference to the instance. |
---|
238 | */ |
---|
239 | string& |
---|
240 | operator= (const C* s) |
---|
241 | { |
---|
242 | base () = s; |
---|
243 | return *this; |
---|
244 | } |
---|
245 | |
---|
246 | /** |
---|
247 | * @brief Assign a standard %string to the instance. |
---|
248 | * |
---|
249 | * The resulting %string contains a copy of the standard %string. |
---|
250 | * |
---|
251 | * @param s A standard %string to assign. |
---|
252 | * @return A reference to the instance. |
---|
253 | */ |
---|
254 | string& |
---|
255 | operator= (const std::basic_string<C>& s) |
---|
256 | { |
---|
257 | base () = s; |
---|
258 | return *this; |
---|
259 | } |
---|
260 | |
---|
261 | /** |
---|
262 | * @brief Copy assignment operator. |
---|
263 | * |
---|
264 | * @param x An instance to assign. |
---|
265 | * @return A reference to the instance. |
---|
266 | */ |
---|
267 | string& |
---|
268 | operator= (const string& x) |
---|
269 | { |
---|
270 | base () = x; |
---|
271 | return *this; |
---|
272 | } |
---|
273 | }; |
---|
274 | |
---|
275 | |
---|
276 | /** |
---|
277 | * @brief Class corresponding to the XML Schema normalizedString |
---|
278 | * built-in type. |
---|
279 | * |
---|
280 | * The %normalized_string class publicly inherits from and has |
---|
281 | * the same set of constructors as @c std::basic_string. It |
---|
282 | * therefore can be used as @c std::string (or @c std::wstring |
---|
283 | * if you are using @c wchar_t as the character type). |
---|
284 | * |
---|
285 | * @nosubgrouping |
---|
286 | */ |
---|
287 | template <typename C, typename B> |
---|
288 | class normalized_string: public B |
---|
289 | { |
---|
290 | typedef B base_type; |
---|
291 | |
---|
292 | base_type& |
---|
293 | base () |
---|
294 | { |
---|
295 | return *this; |
---|
296 | } |
---|
297 | |
---|
298 | public: |
---|
299 | /** |
---|
300 | * @name Constructors |
---|
301 | */ |
---|
302 | //@{ |
---|
303 | |
---|
304 | /** |
---|
305 | * @brief Default constructor creates an empty %normalized_string. |
---|
306 | */ |
---|
307 | normalized_string () |
---|
308 | { |
---|
309 | } |
---|
310 | |
---|
311 | /** |
---|
312 | * @brief Initialize an instance with a copy of a C %string. |
---|
313 | * |
---|
314 | * @param s A C %string to copy. |
---|
315 | */ |
---|
316 | normalized_string (const C* s) |
---|
317 | : base_type (s) |
---|
318 | { |
---|
319 | } |
---|
320 | |
---|
321 | /** |
---|
322 | * @brief Initialize an instance with a character array. |
---|
323 | * |
---|
324 | * @param s A character array to copy. |
---|
325 | * @param n A number of character to copy. |
---|
326 | */ |
---|
327 | normalized_string (const C* s, std::size_t n) |
---|
328 | : base_type (s, n) |
---|
329 | { |
---|
330 | } |
---|
331 | |
---|
332 | /** |
---|
333 | * @brief Initialize an instance with multiple copies of the same |
---|
334 | * character. |
---|
335 | * |
---|
336 | * @param n A number of copies to create. |
---|
337 | * @param c A character to copy. |
---|
338 | */ |
---|
339 | normalized_string (std::size_t n, C c) |
---|
340 | : base_type (n, c) |
---|
341 | { |
---|
342 | } |
---|
343 | |
---|
344 | /** |
---|
345 | * @brief Initialize an instance with a copy of a standard %string. |
---|
346 | * |
---|
347 | * @param s A standard %string to copy. |
---|
348 | */ |
---|
349 | normalized_string (const std::basic_string<C>& s) |
---|
350 | : base_type (s) |
---|
351 | { |
---|
352 | } |
---|
353 | |
---|
354 | /** |
---|
355 | * @brief Initialize an instance with a copy of a substring. |
---|
356 | * |
---|
357 | * @param s A standard %string to copy the substring from. |
---|
358 | * @param pos An index of the first character to copy from. |
---|
359 | * @param n A number of characters to copy. |
---|
360 | */ |
---|
361 | normalized_string (const std::basic_string<C>& s, |
---|
362 | std::size_t pos, |
---|
363 | std::size_t n = std::basic_string<C>::npos) |
---|
364 | : base_type (s, pos, n) |
---|
365 | { |
---|
366 | } |
---|
367 | |
---|
368 | public: |
---|
369 | /** |
---|
370 | * @brief Copy constructor. |
---|
371 | * |
---|
372 | * @param x An instance to make a copy of. |
---|
373 | * @param f Flags to create the copy with. |
---|
374 | * @param c A pointer to the object that will contain the copy. |
---|
375 | * |
---|
376 | * For polymorphic object models use the @c _clone function instead. |
---|
377 | */ |
---|
378 | normalized_string (const normalized_string& x, |
---|
379 | flags f = 0, |
---|
380 | container* c = 0) |
---|
381 | : base_type (x, f, c) |
---|
382 | { |
---|
383 | } |
---|
384 | |
---|
385 | /** |
---|
386 | * @brief Copy the instance polymorphically. |
---|
387 | * |
---|
388 | * @param f Flags to create the copy with. |
---|
389 | * @param c A pointer to the object that will contain the copy. |
---|
390 | * @return A pointer to the dynamically allocated copy. |
---|
391 | * |
---|
392 | * This function ensures that the dynamic type of the instance |
---|
393 | * is used for copying and should be used for polymorphic object |
---|
394 | * models instead of the copy constructor. |
---|
395 | */ |
---|
396 | virtual normalized_string* |
---|
397 | _clone (flags f = 0, container* c = 0) const; |
---|
398 | |
---|
399 | public: |
---|
400 | /** |
---|
401 | * @brief Create an instance from a data representation |
---|
402 | * stream. |
---|
403 | * |
---|
404 | * @param s A stream to extract the data from. |
---|
405 | * @param f Flags to create the new instance with. |
---|
406 | * @param c A pointer to the object that will contain the new |
---|
407 | * instance. |
---|
408 | */ |
---|
409 | template <typename S> |
---|
410 | normalized_string (istream<S>& s, flags f = 0, container* c = 0); |
---|
411 | |
---|
412 | /** |
---|
413 | * @brief Create an instance from a DOM element. |
---|
414 | * |
---|
415 | * @param e A DOM element to extract the data from. |
---|
416 | * @param f Flags to create the new instance with. |
---|
417 | * @param c A pointer to the object that will contain the new |
---|
418 | * instance. |
---|
419 | */ |
---|
420 | normalized_string (const xercesc::DOMElement& e, |
---|
421 | flags f = 0, |
---|
422 | container* c = 0); |
---|
423 | |
---|
424 | /** |
---|
425 | * @brief Create an instance from a DOM Attribute. |
---|
426 | * |
---|
427 | * @param a A DOM attribute to extract the data from. |
---|
428 | * @param f Flags to create the new instance with. |
---|
429 | * @param c A pointer to the object that will contain the new |
---|
430 | * instance. |
---|
431 | */ |
---|
432 | normalized_string (const xercesc::DOMAttr& a, |
---|
433 | flags f = 0, |
---|
434 | container* c = 0); |
---|
435 | |
---|
436 | /** |
---|
437 | * @brief Create an instance from a %string fragment. |
---|
438 | * |
---|
439 | * @param s A %string fragment to extract the data from. |
---|
440 | * @param e A pointer to DOM element containing the %string fragment. |
---|
441 | * @param f Flags to create the new instance with. |
---|
442 | * @param c A pointer to the object that will contain the new |
---|
443 | * instance. |
---|
444 | */ |
---|
445 | normalized_string (const std::basic_string<C>& s, |
---|
446 | const xercesc::DOMElement* e, |
---|
447 | flags f = 0, |
---|
448 | container* c = 0); |
---|
449 | //@} |
---|
450 | |
---|
451 | public: |
---|
452 | /** |
---|
453 | * @brief Assign a character to the instance. |
---|
454 | * |
---|
455 | * The resulting %normalized_string has only one character. |
---|
456 | * |
---|
457 | * @param c A character to assign. |
---|
458 | * @return A reference to the instance. |
---|
459 | */ |
---|
460 | normalized_string& |
---|
461 | operator= (C c) |
---|
462 | { |
---|
463 | base () = c; |
---|
464 | return *this; |
---|
465 | } |
---|
466 | |
---|
467 | /** |
---|
468 | * @brief Assign a C %string to the instance. |
---|
469 | * |
---|
470 | * The resulting %normalized_string contains a copy of the C %string. |
---|
471 | * |
---|
472 | * @param s A C %string to assign. |
---|
473 | * @return A reference to the instance. |
---|
474 | */ |
---|
475 | normalized_string& |
---|
476 | operator= (const C* s) |
---|
477 | { |
---|
478 | base () = s; |
---|
479 | return *this; |
---|
480 | } |
---|
481 | |
---|
482 | /** |
---|
483 | * @brief Assign a standard %string to the instance. |
---|
484 | * |
---|
485 | * The resulting %normalized_string contains a copy of the standard |
---|
486 | * %string. |
---|
487 | * |
---|
488 | * @param s A standard %string to assign. |
---|
489 | * @return A reference to the instance. |
---|
490 | */ |
---|
491 | normalized_string& |
---|
492 | operator= (const std::basic_string<C>& s) |
---|
493 | { |
---|
494 | base () = s; |
---|
495 | return *this; |
---|
496 | } |
---|
497 | |
---|
498 | /** |
---|
499 | * @brief Copy assignment operator. |
---|
500 | * |
---|
501 | * @param x An instance to assign. |
---|
502 | * @return A reference to the instance. |
---|
503 | */ |
---|
504 | normalized_string& |
---|
505 | operator= (const normalized_string& x) |
---|
506 | { |
---|
507 | base () = x; |
---|
508 | return *this; |
---|
509 | } |
---|
510 | |
---|
511 | protected: |
---|
512 | //@cond |
---|
513 | |
---|
514 | void |
---|
515 | normalize (); |
---|
516 | |
---|
517 | //@endcond |
---|
518 | }; |
---|
519 | |
---|
520 | |
---|
521 | /** |
---|
522 | * @brief Class corresponding to the XML Schema %token built-in |
---|
523 | * type. |
---|
524 | * |
---|
525 | * The %token class publicly inherits from and has the same set |
---|
526 | * of constructors as @c std::basic_string. It therefore can be |
---|
527 | * used as @c std::string (or @c std::wstring if you are using |
---|
528 | * @c wchar_t as the character type). |
---|
529 | * |
---|
530 | * @nosubgrouping |
---|
531 | */ |
---|
532 | template <typename C, typename B> |
---|
533 | class token: public B |
---|
534 | { |
---|
535 | typedef B base_type; |
---|
536 | |
---|
537 | base_type& |
---|
538 | base () |
---|
539 | { |
---|
540 | return *this; |
---|
541 | } |
---|
542 | |
---|
543 | public: |
---|
544 | /** |
---|
545 | * @name Constructors |
---|
546 | */ |
---|
547 | //@{ |
---|
548 | |
---|
549 | /** |
---|
550 | * @brief Default constructor creates an empty %token. |
---|
551 | */ |
---|
552 | token () |
---|
553 | { |
---|
554 | } |
---|
555 | |
---|
556 | /** |
---|
557 | * @brief Initialize an instance with a copy of a C %string. |
---|
558 | * |
---|
559 | * @param s A C %string to copy. |
---|
560 | */ |
---|
561 | token (const C* s) |
---|
562 | : base_type (s) |
---|
563 | { |
---|
564 | } |
---|
565 | |
---|
566 | /** |
---|
567 | * @brief Initialize an instance with a character array. |
---|
568 | * |
---|
569 | * @param s A character array to copy. |
---|
570 | * @param n A number of character to copy. |
---|
571 | */ |
---|
572 | token (const C* s, std::size_t n) |
---|
573 | : base_type (s, n) |
---|
574 | { |
---|
575 | } |
---|
576 | |
---|
577 | /** |
---|
578 | * @brief Initialize an instance with multiple copies of the same |
---|
579 | * character. |
---|
580 | * |
---|
581 | * @param n A number of copies to create. |
---|
582 | * @param c A character to copy. |
---|
583 | */ |
---|
584 | token (std::size_t n, C c) |
---|
585 | : base_type (n, c) |
---|
586 | { |
---|
587 | } |
---|
588 | |
---|
589 | /** |
---|
590 | * @brief Initialize an instance with a copy of a standard %string. |
---|
591 | * |
---|
592 | * @param s A standard %string to copy. |
---|
593 | */ |
---|
594 | token (const std::basic_string<C>& s) |
---|
595 | : base_type (s) |
---|
596 | { |
---|
597 | } |
---|
598 | |
---|
599 | /** |
---|
600 | * @brief Initialize an instance with a copy of a substring. |
---|
601 | * |
---|
602 | * @param s A standard %string to copy the substring from. |
---|
603 | * @param pos An index of the first character to copy from. |
---|
604 | * @param n A number of characters to copy. |
---|
605 | */ |
---|
606 | token (const std::basic_string<C>& s, |
---|
607 | std::size_t pos, |
---|
608 | std::size_t n = std::basic_string<C>::npos) |
---|
609 | : base_type (s, pos, n) |
---|
610 | { |
---|
611 | } |
---|
612 | |
---|
613 | public: |
---|
614 | /** |
---|
615 | * @brief Copy constructor. |
---|
616 | * |
---|
617 | * @param x An instance to make a copy of. |
---|
618 | * @param f Flags to create the copy with. |
---|
619 | * @param c A pointer to the object that will contain the copy. |
---|
620 | * |
---|
621 | * For polymorphic object models use the @c _clone function instead. |
---|
622 | */ |
---|
623 | token (const token& x, flags f = 0, container* c = 0) |
---|
624 | : base_type (x, f, c) |
---|
625 | { |
---|
626 | } |
---|
627 | |
---|
628 | /** |
---|
629 | * @brief Copy the instance polymorphically. |
---|
630 | * |
---|
631 | * @param f Flags to create the copy with. |
---|
632 | * @param c A pointer to the object that will contain the copy. |
---|
633 | * @return A pointer to the dynamically allocated copy. |
---|
634 | * |
---|
635 | * This function ensures that the dynamic type of the instance |
---|
636 | * is used for copying and should be used for polymorphic object |
---|
637 | * models instead of the copy constructor. |
---|
638 | */ |
---|
639 | virtual token* |
---|
640 | _clone (flags f = 0, container* c = 0) const; |
---|
641 | |
---|
642 | public: |
---|
643 | /** |
---|
644 | * @brief Create an instance from a data representation |
---|
645 | * stream. |
---|
646 | * |
---|
647 | * @param s A stream to extract the data from. |
---|
648 | * @param f Flags to create the new instance with. |
---|
649 | * @param c A pointer to the object that will contain the new |
---|
650 | * instance. |
---|
651 | */ |
---|
652 | template <typename S> |
---|
653 | token (istream<S>& s, flags f = 0, container* c = 0); |
---|
654 | |
---|
655 | /** |
---|
656 | * @brief Create an instance from a DOM element. |
---|
657 | * |
---|
658 | * @param e A DOM element to extract the data from. |
---|
659 | * @param f Flags to create the new instance with. |
---|
660 | * @param c A pointer to the object that will contain the new |
---|
661 | * instance. |
---|
662 | */ |
---|
663 | token (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
664 | |
---|
665 | /** |
---|
666 | * @brief Create an instance from a DOM Attribute. |
---|
667 | * |
---|
668 | * @param a A DOM attribute to extract the data from. |
---|
669 | * @param f Flags to create the new instance with. |
---|
670 | * @param c A pointer to the object that will contain the new |
---|
671 | * instance. |
---|
672 | */ |
---|
673 | token (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
674 | |
---|
675 | /** |
---|
676 | * @brief Create an instance from a %string fragment. |
---|
677 | * |
---|
678 | * @param s A %string fragment to extract the data from. |
---|
679 | * @param e A pointer to DOM element containing the %string fragment. |
---|
680 | * @param f Flags to create the new instance with. |
---|
681 | * @param c A pointer to the object that will contain the new |
---|
682 | * instance. |
---|
683 | */ |
---|
684 | token (const std::basic_string<C>& s, |
---|
685 | const xercesc::DOMElement* e, |
---|
686 | flags f = 0, |
---|
687 | container* c = 0); |
---|
688 | //@} |
---|
689 | |
---|
690 | public: |
---|
691 | /** |
---|
692 | * @brief Assign a character to the instance. |
---|
693 | * |
---|
694 | * The resulting %token has only one character. |
---|
695 | * |
---|
696 | * @param c A character to assign. |
---|
697 | * @return A reference to the instance. |
---|
698 | */ |
---|
699 | token& |
---|
700 | operator= (C c) |
---|
701 | { |
---|
702 | base () = c; |
---|
703 | return *this; |
---|
704 | } |
---|
705 | |
---|
706 | /** |
---|
707 | * @brief Assign a C %string to the instance. |
---|
708 | * |
---|
709 | * The resulting %token contains a copy of the C %string. |
---|
710 | * |
---|
711 | * @param s A C %string to assign. |
---|
712 | * @return A reference to the instance. |
---|
713 | */ |
---|
714 | token& |
---|
715 | operator= (const C* s) |
---|
716 | { |
---|
717 | base () = s; |
---|
718 | return *this; |
---|
719 | } |
---|
720 | |
---|
721 | /** |
---|
722 | * @brief Assign a standard %string to the instance. |
---|
723 | * |
---|
724 | * The resulting %token contains a copy of the standard %string. |
---|
725 | * |
---|
726 | * @param s A standard %string to assign. |
---|
727 | * @return A reference to the instance. |
---|
728 | */ |
---|
729 | token& |
---|
730 | operator= (const std::basic_string<C>& s) |
---|
731 | { |
---|
732 | base () = s; |
---|
733 | return *this; |
---|
734 | } |
---|
735 | |
---|
736 | /** |
---|
737 | * @brief Copy assignment operator. |
---|
738 | * |
---|
739 | * @param x An instance to assign. |
---|
740 | * @return A reference to the instance. |
---|
741 | */ |
---|
742 | token& |
---|
743 | operator= (const token& x) |
---|
744 | { |
---|
745 | base () = x; |
---|
746 | return *this; |
---|
747 | } |
---|
748 | |
---|
749 | protected: |
---|
750 | //@cond |
---|
751 | |
---|
752 | void |
---|
753 | collapse (); |
---|
754 | |
---|
755 | //@endcond |
---|
756 | }; |
---|
757 | |
---|
758 | |
---|
759 | /** |
---|
760 | * @brief Class corresponding to the XML Schema NMTOKEN built-in |
---|
761 | * type. |
---|
762 | * |
---|
763 | * The %nmtoken class publicly inherits from and has the same set |
---|
764 | * of constructors as @c std::basic_string. It therefore can be |
---|
765 | * used as @c std::string (or @c std::wstring if you are using |
---|
766 | * @c wchar_t as the character type). |
---|
767 | * |
---|
768 | * @nosubgrouping |
---|
769 | */ |
---|
770 | template <typename C, typename B> |
---|
771 | class nmtoken: public B |
---|
772 | { |
---|
773 | typedef B base_type; |
---|
774 | |
---|
775 | base_type& |
---|
776 | base () |
---|
777 | { |
---|
778 | return *this; |
---|
779 | } |
---|
780 | |
---|
781 | public: |
---|
782 | /** |
---|
783 | * @name Constructors |
---|
784 | */ |
---|
785 | //@{ |
---|
786 | |
---|
787 | /** |
---|
788 | * @brief Initialize an instance with a copy of a C %string. |
---|
789 | * |
---|
790 | * @param s A C %string to copy. |
---|
791 | */ |
---|
792 | nmtoken (const C* s) |
---|
793 | : base_type (s) |
---|
794 | { |
---|
795 | } |
---|
796 | |
---|
797 | /** |
---|
798 | * @brief Initialize an instance with a character array. |
---|
799 | * |
---|
800 | * @param s A character array to copy. |
---|
801 | * @param n A number of character to copy. |
---|
802 | */ |
---|
803 | nmtoken (const C* s, std::size_t n) |
---|
804 | : base_type (s, n) |
---|
805 | { |
---|
806 | } |
---|
807 | |
---|
808 | /** |
---|
809 | * @brief Initialize an instance with multiple copies of the same |
---|
810 | * character. |
---|
811 | * |
---|
812 | * @param n A number of copies to create. |
---|
813 | * @param c A character to copy. |
---|
814 | */ |
---|
815 | nmtoken (std::size_t n, C c) |
---|
816 | : base_type (n, c) |
---|
817 | { |
---|
818 | } |
---|
819 | |
---|
820 | /** |
---|
821 | * @brief Initialize an instance with a copy of a standard %string. |
---|
822 | * |
---|
823 | * @param s A standard %string to copy. |
---|
824 | */ |
---|
825 | nmtoken (const std::basic_string<C>& s) |
---|
826 | : base_type (s) |
---|
827 | { |
---|
828 | } |
---|
829 | |
---|
830 | /** |
---|
831 | * @brief Initialize an instance with a copy of a substring. |
---|
832 | * |
---|
833 | * @param s A standard %string to copy the substring from. |
---|
834 | * @param pos An index of the first character to copy from. |
---|
835 | * @param n A number of characters to copy. |
---|
836 | */ |
---|
837 | nmtoken (const std::basic_string<C>& s, |
---|
838 | std::size_t pos, |
---|
839 | std::size_t n = std::basic_string<C>::npos) |
---|
840 | : base_type (s, pos, n) |
---|
841 | { |
---|
842 | } |
---|
843 | |
---|
844 | public: |
---|
845 | /** |
---|
846 | * @brief Copy constructor. |
---|
847 | * |
---|
848 | * @param x An instance to make a copy of. |
---|
849 | * @param f Flags to create the copy with. |
---|
850 | * @param c A pointer to the object that will contain the copy. |
---|
851 | * |
---|
852 | * For polymorphic object models use the @c _clone function instead. |
---|
853 | */ |
---|
854 | nmtoken (const nmtoken& x, flags f = 0, container* c = 0) |
---|
855 | : base_type (x, f, c) |
---|
856 | { |
---|
857 | } |
---|
858 | |
---|
859 | /** |
---|
860 | * @brief Copy the instance polymorphically. |
---|
861 | * |
---|
862 | * @param f Flags to create the copy with. |
---|
863 | * @param c A pointer to the object that will contain the copy. |
---|
864 | * @return A pointer to the dynamically allocated copy. |
---|
865 | * |
---|
866 | * This function ensures that the dynamic type of the instance |
---|
867 | * is used for copying and should be used for polymorphic object |
---|
868 | * models instead of the copy constructor. |
---|
869 | */ |
---|
870 | virtual nmtoken* |
---|
871 | _clone (flags f = 0, container* c = 0) const; |
---|
872 | |
---|
873 | public: |
---|
874 | /** |
---|
875 | * @brief Create an instance from a data representation |
---|
876 | * stream. |
---|
877 | * |
---|
878 | * @param s A stream to extract the data from. |
---|
879 | * @param f Flags to create the new instance with. |
---|
880 | * @param c A pointer to the object that will contain the new |
---|
881 | * instance. |
---|
882 | */ |
---|
883 | template <typename S> |
---|
884 | nmtoken (istream<S>& s, flags f = 0, container* c = 0); |
---|
885 | |
---|
886 | /** |
---|
887 | * @brief Create an instance from a DOM element. |
---|
888 | * |
---|
889 | * @param e A DOM element to extract the data from. |
---|
890 | * @param f Flags to create the new instance with. |
---|
891 | * @param c A pointer to the object that will contain the new |
---|
892 | * instance. |
---|
893 | */ |
---|
894 | nmtoken (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
895 | |
---|
896 | /** |
---|
897 | * @brief Create an instance from a DOM Attribute. |
---|
898 | * |
---|
899 | * @param a A DOM attribute to extract the data from. |
---|
900 | * @param f Flags to create the new instance with. |
---|
901 | * @param c A pointer to the object that will contain the new |
---|
902 | * instance. |
---|
903 | */ |
---|
904 | nmtoken (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
905 | |
---|
906 | /** |
---|
907 | * @brief Create an instance from a %string fragment. |
---|
908 | * |
---|
909 | * @param s A %string fragment to extract the data from. |
---|
910 | * @param e A pointer to DOM element containing the %string fragment. |
---|
911 | * @param f Flags to create the new instance with. |
---|
912 | * @param c A pointer to the object that will contain the new |
---|
913 | * instance. |
---|
914 | */ |
---|
915 | nmtoken (const std::basic_string<C>& s, |
---|
916 | const xercesc::DOMElement* e, |
---|
917 | flags f = 0, |
---|
918 | container* c = 0); |
---|
919 | //@} |
---|
920 | |
---|
921 | public: |
---|
922 | /** |
---|
923 | * @brief Assign a character to the instance. |
---|
924 | * |
---|
925 | * The resulting %nmtoken has only one character. |
---|
926 | * |
---|
927 | * @param c A character to assign. |
---|
928 | * @return A reference to the instance. |
---|
929 | */ |
---|
930 | nmtoken& |
---|
931 | operator= (C c) |
---|
932 | { |
---|
933 | base () = c; |
---|
934 | return *this; |
---|
935 | } |
---|
936 | |
---|
937 | /** |
---|
938 | * @brief Assign a C %string to the instance. |
---|
939 | * |
---|
940 | * The resulting %nmtoken contains a copy of the C %string. |
---|
941 | * |
---|
942 | * @param s A C %string to assign. |
---|
943 | * @return A reference to the instance. |
---|
944 | */ |
---|
945 | nmtoken& |
---|
946 | operator= (const C* s) |
---|
947 | { |
---|
948 | base () = s; |
---|
949 | return *this; |
---|
950 | } |
---|
951 | |
---|
952 | /** |
---|
953 | * @brief Assign a standard %string to the instance. |
---|
954 | * |
---|
955 | * The resulting %nmtoken contains a copy of the standard %string. |
---|
956 | * |
---|
957 | * @param s A standard %string to assign. |
---|
958 | * @return A reference to the instance. |
---|
959 | */ |
---|
960 | nmtoken& |
---|
961 | operator= (const std::basic_string<C>& s) |
---|
962 | { |
---|
963 | base () = s; |
---|
964 | return *this; |
---|
965 | } |
---|
966 | |
---|
967 | /** |
---|
968 | * @brief Copy assignment operator. |
---|
969 | * |
---|
970 | * @param x An instance to assign. |
---|
971 | * @return A reference to the instance. |
---|
972 | */ |
---|
973 | nmtoken& |
---|
974 | operator= (const nmtoken& x) |
---|
975 | { |
---|
976 | base () = x; |
---|
977 | return *this; |
---|
978 | } |
---|
979 | |
---|
980 | protected: |
---|
981 | //@cond |
---|
982 | |
---|
983 | nmtoken () |
---|
984 | : base_type () |
---|
985 | { |
---|
986 | } |
---|
987 | |
---|
988 | //@endcond |
---|
989 | }; |
---|
990 | |
---|
991 | |
---|
992 | /** |
---|
993 | * @brief Class corresponding to the XML Schema NMTOKENS built-in |
---|
994 | * type. |
---|
995 | * |
---|
996 | * The %nmtokens class is a vector (or %list in XML Schema terminology) |
---|
997 | * of nmtoken elements. It is implemented in terms of the list class |
---|
998 | * template. |
---|
999 | * |
---|
1000 | * @nosubgrouping |
---|
1001 | */ |
---|
1002 | template <typename C, typename B, typename nmtoken> |
---|
1003 | class nmtokens: public B, public list<nmtoken, C> |
---|
1004 | { |
---|
1005 | typedef list<nmtoken, C> base_type; |
---|
1006 | |
---|
1007 | public: |
---|
1008 | /** |
---|
1009 | * @name Constructors |
---|
1010 | */ |
---|
1011 | //@{ |
---|
1012 | |
---|
1013 | /** |
---|
1014 | * @brief Default constructor creates no elements. |
---|
1015 | */ |
---|
1016 | nmtokens () |
---|
1017 | { |
---|
1018 | } |
---|
1019 | |
---|
1020 | /** |
---|
1021 | * @brief Initialize the instance with copies of an exemplar elements. |
---|
1022 | * |
---|
1023 | * @param n A number of elements to copy. |
---|
1024 | * @param x An exemplar element to copy. |
---|
1025 | */ |
---|
1026 | nmtokens (typename base_type::size_type n, const nmtoken& x) |
---|
1027 | : base_type (n, x) |
---|
1028 | { |
---|
1029 | } |
---|
1030 | |
---|
1031 | /** |
---|
1032 | * @brief Initialize the instance with copies of elements from an |
---|
1033 | * iterator range. |
---|
1034 | * |
---|
1035 | * @param begin An iterator pointing to the first element. |
---|
1036 | * @param end An iterator pointing to the one past the last element. |
---|
1037 | */ |
---|
1038 | template <typename I> |
---|
1039 | nmtokens (const I& begin, const I& end) |
---|
1040 | : base_type (begin, end) |
---|
1041 | { |
---|
1042 | } |
---|
1043 | |
---|
1044 | public: |
---|
1045 | /** |
---|
1046 | * @brief Copy constructor. |
---|
1047 | * |
---|
1048 | * @param x An instance to make a copy of. |
---|
1049 | * @param f Flags to create the copy with. |
---|
1050 | * @param c A pointer to the object that will contain the copy. |
---|
1051 | * |
---|
1052 | * For polymorphic object models use the @c _clone function instead. |
---|
1053 | */ |
---|
1054 | nmtokens (const nmtokens& x, flags f, container* c = 0) |
---|
1055 | : B (x, f, c), base_type (x, f, c) |
---|
1056 | { |
---|
1057 | } |
---|
1058 | |
---|
1059 | /** |
---|
1060 | * @brief Copy the instance polymorphically. |
---|
1061 | * |
---|
1062 | * @param f Flags to create the copy with. |
---|
1063 | * @param c A pointer to the object that will contain the copy. |
---|
1064 | * @return A pointer to the dynamically allocated copy. |
---|
1065 | * |
---|
1066 | * This function ensures that the dynamic type of the instance |
---|
1067 | * is used for copying and should be used for polymorphic object |
---|
1068 | * models instead of the copy constructor. |
---|
1069 | */ |
---|
1070 | virtual nmtokens* |
---|
1071 | _clone (flags f = 0, container* c = 0) const; |
---|
1072 | |
---|
1073 | public: |
---|
1074 | /** |
---|
1075 | * @brief Create an instance from a data representation |
---|
1076 | * stream. |
---|
1077 | * |
---|
1078 | * @param s A stream to extract the data from. |
---|
1079 | * @param f Flags to create the new instance with. |
---|
1080 | * @param c A pointer to the object that will contain the new |
---|
1081 | * instance. |
---|
1082 | */ |
---|
1083 | template <typename S> |
---|
1084 | nmtokens (istream<S>& s, flags f = 0, container* c = 0); |
---|
1085 | |
---|
1086 | /** |
---|
1087 | * @brief Create an instance from a DOM element. |
---|
1088 | * |
---|
1089 | * @param e A DOM element to extract the data from. |
---|
1090 | * @param f Flags to create the new instance with. |
---|
1091 | * @param c A pointer to the object that will contain the new |
---|
1092 | * instance. |
---|
1093 | */ |
---|
1094 | nmtokens (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
1095 | |
---|
1096 | /** |
---|
1097 | * @brief Create an instance from a DOM Attribute. |
---|
1098 | * |
---|
1099 | * @param a A DOM attribute to extract the data from. |
---|
1100 | * @param f Flags to create the new instance with. |
---|
1101 | * @param c A pointer to the object that will contain the new |
---|
1102 | * instance. |
---|
1103 | */ |
---|
1104 | nmtokens (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
1105 | |
---|
1106 | /** |
---|
1107 | * @brief Create an instance from a %string fragment. |
---|
1108 | * |
---|
1109 | * @param s A %string fragment to extract the data from. |
---|
1110 | * @param e A pointer to DOM element containing the %string fragment. |
---|
1111 | * @param f Flags to create the new instance with. |
---|
1112 | * @param c A pointer to the object that will contain the new |
---|
1113 | * instance. |
---|
1114 | */ |
---|
1115 | nmtokens (const std::basic_string<C>& s, |
---|
1116 | const xercesc::DOMElement* e, |
---|
1117 | flags f = 0, |
---|
1118 | container* c = 0); |
---|
1119 | //@} |
---|
1120 | }; |
---|
1121 | |
---|
1122 | |
---|
1123 | /** |
---|
1124 | * @brief Class corresponding to the XML Schema Name built-in |
---|
1125 | * type. |
---|
1126 | * |
---|
1127 | * The %name class publicly inherits from and has the same set |
---|
1128 | * of constructors as @c std::basic_string. It therefore can be |
---|
1129 | * used as @c std::string (or @c std::wstring if you are using |
---|
1130 | * @c wchar_t as the character type). |
---|
1131 | * |
---|
1132 | * @nosubgrouping |
---|
1133 | */ |
---|
1134 | template <typename C, typename B> |
---|
1135 | class name: public B |
---|
1136 | { |
---|
1137 | typedef B base_type; |
---|
1138 | |
---|
1139 | base_type& |
---|
1140 | base () |
---|
1141 | { |
---|
1142 | return *this; |
---|
1143 | } |
---|
1144 | |
---|
1145 | public: |
---|
1146 | /** |
---|
1147 | * @name Constructors |
---|
1148 | */ |
---|
1149 | //@{ |
---|
1150 | |
---|
1151 | /** |
---|
1152 | * @brief Initialize an instance with a copy of a C %string. |
---|
1153 | * |
---|
1154 | * @param s A C %string to copy. |
---|
1155 | */ |
---|
1156 | name (const C* s) |
---|
1157 | : base_type (s) |
---|
1158 | { |
---|
1159 | } |
---|
1160 | |
---|
1161 | /** |
---|
1162 | * @brief Initialize an instance with a character array. |
---|
1163 | * |
---|
1164 | * @param s A character array to copy. |
---|
1165 | * @param n A number of character to copy. |
---|
1166 | */ |
---|
1167 | name (const C* s, std::size_t n) |
---|
1168 | : base_type (s, n) |
---|
1169 | { |
---|
1170 | } |
---|
1171 | |
---|
1172 | /** |
---|
1173 | * @brief Initialize an instance with multiple copies of the same |
---|
1174 | * character. |
---|
1175 | * |
---|
1176 | * @param n A number of copies to create. |
---|
1177 | * @param c A character to copy. |
---|
1178 | */ |
---|
1179 | name (std::size_t n, C c) |
---|
1180 | : base_type (n, c) |
---|
1181 | { |
---|
1182 | } |
---|
1183 | |
---|
1184 | /** |
---|
1185 | * @brief Initialize an instance with a copy of a standard %string. |
---|
1186 | * |
---|
1187 | * @param s A standard %string to copy. |
---|
1188 | */ |
---|
1189 | name (const std::basic_string<C>& s) |
---|
1190 | : base_type (s) |
---|
1191 | { |
---|
1192 | } |
---|
1193 | |
---|
1194 | /** |
---|
1195 | * @brief Initialize an instance with a copy of a substring. |
---|
1196 | * |
---|
1197 | * @param s A standard %string to copy the substring from. |
---|
1198 | * @param pos An index of the first character to copy from. |
---|
1199 | * @param n A number of characters to copy. |
---|
1200 | */ |
---|
1201 | name (const std::basic_string<C>& s, |
---|
1202 | std::size_t pos, |
---|
1203 | std::size_t n = std::basic_string<C>::npos) |
---|
1204 | : base_type (s, pos, n) |
---|
1205 | { |
---|
1206 | } |
---|
1207 | |
---|
1208 | public: |
---|
1209 | /** |
---|
1210 | * @brief Copy constructor. |
---|
1211 | * |
---|
1212 | * @param x An instance to make a copy of. |
---|
1213 | * @param f Flags to create the copy with. |
---|
1214 | * @param c A pointer to the object that will contain the copy. |
---|
1215 | * |
---|
1216 | * For polymorphic object models use the @c _clone function instead. |
---|
1217 | */ |
---|
1218 | name (const name& x, flags f = 0, container* c = 0) |
---|
1219 | : base_type (x, f, c) |
---|
1220 | { |
---|
1221 | } |
---|
1222 | |
---|
1223 | /** |
---|
1224 | * @brief Copy the instance polymorphically. |
---|
1225 | * |
---|
1226 | * @param f Flags to create the copy with. |
---|
1227 | * @param c A pointer to the object that will contain the copy. |
---|
1228 | * @return A pointer to the dynamically allocated copy. |
---|
1229 | * |
---|
1230 | * This function ensures that the dynamic type of the instance |
---|
1231 | * is used for copying and should be used for polymorphic object |
---|
1232 | * models instead of the copy constructor. |
---|
1233 | */ |
---|
1234 | virtual name* |
---|
1235 | _clone (flags f = 0, container* c = 0) const; |
---|
1236 | |
---|
1237 | public: |
---|
1238 | /** |
---|
1239 | * @brief Create an instance from a data representation |
---|
1240 | * stream. |
---|
1241 | * |
---|
1242 | * @param s A stream to extract the data from. |
---|
1243 | * @param f Flags to create the new instance with. |
---|
1244 | * @param c A pointer to the object that will contain the new |
---|
1245 | * instance. |
---|
1246 | */ |
---|
1247 | template <typename S> |
---|
1248 | name (istream<S>& s, flags f = 0, container* c = 0); |
---|
1249 | |
---|
1250 | /** |
---|
1251 | * @brief Create an instance from a DOM element. |
---|
1252 | * |
---|
1253 | * @param e A DOM element to extract the data from. |
---|
1254 | * @param f Flags to create the new instance with. |
---|
1255 | * @param c A pointer to the object that will contain the new |
---|
1256 | * instance. |
---|
1257 | */ |
---|
1258 | name (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
1259 | |
---|
1260 | /** |
---|
1261 | * @brief Create an instance from a DOM Attribute. |
---|
1262 | * |
---|
1263 | * @param a A DOM attribute to extract the data from. |
---|
1264 | * @param f Flags to create the new instance with. |
---|
1265 | * @param c A pointer to the object that will contain the new |
---|
1266 | * instance. |
---|
1267 | */ |
---|
1268 | name (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
1269 | |
---|
1270 | /** |
---|
1271 | * @brief Create an instance from a %string fragment. |
---|
1272 | * |
---|
1273 | * @param s A %string fragment to extract the data from. |
---|
1274 | * @param e A pointer to DOM element containing the %string fragment. |
---|
1275 | * @param f Flags to create the new instance with. |
---|
1276 | * @param c A pointer to the object that will contain the new |
---|
1277 | * instance. |
---|
1278 | */ |
---|
1279 | name (const std::basic_string<C>& s, |
---|
1280 | const xercesc::DOMElement* e, |
---|
1281 | flags f = 0, |
---|
1282 | container* c = 0); |
---|
1283 | //@} |
---|
1284 | |
---|
1285 | public: |
---|
1286 | /** |
---|
1287 | * @brief Assign a character to the instance. |
---|
1288 | * |
---|
1289 | * The resulting %name has only one character. |
---|
1290 | * |
---|
1291 | * @param c A character to assign. |
---|
1292 | * @return A reference to the instance. |
---|
1293 | */ |
---|
1294 | name& |
---|
1295 | operator= (C c) |
---|
1296 | { |
---|
1297 | base () = c; |
---|
1298 | return *this; |
---|
1299 | } |
---|
1300 | |
---|
1301 | /** |
---|
1302 | * @brief Assign a C %string to the instance. |
---|
1303 | * |
---|
1304 | * The resulting %name contains a copy of the C %string. |
---|
1305 | * |
---|
1306 | * @param s A C %string to assign. |
---|
1307 | * @return A reference to the instance. |
---|
1308 | */ |
---|
1309 | name& |
---|
1310 | operator= (const C* s) |
---|
1311 | { |
---|
1312 | base () = s; |
---|
1313 | return *this; |
---|
1314 | } |
---|
1315 | |
---|
1316 | /** |
---|
1317 | * @brief Assign a standard %string to the instance. |
---|
1318 | * |
---|
1319 | * The resulting %name contains a copy of the standard %string. |
---|
1320 | * |
---|
1321 | * @param s A standard %string to assign. |
---|
1322 | * @return A reference to the instance. |
---|
1323 | */ |
---|
1324 | name& |
---|
1325 | operator= (const std::basic_string<C>& s) |
---|
1326 | { |
---|
1327 | base () = s; |
---|
1328 | return *this; |
---|
1329 | } |
---|
1330 | |
---|
1331 | /** |
---|
1332 | * @brief Copy assignment operator. |
---|
1333 | * |
---|
1334 | * @param x An instance to assign. |
---|
1335 | * @return A reference to the instance. |
---|
1336 | */ |
---|
1337 | name& |
---|
1338 | operator= (const name& x) |
---|
1339 | { |
---|
1340 | base () = x; |
---|
1341 | return *this; |
---|
1342 | } |
---|
1343 | |
---|
1344 | protected: |
---|
1345 | //@cond |
---|
1346 | |
---|
1347 | name () |
---|
1348 | : base_type () |
---|
1349 | { |
---|
1350 | } |
---|
1351 | |
---|
1352 | //@endcond |
---|
1353 | }; |
---|
1354 | |
---|
1355 | |
---|
1356 | // Forward declaration for Sun CC. |
---|
1357 | // |
---|
1358 | template <typename C, typename B, typename uri, typename ncname> |
---|
1359 | class qname; |
---|
1360 | |
---|
1361 | |
---|
1362 | /** |
---|
1363 | * @brief Class corresponding to the XML Schema NCame built-in |
---|
1364 | * type. |
---|
1365 | * |
---|
1366 | * The %ncname class publicly inherits from and has the same set |
---|
1367 | * of constructors as @c std::basic_string. It therefore can be |
---|
1368 | * used as @c std::string (or @c std::wstring if you are using |
---|
1369 | * @c wchar_t as the character type). |
---|
1370 | * |
---|
1371 | * @nosubgrouping |
---|
1372 | */ |
---|
1373 | template <typename C, typename B> |
---|
1374 | class ncname: public B |
---|
1375 | { |
---|
1376 | typedef B base_type; |
---|
1377 | |
---|
1378 | base_type& |
---|
1379 | base () |
---|
1380 | { |
---|
1381 | return *this; |
---|
1382 | } |
---|
1383 | |
---|
1384 | public: |
---|
1385 | /** |
---|
1386 | * @name Constructors |
---|
1387 | */ |
---|
1388 | //@{ |
---|
1389 | |
---|
1390 | /** |
---|
1391 | * @brief Initialize an instance with a copy of a C %string. |
---|
1392 | * |
---|
1393 | * @param s A C %string to copy. |
---|
1394 | */ |
---|
1395 | ncname (const C* s) |
---|
1396 | : base_type (s) |
---|
1397 | { |
---|
1398 | } |
---|
1399 | |
---|
1400 | /** |
---|
1401 | * @brief Initialize an instance with a character array. |
---|
1402 | * |
---|
1403 | * @param s A character array to copy. |
---|
1404 | * @param n A number of character to copy. |
---|
1405 | */ |
---|
1406 | ncname (const C* s, std::size_t n) |
---|
1407 | : base_type (s, n) |
---|
1408 | { |
---|
1409 | } |
---|
1410 | |
---|
1411 | /** |
---|
1412 | * @brief Initialize an instance with multiple copies of the same |
---|
1413 | * character. |
---|
1414 | * |
---|
1415 | * @param n A number of copies to create. |
---|
1416 | * @param c A character to copy. |
---|
1417 | */ |
---|
1418 | ncname (std::size_t n, C c) |
---|
1419 | : base_type (n, c) |
---|
1420 | { |
---|
1421 | } |
---|
1422 | |
---|
1423 | /** |
---|
1424 | * @brief Initialize an instance with a copy of a standard %string. |
---|
1425 | * |
---|
1426 | * @param s A standard %string to copy. |
---|
1427 | */ |
---|
1428 | ncname (const std::basic_string<C>& s) |
---|
1429 | : base_type (s) |
---|
1430 | { |
---|
1431 | } |
---|
1432 | |
---|
1433 | /** |
---|
1434 | * @brief Initialize an instance with a copy of a substring. |
---|
1435 | * |
---|
1436 | * @param s A standard %string to copy the substring from. |
---|
1437 | * @param pos An index of the first character to copy from. |
---|
1438 | * @param n A number of characters to copy. |
---|
1439 | */ |
---|
1440 | ncname (const std::basic_string<C>& s, |
---|
1441 | std::size_t pos, |
---|
1442 | std::size_t n = std::basic_string<C>::npos) |
---|
1443 | : base_type (s, pos, n) |
---|
1444 | { |
---|
1445 | } |
---|
1446 | |
---|
1447 | public: |
---|
1448 | /** |
---|
1449 | * @brief Copy constructor. |
---|
1450 | * |
---|
1451 | * @param x An instance to make a copy of. |
---|
1452 | * @param f Flags to create the copy with. |
---|
1453 | * @param c A pointer to the object that will contain the copy. |
---|
1454 | * |
---|
1455 | * For polymorphic object models use the @c _clone function instead. |
---|
1456 | */ |
---|
1457 | ncname (const ncname& x, flags f = 0, container* c = 0) |
---|
1458 | : base_type (x, f, c) |
---|
1459 | { |
---|
1460 | } |
---|
1461 | |
---|
1462 | /** |
---|
1463 | * @brief Copy the instance polymorphically. |
---|
1464 | * |
---|
1465 | * @param f Flags to create the copy with. |
---|
1466 | * @param c A pointer to the object that will contain the copy. |
---|
1467 | * @return A pointer to the dynamically allocated copy. |
---|
1468 | * |
---|
1469 | * This function ensures that the dynamic type of the instance |
---|
1470 | * is used for copying and should be used for polymorphic object |
---|
1471 | * models instead of the copy constructor. |
---|
1472 | */ |
---|
1473 | virtual ncname* |
---|
1474 | _clone (flags f = 0, container* c = 0) const; |
---|
1475 | |
---|
1476 | public: |
---|
1477 | /** |
---|
1478 | * @brief Create an instance from a data representation |
---|
1479 | * stream. |
---|
1480 | * |
---|
1481 | * @param s A stream to extract the data from. |
---|
1482 | * @param f Flags to create the new instance with. |
---|
1483 | * @param c A pointer to the object that will contain the new |
---|
1484 | * instance. |
---|
1485 | */ |
---|
1486 | template <typename S> |
---|
1487 | ncname (istream<S>& s, flags f = 0, container* c = 0); |
---|
1488 | |
---|
1489 | /** |
---|
1490 | * @brief Create an instance from a DOM element. |
---|
1491 | * |
---|
1492 | * @param e A DOM element to extract the data from. |
---|
1493 | * @param f Flags to create the new instance with. |
---|
1494 | * @param c A pointer to the object that will contain the new |
---|
1495 | * instance. |
---|
1496 | */ |
---|
1497 | ncname (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
1498 | |
---|
1499 | /** |
---|
1500 | * @brief Create an instance from a DOM Attribute. |
---|
1501 | * |
---|
1502 | * @param a A DOM attribute to extract the data from. |
---|
1503 | * @param f Flags to create the new instance with. |
---|
1504 | * @param c A pointer to the object that will contain the new |
---|
1505 | * instance. |
---|
1506 | */ |
---|
1507 | ncname (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
1508 | |
---|
1509 | /** |
---|
1510 | * @brief Create an instance from a %string fragment. |
---|
1511 | * |
---|
1512 | * @param s A %string fragment to extract the data from. |
---|
1513 | * @param e A pointer to DOM element containing the %string fragment. |
---|
1514 | * @param f Flags to create the new instance with. |
---|
1515 | * @param c A pointer to the object that will contain the new |
---|
1516 | * instance. |
---|
1517 | */ |
---|
1518 | ncname (const std::basic_string<C>& s, |
---|
1519 | const xercesc::DOMElement* e, |
---|
1520 | flags f = 0, |
---|
1521 | container* c = 0); |
---|
1522 | //@} |
---|
1523 | |
---|
1524 | public: |
---|
1525 | /** |
---|
1526 | * @brief Assign a character to the instance. |
---|
1527 | * |
---|
1528 | * The resulting %ncname has only one character. |
---|
1529 | * |
---|
1530 | * @param c A character to assign. |
---|
1531 | * @return A reference to the instance. |
---|
1532 | */ |
---|
1533 | ncname& |
---|
1534 | operator= (C c) |
---|
1535 | { |
---|
1536 | base () = c; |
---|
1537 | return *this; |
---|
1538 | } |
---|
1539 | |
---|
1540 | /** |
---|
1541 | * @brief Assign a C %string to the instance. |
---|
1542 | * |
---|
1543 | * The resulting %ncname contains a copy of the C %string. |
---|
1544 | * |
---|
1545 | * @param s A C %string to assign. |
---|
1546 | * @return A reference to the instance. |
---|
1547 | */ |
---|
1548 | ncname& |
---|
1549 | operator= (const C* s) |
---|
1550 | { |
---|
1551 | base () = s; |
---|
1552 | return *this; |
---|
1553 | } |
---|
1554 | |
---|
1555 | /** |
---|
1556 | * @brief Assign a standard %string to the instance. |
---|
1557 | * |
---|
1558 | * The resulting %ncname contains a copy of the standard %string. |
---|
1559 | * |
---|
1560 | * @param s A standard %string to assign. |
---|
1561 | * @return A reference to the instance. |
---|
1562 | */ |
---|
1563 | ncname& |
---|
1564 | operator= (const std::basic_string<C>& s) |
---|
1565 | { |
---|
1566 | base () = s; |
---|
1567 | return *this; |
---|
1568 | } |
---|
1569 | |
---|
1570 | /** |
---|
1571 | * @brief Copy assignment operator. |
---|
1572 | * |
---|
1573 | * @param x An instance to assign. |
---|
1574 | * @return A reference to the instance. |
---|
1575 | */ |
---|
1576 | ncname& |
---|
1577 | operator= (const ncname& x) |
---|
1578 | { |
---|
1579 | base () = x; |
---|
1580 | return *this; |
---|
1581 | } |
---|
1582 | |
---|
1583 | protected: |
---|
1584 | //@cond |
---|
1585 | |
---|
1586 | ncname () |
---|
1587 | : base_type () |
---|
1588 | { |
---|
1589 | } |
---|
1590 | |
---|
1591 | //@endcond |
---|
1592 | |
---|
1593 | template <typename, typename, typename, typename> |
---|
1594 | friend class qname; |
---|
1595 | }; |
---|
1596 | |
---|
1597 | |
---|
1598 | /** |
---|
1599 | * @brief Class corresponding to the XML Schema %language built-in |
---|
1600 | * type. |
---|
1601 | * |
---|
1602 | * The %language class publicly inherits from and has the same set |
---|
1603 | * of constructors as @c std::basic_string. It therefore can be |
---|
1604 | * used as @c std::string (or @c std::wstring if you are using |
---|
1605 | * @c wchar_t as the character type). |
---|
1606 | * |
---|
1607 | * @nosubgrouping |
---|
1608 | */ |
---|
1609 | template <typename C, typename B> |
---|
1610 | class language: public B |
---|
1611 | { |
---|
1612 | typedef B base_type; |
---|
1613 | |
---|
1614 | base_type& |
---|
1615 | base () |
---|
1616 | { |
---|
1617 | return *this; |
---|
1618 | } |
---|
1619 | |
---|
1620 | public: |
---|
1621 | /** |
---|
1622 | * @name Constructors |
---|
1623 | */ |
---|
1624 | //@{ |
---|
1625 | |
---|
1626 | /** |
---|
1627 | * @brief Initialize an instance with a copy of a C %string. |
---|
1628 | * |
---|
1629 | * @param s A C %string to copy. |
---|
1630 | */ |
---|
1631 | language (const C* s) |
---|
1632 | : base_type (s) |
---|
1633 | { |
---|
1634 | } |
---|
1635 | |
---|
1636 | /** |
---|
1637 | * @brief Initialize an instance with a character array. |
---|
1638 | * |
---|
1639 | * @param s A character array to copy. |
---|
1640 | * @param n A number of character to copy. |
---|
1641 | */ |
---|
1642 | language (const C* s, std::size_t n) |
---|
1643 | : base_type (s, n) |
---|
1644 | { |
---|
1645 | } |
---|
1646 | |
---|
1647 | /** |
---|
1648 | * @brief Initialize an instance with multiple copies of the same |
---|
1649 | * character. |
---|
1650 | * |
---|
1651 | * @param n A number of copies to create. |
---|
1652 | * @param c A character to copy. |
---|
1653 | */ |
---|
1654 | language (std::size_t n, C c) |
---|
1655 | : base_type (n, c) |
---|
1656 | { |
---|
1657 | } |
---|
1658 | |
---|
1659 | /** |
---|
1660 | * @brief Initialize an instance with a copy of a standard %string. |
---|
1661 | * |
---|
1662 | * @param s A standard %string to copy. |
---|
1663 | */ |
---|
1664 | language (const std::basic_string<C>& s) |
---|
1665 | : base_type (s) |
---|
1666 | { |
---|
1667 | } |
---|
1668 | |
---|
1669 | /** |
---|
1670 | * @brief Initialize an instance with a copy of a substring. |
---|
1671 | * |
---|
1672 | * @param s A standard %string to copy the substring from. |
---|
1673 | * @param pos An index of the first character to copy from. |
---|
1674 | * @param n A number of characters to copy. |
---|
1675 | */ |
---|
1676 | language (const std::basic_string<C>& s, |
---|
1677 | std::size_t pos, |
---|
1678 | std::size_t n = std::basic_string<C>::npos) |
---|
1679 | : base_type (s, pos, n) |
---|
1680 | { |
---|
1681 | } |
---|
1682 | |
---|
1683 | public: |
---|
1684 | /** |
---|
1685 | * @brief Copy constructor. |
---|
1686 | * |
---|
1687 | * @param x An instance to make a copy of. |
---|
1688 | * @param f Flags to create the copy with. |
---|
1689 | * @param c A pointer to the object that will contain the copy. |
---|
1690 | * |
---|
1691 | * For polymorphic object models use the @c _clone function instead. |
---|
1692 | */ |
---|
1693 | language (const language& x, flags f = 0, container* c = 0) |
---|
1694 | : base_type (x, f, c) |
---|
1695 | { |
---|
1696 | } |
---|
1697 | |
---|
1698 | /** |
---|
1699 | * @brief Copy the instance polymorphically. |
---|
1700 | * |
---|
1701 | * @param f Flags to create the copy with. |
---|
1702 | * @param c A pointer to the object that will contain the copy. |
---|
1703 | * @return A pointer to the dynamically allocated copy. |
---|
1704 | * |
---|
1705 | * This function ensures that the dynamic type of the instance |
---|
1706 | * is used for copying and should be used for polymorphic object |
---|
1707 | * models instead of the copy constructor. |
---|
1708 | */ |
---|
1709 | virtual language* |
---|
1710 | _clone (flags f = 0, container* c = 0) const; |
---|
1711 | |
---|
1712 | public: |
---|
1713 | /** |
---|
1714 | * @brief Create an instance from a data representation |
---|
1715 | * stream. |
---|
1716 | * |
---|
1717 | * @param s A stream to extract the data from. |
---|
1718 | * @param f Flags to create the new instance with. |
---|
1719 | * @param c A pointer to the object that will contain the new |
---|
1720 | * instance. |
---|
1721 | */ |
---|
1722 | template <typename S> |
---|
1723 | language (istream<S>& s, flags f = 0, container* c = 0); |
---|
1724 | |
---|
1725 | /** |
---|
1726 | * @brief Create an instance from a DOM element. |
---|
1727 | * |
---|
1728 | * @param e A DOM element to extract the data from. |
---|
1729 | * @param f Flags to create the new instance with. |
---|
1730 | * @param c A pointer to the object that will contain the new |
---|
1731 | * instance. |
---|
1732 | */ |
---|
1733 | language (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
1734 | |
---|
1735 | /** |
---|
1736 | * @brief Create an instance from a DOM Attribute. |
---|
1737 | * |
---|
1738 | * @param a A DOM attribute to extract the data from. |
---|
1739 | * @param f Flags to create the new instance with. |
---|
1740 | * @param c A pointer to the object that will contain the new |
---|
1741 | * instance. |
---|
1742 | */ |
---|
1743 | language (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
1744 | |
---|
1745 | /** |
---|
1746 | * @brief Create an instance from a %string fragment. |
---|
1747 | * |
---|
1748 | * @param s A %string fragment to extract the data from. |
---|
1749 | * @param e A pointer to DOM element containing the %string fragment. |
---|
1750 | * @param f Flags to create the new instance with. |
---|
1751 | * @param c A pointer to the object that will contain the new |
---|
1752 | * instance. |
---|
1753 | */ |
---|
1754 | language (const std::basic_string<C>& s, |
---|
1755 | const xercesc::DOMElement* e, |
---|
1756 | flags f = 0, |
---|
1757 | container* c = 0); |
---|
1758 | //@} |
---|
1759 | |
---|
1760 | public: |
---|
1761 | /** |
---|
1762 | * @brief Assign a character to the instance. |
---|
1763 | * |
---|
1764 | * The resulting %language has only one character. |
---|
1765 | * |
---|
1766 | * @param c A character to assign. |
---|
1767 | * @return A reference to the instance. |
---|
1768 | */ |
---|
1769 | language& |
---|
1770 | operator= (C c) |
---|
1771 | { |
---|
1772 | base () = c; |
---|
1773 | return *this; |
---|
1774 | } |
---|
1775 | |
---|
1776 | /** |
---|
1777 | * @brief Assign a C %string to the instance. |
---|
1778 | * |
---|
1779 | * The resulting %language contains a copy of the C %string. |
---|
1780 | * |
---|
1781 | * @param s A C %string to assign. |
---|
1782 | * @return A reference to the instance. |
---|
1783 | */ |
---|
1784 | language& |
---|
1785 | operator= (const C* s) |
---|
1786 | { |
---|
1787 | base () = s; |
---|
1788 | return *this; |
---|
1789 | } |
---|
1790 | |
---|
1791 | /** |
---|
1792 | * @brief Assign a standard %string to the instance. |
---|
1793 | * |
---|
1794 | * The resulting %language contains a copy of the standard %string. |
---|
1795 | * |
---|
1796 | * @param s A standard %string to assign. |
---|
1797 | * @return A reference to the instance. |
---|
1798 | */ |
---|
1799 | language& |
---|
1800 | operator= (const std::basic_string<C>& s) |
---|
1801 | { |
---|
1802 | base () = s; |
---|
1803 | return *this; |
---|
1804 | } |
---|
1805 | |
---|
1806 | /** |
---|
1807 | * @brief Copy assignment operator. |
---|
1808 | * |
---|
1809 | * @param x An instance to assign. |
---|
1810 | * @return A reference to the instance. |
---|
1811 | */ |
---|
1812 | language& |
---|
1813 | operator= (const language& x) |
---|
1814 | { |
---|
1815 | base () = x; |
---|
1816 | return *this; |
---|
1817 | } |
---|
1818 | |
---|
1819 | protected: |
---|
1820 | //@cond |
---|
1821 | |
---|
1822 | language () |
---|
1823 | : base_type () |
---|
1824 | { |
---|
1825 | } |
---|
1826 | |
---|
1827 | //@endcond |
---|
1828 | }; |
---|
1829 | |
---|
1830 | |
---|
1831 | //@cond |
---|
1832 | |
---|
1833 | template <typename C, typename ncname> |
---|
1834 | struct identity_impl: identity |
---|
1835 | { |
---|
1836 | identity_impl (const ncname& id) |
---|
1837 | : id_ (id) |
---|
1838 | { |
---|
1839 | } |
---|
1840 | |
---|
1841 | virtual bool |
---|
1842 | before (const identity& y) const; |
---|
1843 | |
---|
1844 | virtual void |
---|
1845 | throw_duplicate_id () const; |
---|
1846 | |
---|
1847 | private: |
---|
1848 | const ncname& id_; |
---|
1849 | }; |
---|
1850 | |
---|
1851 | //@endcond |
---|
1852 | |
---|
1853 | |
---|
1854 | /** |
---|
1855 | * @brief Class corresponding to the XML Schema ID built-in |
---|
1856 | * type. |
---|
1857 | * |
---|
1858 | * The %id class publicly inherits from and has the same set |
---|
1859 | * of constructors as @c std::basic_string. It therefore can be |
---|
1860 | * used as @c std::string (or @c std::wstring if you are using |
---|
1861 | * @c wchar_t as the character type). |
---|
1862 | * |
---|
1863 | * @nosubgrouping |
---|
1864 | */ |
---|
1865 | template <typename C, typename B> |
---|
1866 | class id: public B |
---|
1867 | { |
---|
1868 | typedef B base_type; |
---|
1869 | |
---|
1870 | base_type& |
---|
1871 | base () |
---|
1872 | { |
---|
1873 | return *this; |
---|
1874 | } |
---|
1875 | |
---|
1876 | public: |
---|
1877 | ~id() |
---|
1878 | { |
---|
1879 | unregister_id (); |
---|
1880 | } |
---|
1881 | |
---|
1882 | public: |
---|
1883 | /** |
---|
1884 | * @name Constructors |
---|
1885 | */ |
---|
1886 | //@{ |
---|
1887 | |
---|
1888 | /** |
---|
1889 | * @brief Initialize an instance with a copy of a C %string. |
---|
1890 | * |
---|
1891 | * @param s A C %string to copy. |
---|
1892 | */ |
---|
1893 | id (const C* s) |
---|
1894 | : base_type (s), identity_ (*this) |
---|
1895 | { |
---|
1896 | register_id (); |
---|
1897 | } |
---|
1898 | |
---|
1899 | /** |
---|
1900 | * @brief Initialize an instance with a character array. |
---|
1901 | * |
---|
1902 | * @param s A character array to copy. |
---|
1903 | * @param n A number of character to copy. |
---|
1904 | */ |
---|
1905 | id (const C* s, std::size_t n) |
---|
1906 | : base_type (s, n), identity_ (*this) |
---|
1907 | { |
---|
1908 | register_id (); |
---|
1909 | } |
---|
1910 | |
---|
1911 | /** |
---|
1912 | * @brief Initialize an instance with multiple copies of the same |
---|
1913 | * character. |
---|
1914 | * |
---|
1915 | * @param n A number of copies to create. |
---|
1916 | * @param c A character to copy. |
---|
1917 | */ |
---|
1918 | id (std::size_t n, C c) |
---|
1919 | : base_type (n, c), identity_ (*this) |
---|
1920 | { |
---|
1921 | register_id (); |
---|
1922 | } |
---|
1923 | |
---|
1924 | /** |
---|
1925 | * @brief Initialize an instance with a copy of a standard %string. |
---|
1926 | * |
---|
1927 | * @param s A standard %string to copy. |
---|
1928 | */ |
---|
1929 | id (const std::basic_string<C>& s) |
---|
1930 | : base_type (s), identity_ (*this) |
---|
1931 | { |
---|
1932 | register_id (); |
---|
1933 | } |
---|
1934 | |
---|
1935 | /** |
---|
1936 | * @brief Initialize an instance with a copy of a substring. |
---|
1937 | * |
---|
1938 | * @param s A standard %string to copy the substring from. |
---|
1939 | * @param pos An index of the first character to copy from. |
---|
1940 | * @param n A number of characters to copy. |
---|
1941 | */ |
---|
1942 | id (const std::basic_string<C>& s, |
---|
1943 | std::size_t pos, |
---|
1944 | std::size_t n = std::basic_string<C>::npos) |
---|
1945 | : base_type (s, pos, n), identity_ (*this) |
---|
1946 | { |
---|
1947 | register_id (); |
---|
1948 | } |
---|
1949 | |
---|
1950 | public: |
---|
1951 | /** |
---|
1952 | * @brief Copy constructor. |
---|
1953 | * |
---|
1954 | * @param x An instance to make a copy of. |
---|
1955 | * @param f Flags to create the copy with. |
---|
1956 | * @param c A pointer to the object that will contain the copy. |
---|
1957 | * |
---|
1958 | * For polymorphic object models use the @c _clone function instead. |
---|
1959 | */ |
---|
1960 | id (const id& x, flags f = 0, container* c = 0) |
---|
1961 | : base_type (x, f, c), identity_ (*this) |
---|
1962 | { |
---|
1963 | register_id (); |
---|
1964 | } |
---|
1965 | |
---|
1966 | /** |
---|
1967 | * @brief Copy the instance polymorphically. |
---|
1968 | * |
---|
1969 | * @param f Flags to create the copy with. |
---|
1970 | * @param c A pointer to the object that will contain the copy. |
---|
1971 | * @return A pointer to the dynamically allocated copy. |
---|
1972 | * |
---|
1973 | * This function ensures that the dynamic type of the instance |
---|
1974 | * is used for copying and should be used for polymorphic object |
---|
1975 | * models instead of the copy constructor. |
---|
1976 | */ |
---|
1977 | virtual id* |
---|
1978 | _clone (flags f = 0, container* c = 0) const; |
---|
1979 | |
---|
1980 | public: |
---|
1981 | /** |
---|
1982 | * @brief Create an instance from a data representation |
---|
1983 | * stream. |
---|
1984 | * |
---|
1985 | * @param s A stream to extract the data from. |
---|
1986 | * @param f Flags to create the new instance with. |
---|
1987 | * @param c A pointer to the object that will contain the new |
---|
1988 | * instance. |
---|
1989 | */ |
---|
1990 | template <typename S> |
---|
1991 | id (istream<S>& s, flags f = 0, container* c = 0); |
---|
1992 | |
---|
1993 | /** |
---|
1994 | * @brief Create an instance from a DOM element. |
---|
1995 | * |
---|
1996 | * @param e A DOM element to extract the data from. |
---|
1997 | * @param f Flags to create the new instance with. |
---|
1998 | * @param c A pointer to the object that will contain the new |
---|
1999 | * instance. |
---|
2000 | */ |
---|
2001 | id (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
2002 | |
---|
2003 | /** |
---|
2004 | * @brief Create an instance from a DOM Attribute. |
---|
2005 | * |
---|
2006 | * @param a A DOM attribute to extract the data from. |
---|
2007 | * @param f Flags to create the new instance with. |
---|
2008 | * @param c A pointer to the object that will contain the new |
---|
2009 | * instance. |
---|
2010 | */ |
---|
2011 | id (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
2012 | |
---|
2013 | /** |
---|
2014 | * @brief Create an instance from a %string fragment. |
---|
2015 | * |
---|
2016 | * @param s A %string fragment to extract the data from. |
---|
2017 | * @param e A pointer to DOM element containing the %string fragment. |
---|
2018 | * @param f Flags to create the new instance with. |
---|
2019 | * @param c A pointer to the object that will contain the new |
---|
2020 | * instance. |
---|
2021 | */ |
---|
2022 | id (const std::basic_string<C>& s, |
---|
2023 | const xercesc::DOMElement* e, |
---|
2024 | flags f = 0, |
---|
2025 | container* c = 0); |
---|
2026 | //@} |
---|
2027 | |
---|
2028 | public: |
---|
2029 | /** |
---|
2030 | * @brief Assign a character to the instance. |
---|
2031 | * |
---|
2032 | * The resulting %id has only one character. |
---|
2033 | * |
---|
2034 | * @param c A character to assign. |
---|
2035 | * @return A reference to the instance. |
---|
2036 | */ |
---|
2037 | id& |
---|
2038 | operator= (C c); |
---|
2039 | |
---|
2040 | |
---|
2041 | /** |
---|
2042 | * @brief Assign a C %string to the instance. |
---|
2043 | * |
---|
2044 | * The resulting %id contains a copy of the C %string. |
---|
2045 | * |
---|
2046 | * @param s A C %string to assign. |
---|
2047 | * @return A reference to the instance. |
---|
2048 | */ |
---|
2049 | id& |
---|
2050 | operator= (const C* s); |
---|
2051 | |
---|
2052 | /** |
---|
2053 | * @brief Assign a standard %string to the instance. |
---|
2054 | * |
---|
2055 | * The resulting %id contains a copy of the standard %string. |
---|
2056 | * |
---|
2057 | * @param s A standard %string to assign. |
---|
2058 | * @return A reference to the instance. |
---|
2059 | */ |
---|
2060 | id& |
---|
2061 | operator= (const std::basic_string<C>& s); |
---|
2062 | |
---|
2063 | /** |
---|
2064 | * @brief Copy assignment operator. |
---|
2065 | * |
---|
2066 | * @param x An instance to assign. |
---|
2067 | * @return A reference to the instance. |
---|
2068 | */ |
---|
2069 | id& |
---|
2070 | operator= (const id& x); |
---|
2071 | |
---|
2072 | public: |
---|
2073 | //@cond |
---|
2074 | |
---|
2075 | virtual void |
---|
2076 | _container (container*); |
---|
2077 | |
---|
2078 | // The above override also hides other _container versions. We |
---|
2079 | // also cannot do using-declarations because of bugs in HP aCC3. |
---|
2080 | // |
---|
2081 | const container* |
---|
2082 | _container () const |
---|
2083 | { |
---|
2084 | return B::_container (); |
---|
2085 | } |
---|
2086 | |
---|
2087 | container* |
---|
2088 | _container () |
---|
2089 | { |
---|
2090 | return B::_container (); |
---|
2091 | } |
---|
2092 | |
---|
2093 | //@endcond |
---|
2094 | |
---|
2095 | protected: |
---|
2096 | //@cond |
---|
2097 | |
---|
2098 | id () |
---|
2099 | : base_type (), identity_ (*this) |
---|
2100 | { |
---|
2101 | register_id (); |
---|
2102 | } |
---|
2103 | |
---|
2104 | //@endcond |
---|
2105 | |
---|
2106 | private: |
---|
2107 | void |
---|
2108 | register_id (); |
---|
2109 | |
---|
2110 | void |
---|
2111 | unregister_id (); |
---|
2112 | |
---|
2113 | private: |
---|
2114 | identity_impl<C, B> identity_; |
---|
2115 | }; |
---|
2116 | |
---|
2117 | |
---|
2118 | /** |
---|
2119 | * @brief Class corresponding to the XML Schema IDREF built-in |
---|
2120 | * type. |
---|
2121 | * |
---|
2122 | * The %idref class publicly inherits from and has the same set |
---|
2123 | * of constructors as @c std::basic_string. It therefore can be |
---|
2124 | * used as @c std::string (or @c std::wstring if you are using |
---|
2125 | * @c wchar_t as the character type). |
---|
2126 | * |
---|
2127 | * The %idref class also provides an autopointer-like interface |
---|
2128 | * for resolving referenced objects. By default the object is |
---|
2129 | * returned as type (mapping for anyType) but statically-typed |
---|
2130 | * %idref can be created using the XML Schema extension. See the |
---|
2131 | * C++/Tree Mapping User Manual for more information. |
---|
2132 | * |
---|
2133 | * @nosubgrouping |
---|
2134 | */ |
---|
2135 | template <typename X, typename C, typename B> |
---|
2136 | class idref: public B |
---|
2137 | { |
---|
2138 | typedef B base_type; |
---|
2139 | |
---|
2140 | base_type& |
---|
2141 | base () |
---|
2142 | { |
---|
2143 | return *this; |
---|
2144 | } |
---|
2145 | |
---|
2146 | public: |
---|
2147 | /** |
---|
2148 | * @brief Referenced type. |
---|
2149 | */ |
---|
2150 | typedef X ref_type; |
---|
2151 | |
---|
2152 | public: |
---|
2153 | /** |
---|
2154 | * @name Constructors |
---|
2155 | */ |
---|
2156 | //@{ |
---|
2157 | |
---|
2158 | /** |
---|
2159 | * @brief Initialize an instance with a copy of a C %string. |
---|
2160 | * |
---|
2161 | * @param s A C %string to copy. |
---|
2162 | */ |
---|
2163 | idref (const C* s) |
---|
2164 | : base_type (s), identity_ (*this) |
---|
2165 | { |
---|
2166 | } |
---|
2167 | |
---|
2168 | /** |
---|
2169 | * @brief Initialize an instance with a character array. |
---|
2170 | * |
---|
2171 | * @param s A character array to copy. |
---|
2172 | * @param n A number of character to copy. |
---|
2173 | */ |
---|
2174 | idref (const C* s, std::size_t n) |
---|
2175 | : base_type (s, n), identity_ (*this) |
---|
2176 | { |
---|
2177 | } |
---|
2178 | |
---|
2179 | /** |
---|
2180 | * @brief Initialize an instance with multiple copies of the same |
---|
2181 | * character. |
---|
2182 | * |
---|
2183 | * @param n A number of copies to create. |
---|
2184 | * @param c A character to copy. |
---|
2185 | */ |
---|
2186 | idref (std::size_t n, C c) |
---|
2187 | : base_type (n, c), identity_ (*this) |
---|
2188 | { |
---|
2189 | } |
---|
2190 | |
---|
2191 | /** |
---|
2192 | * @brief Initialize an instance with a copy of a standard %string. |
---|
2193 | * |
---|
2194 | * @param s A standard %string to copy. |
---|
2195 | */ |
---|
2196 | idref (const std::basic_string<C>& s) |
---|
2197 | : base_type (s), identity_ (*this) |
---|
2198 | { |
---|
2199 | } |
---|
2200 | |
---|
2201 | /** |
---|
2202 | * @brief Initialize an instance with a copy of a substring. |
---|
2203 | * |
---|
2204 | * @param s A standard %string to copy the substring from. |
---|
2205 | * @param pos An index of the first character to copy from. |
---|
2206 | * @param n A number of characters to copy. |
---|
2207 | */ |
---|
2208 | idref (const std::basic_string<C>& s, |
---|
2209 | std::size_t pos, |
---|
2210 | std::size_t n = std::basic_string<C>::npos) |
---|
2211 | : base_type (s, pos, n), identity_ (*this) |
---|
2212 | { |
---|
2213 | } |
---|
2214 | |
---|
2215 | public: |
---|
2216 | /** |
---|
2217 | * @brief Copy constructor. |
---|
2218 | * |
---|
2219 | * @param x An instance to make a copy of. |
---|
2220 | * @param f Flags to create the copy with. |
---|
2221 | * @param c A pointer to the object that will contain the copy. |
---|
2222 | * |
---|
2223 | * For polymorphic object models use the @c _clone function instead. |
---|
2224 | */ |
---|
2225 | idref (const idref& x, flags f = 0, container* c = 0) |
---|
2226 | : base_type (x, f, c), identity_ (*this) |
---|
2227 | { |
---|
2228 | } |
---|
2229 | |
---|
2230 | /** |
---|
2231 | * @brief Copy the instance polymorphically. |
---|
2232 | * |
---|
2233 | * @param f Flags to create the copy with. |
---|
2234 | * @param c A pointer to the object that will contain the copy. |
---|
2235 | * @return A pointer to the dynamically allocated copy. |
---|
2236 | * |
---|
2237 | * This function ensures that the dynamic type of the instance |
---|
2238 | * is used for copying and should be used for polymorphic object |
---|
2239 | * models instead of the copy constructor. |
---|
2240 | */ |
---|
2241 | virtual idref* |
---|
2242 | _clone (flags f = 0, container* c = 0) const; |
---|
2243 | |
---|
2244 | public: |
---|
2245 | /** |
---|
2246 | * @brief Create an instance from a data representation |
---|
2247 | * stream. |
---|
2248 | * |
---|
2249 | * @param s A stream to extract the data from. |
---|
2250 | * @param f Flags to create the new instance with. |
---|
2251 | * @param c A pointer to the object that will contain the new |
---|
2252 | * instance. |
---|
2253 | */ |
---|
2254 | template <typename S> |
---|
2255 | idref (istream<S>& s, flags f = 0, container* c = 0); |
---|
2256 | |
---|
2257 | /** |
---|
2258 | * @brief Create an instance from a DOM element. |
---|
2259 | * |
---|
2260 | * @param e A DOM element to extract the data from. |
---|
2261 | * @param f Flags to create the new instance with. |
---|
2262 | * @param c A pointer to the object that will contain the new |
---|
2263 | * instance. |
---|
2264 | */ |
---|
2265 | idref (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
2266 | |
---|
2267 | /** |
---|
2268 | * @brief Create an instance from a DOM Attribute. |
---|
2269 | * |
---|
2270 | * @param a A DOM attribute to extract the data from. |
---|
2271 | * @param f Flags to create the new instance with. |
---|
2272 | * @param c A pointer to the object that will contain the new |
---|
2273 | * instance. |
---|
2274 | */ |
---|
2275 | idref (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
2276 | |
---|
2277 | /** |
---|
2278 | * @brief Create an instance from a %string fragment. |
---|
2279 | * |
---|
2280 | * @param s A %string fragment to extract the data from. |
---|
2281 | * @param e A pointer to DOM element containing the %string fragment. |
---|
2282 | * @param f Flags to create the new instance with. |
---|
2283 | * @param c A pointer to the object that will contain the new |
---|
2284 | * instance. |
---|
2285 | */ |
---|
2286 | idref (const std::basic_string<C>& s, |
---|
2287 | const xercesc::DOMElement* e, |
---|
2288 | flags f = 0, |
---|
2289 | container* c = 0); |
---|
2290 | //@} |
---|
2291 | |
---|
2292 | public: |
---|
2293 | /** |
---|
2294 | * @brief Assign a character to the instance. |
---|
2295 | * |
---|
2296 | * The resulting %idref has only one character. |
---|
2297 | * |
---|
2298 | * @param c A character to assign. |
---|
2299 | * @return A reference to the instance. |
---|
2300 | */ |
---|
2301 | idref& |
---|
2302 | operator= (C c) |
---|
2303 | { |
---|
2304 | base () = c; |
---|
2305 | return *this; |
---|
2306 | } |
---|
2307 | |
---|
2308 | /** |
---|
2309 | * @brief Assign a C %string to the instance. |
---|
2310 | * |
---|
2311 | * The resulting %idref contains a copy of the C %string. |
---|
2312 | * |
---|
2313 | * @param s A C %string to assign. |
---|
2314 | * @return A reference to the instance. |
---|
2315 | */ |
---|
2316 | idref& |
---|
2317 | operator= (const C* s) |
---|
2318 | { |
---|
2319 | base () = s; |
---|
2320 | return *this; |
---|
2321 | } |
---|
2322 | |
---|
2323 | /** |
---|
2324 | * @brief Assign a standard %string to the instance. |
---|
2325 | * |
---|
2326 | * The resulting %idref contains a copy of the standard %string. |
---|
2327 | * |
---|
2328 | * @param s A standard %string to assign. |
---|
2329 | * @return A reference to the instance. |
---|
2330 | */ |
---|
2331 | idref& |
---|
2332 | operator= (const std::basic_string<C>& s) |
---|
2333 | { |
---|
2334 | base () = s; |
---|
2335 | return *this; |
---|
2336 | } |
---|
2337 | |
---|
2338 | /** |
---|
2339 | * @brief Copy assignment operator. |
---|
2340 | * |
---|
2341 | * @param x An instance to assign. |
---|
2342 | * @return A reference to the instance. |
---|
2343 | */ |
---|
2344 | idref& |
---|
2345 | operator= (const idref& x) |
---|
2346 | { |
---|
2347 | base () = x; |
---|
2348 | return *this; |
---|
2349 | } |
---|
2350 | |
---|
2351 | public: |
---|
2352 | /** |
---|
2353 | * @brief Call referenced object. |
---|
2354 | * |
---|
2355 | * @return A constant pointer to the referenced object. |
---|
2356 | */ |
---|
2357 | const ref_type* |
---|
2358 | operator-> () const |
---|
2359 | { |
---|
2360 | return get (); |
---|
2361 | } |
---|
2362 | |
---|
2363 | /** |
---|
2364 | * @brief Call referenced object. |
---|
2365 | * |
---|
2366 | * @return A pointer to the referenced object. |
---|
2367 | */ |
---|
2368 | ref_type* |
---|
2369 | operator-> () |
---|
2370 | { |
---|
2371 | return get (); |
---|
2372 | } |
---|
2373 | |
---|
2374 | /** |
---|
2375 | * @brief Dereference referenced object. |
---|
2376 | * |
---|
2377 | * @return A constant C++ reference to the referenced object. |
---|
2378 | */ |
---|
2379 | const ref_type& |
---|
2380 | operator* () const |
---|
2381 | { |
---|
2382 | return *(get ()); |
---|
2383 | } |
---|
2384 | |
---|
2385 | /** |
---|
2386 | * @brief Dereference referenced object. |
---|
2387 | * |
---|
2388 | * @return A C++ reference to the referenced object. |
---|
2389 | */ |
---|
2390 | ref_type& |
---|
2391 | operator* () |
---|
2392 | { |
---|
2393 | return *(get ()); |
---|
2394 | } |
---|
2395 | |
---|
2396 | /** |
---|
2397 | * @brief Get a constant pointer to the referenced object. |
---|
2398 | * |
---|
2399 | * @return A constant pointer to the referenced object or 0 if |
---|
2400 | * the object is not found. |
---|
2401 | */ |
---|
2402 | const ref_type* |
---|
2403 | get () const |
---|
2404 | { |
---|
2405 | return dynamic_cast<const ref_type*> (get_ ()); |
---|
2406 | } |
---|
2407 | |
---|
2408 | /** |
---|
2409 | * @brief Get a pointer to the referenced object. |
---|
2410 | * |
---|
2411 | * @return A pointer to the referenced object or 0 if the object |
---|
2412 | * is not found. |
---|
2413 | */ |
---|
2414 | ref_type* |
---|
2415 | get () |
---|
2416 | { |
---|
2417 | return dynamic_cast<ref_type*> (get_ ()); |
---|
2418 | } |
---|
2419 | |
---|
2420 | /** |
---|
2421 | * @brief Opaque type that can be evaluated as true or false. |
---|
2422 | */ |
---|
2423 | typedef void (idref::*bool_convertible)(); |
---|
2424 | |
---|
2425 | /** |
---|
2426 | * @brief Implicit conversion to boolean type. |
---|
2427 | * |
---|
2428 | * @return True if the referenced object is found, false otherwise. |
---|
2429 | */ |
---|
2430 | operator bool_convertible () const |
---|
2431 | { |
---|
2432 | return get_ () ? &idref::true_ : 0; |
---|
2433 | } |
---|
2434 | |
---|
2435 | protected: |
---|
2436 | //@cond |
---|
2437 | |
---|
2438 | idref () |
---|
2439 | : base_type (), identity_ (*this) |
---|
2440 | { |
---|
2441 | } |
---|
2442 | |
---|
2443 | //@endcond |
---|
2444 | |
---|
2445 | private: |
---|
2446 | const _type* |
---|
2447 | get_ () const; |
---|
2448 | |
---|
2449 | _type* |
---|
2450 | get_ (); |
---|
2451 | |
---|
2452 | void |
---|
2453 | true_ (); |
---|
2454 | |
---|
2455 | private: |
---|
2456 | identity_impl<C, B> identity_; |
---|
2457 | }; |
---|
2458 | |
---|
2459 | |
---|
2460 | /** |
---|
2461 | * @brief Class corresponding to the XML Schema IDREFS built-in |
---|
2462 | * type. |
---|
2463 | * |
---|
2464 | * The %idrefs class is a vector (or %list in XML Schema terminology) |
---|
2465 | * of idref elements. It is implemented in terms of the list class |
---|
2466 | * template. |
---|
2467 | * |
---|
2468 | * @nosubgrouping |
---|
2469 | */ |
---|
2470 | template <typename C, typename B, typename idref> |
---|
2471 | class idrefs: public B, public list<idref, C> |
---|
2472 | { |
---|
2473 | typedef list<idref, C> base_type; |
---|
2474 | |
---|
2475 | public: |
---|
2476 | /** |
---|
2477 | * @name Constructors |
---|
2478 | */ |
---|
2479 | //@{ |
---|
2480 | |
---|
2481 | /** |
---|
2482 | * @brief Default constructor creates no elements. |
---|
2483 | */ |
---|
2484 | idrefs () |
---|
2485 | { |
---|
2486 | } |
---|
2487 | |
---|
2488 | /** |
---|
2489 | * @brief Initialize the instance with copies of an exemplar elements. |
---|
2490 | * |
---|
2491 | * @param n A number of elements to copy. |
---|
2492 | * @param x An exemplar element to copy. |
---|
2493 | */ |
---|
2494 | idrefs (typename base_type::size_type n, const idref& x) |
---|
2495 | : base_type (n, x) |
---|
2496 | { |
---|
2497 | } |
---|
2498 | |
---|
2499 | /** |
---|
2500 | * @brief Initialize the instance with copies of elements from an |
---|
2501 | * iterator range. |
---|
2502 | * |
---|
2503 | * @param begin An iterator pointing to the first element. |
---|
2504 | * @param end An iterator pointing to the one past the last element. |
---|
2505 | */ |
---|
2506 | template <typename I> |
---|
2507 | idrefs (const I& begin, const I& end) |
---|
2508 | : base_type (begin, end) |
---|
2509 | { |
---|
2510 | } |
---|
2511 | |
---|
2512 | public: |
---|
2513 | /** |
---|
2514 | * @brief Copy constructor. |
---|
2515 | * |
---|
2516 | * @param x An instance to make a copy of. |
---|
2517 | * @param f Flags to create the copy with. |
---|
2518 | * @param c A pointer to the object that will contain the copy. |
---|
2519 | * |
---|
2520 | * For polymorphic object models use the @c _clone function instead. |
---|
2521 | */ |
---|
2522 | idrefs (const idrefs& x, flags f = 0, container* c = 0) |
---|
2523 | : B (x, f, c), base_type (x, f, c) |
---|
2524 | { |
---|
2525 | } |
---|
2526 | |
---|
2527 | /** |
---|
2528 | * @brief Copy the instance polymorphically. |
---|
2529 | * |
---|
2530 | * @param f Flags to create the copy with. |
---|
2531 | * @param c A pointer to the object that will contain the copy. |
---|
2532 | * @return A pointer to the dynamically allocated copy. |
---|
2533 | * |
---|
2534 | * This function ensures that the dynamic type of the instance |
---|
2535 | * is used for copying and should be used for polymorphic object |
---|
2536 | * models instead of the copy constructor. |
---|
2537 | */ |
---|
2538 | virtual idrefs* |
---|
2539 | _clone (flags f = 0, container* c = 0) const; |
---|
2540 | |
---|
2541 | public: |
---|
2542 | /** |
---|
2543 | * @brief Create an instance from a data representation |
---|
2544 | * stream. |
---|
2545 | * |
---|
2546 | * @param s A stream to extract the data from. |
---|
2547 | * @param f Flags to create the new instance with. |
---|
2548 | * @param c A pointer to the object that will contain the new |
---|
2549 | * instance. |
---|
2550 | */ |
---|
2551 | template <typename S> |
---|
2552 | idrefs (istream<S>& s, flags f = 0, container* c = 0); |
---|
2553 | |
---|
2554 | /** |
---|
2555 | * @brief Create an instance from a DOM element. |
---|
2556 | * |
---|
2557 | * @param e A DOM element to extract the data from. |
---|
2558 | * @param f Flags to create the new instance with. |
---|
2559 | * @param c A pointer to the object that will contain the new |
---|
2560 | * instance. |
---|
2561 | */ |
---|
2562 | idrefs (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
2563 | |
---|
2564 | /** |
---|
2565 | * @brief Create an instance from a DOM Attribute. |
---|
2566 | * |
---|
2567 | * @param a A DOM attribute to extract the data from. |
---|
2568 | * @param f Flags to create the new instance with. |
---|
2569 | * @param c A pointer to the object that will contain the new |
---|
2570 | * instance. |
---|
2571 | */ |
---|
2572 | idrefs (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
2573 | |
---|
2574 | /** |
---|
2575 | * @brief Create an instance from a %string fragment. |
---|
2576 | * |
---|
2577 | * @param s A %string fragment to extract the data from. |
---|
2578 | * @param e A pointer to DOM element containing the %string fragment. |
---|
2579 | * @param f Flags to create the new instance with. |
---|
2580 | * @param c A pointer to the object that will contain the new |
---|
2581 | * instance. |
---|
2582 | */ |
---|
2583 | idrefs (const std::basic_string<C>& s, |
---|
2584 | const xercesc::DOMElement* e, |
---|
2585 | flags f = 0, |
---|
2586 | container* c = 0); |
---|
2587 | //@} |
---|
2588 | }; |
---|
2589 | |
---|
2590 | |
---|
2591 | /** |
---|
2592 | * @brief Class corresponding to the XML Schema anyURI built-in |
---|
2593 | * type. |
---|
2594 | * |
---|
2595 | * The %uri class publicly inherits from and has the same set |
---|
2596 | * of constructors as @c std::basic_string. It therefore can be |
---|
2597 | * used as @c std::string (or @c std::wstring if you are using |
---|
2598 | * @c wchar_t as the character type). |
---|
2599 | * |
---|
2600 | * @nosubgrouping |
---|
2601 | */ |
---|
2602 | template <typename C, typename B> |
---|
2603 | class uri: public B, public std::basic_string<C> |
---|
2604 | { |
---|
2605 | typedef std::basic_string<C> base_type; |
---|
2606 | |
---|
2607 | base_type& |
---|
2608 | base () |
---|
2609 | { |
---|
2610 | return *this; |
---|
2611 | } |
---|
2612 | |
---|
2613 | public: |
---|
2614 | /** |
---|
2615 | * @name Constructors |
---|
2616 | */ |
---|
2617 | //@{ |
---|
2618 | |
---|
2619 | /** |
---|
2620 | * @brief Initialize an instance with a copy of a C %string. |
---|
2621 | * |
---|
2622 | * @param s A C %string to copy. |
---|
2623 | */ |
---|
2624 | uri (const C* s) |
---|
2625 | : base_type (s) |
---|
2626 | { |
---|
2627 | } |
---|
2628 | |
---|
2629 | /** |
---|
2630 | * @brief Initialize an instance with a character array. |
---|
2631 | * |
---|
2632 | * @param s A character array to copy. |
---|
2633 | * @param n A number of character to copy. |
---|
2634 | */ |
---|
2635 | uri (const C* s, std::size_t n) |
---|
2636 | : base_type (s, n) |
---|
2637 | { |
---|
2638 | } |
---|
2639 | |
---|
2640 | /** |
---|
2641 | * @brief Initialize an instance with multiple copies of the same |
---|
2642 | * character. |
---|
2643 | * |
---|
2644 | * @param n A number of copies to create. |
---|
2645 | * @param c A character to copy. |
---|
2646 | */ |
---|
2647 | uri (std::size_t n, C c) |
---|
2648 | : base_type (n, c) |
---|
2649 | { |
---|
2650 | } |
---|
2651 | |
---|
2652 | /** |
---|
2653 | * @brief Initialize an instance with a copy of a standard %string. |
---|
2654 | * |
---|
2655 | * @param s A standard %string to copy. |
---|
2656 | */ |
---|
2657 | uri (const std::basic_string<C>& s) |
---|
2658 | : base_type (s) |
---|
2659 | { |
---|
2660 | } |
---|
2661 | |
---|
2662 | /** |
---|
2663 | * @brief Initialize an instance with a copy of a substring. |
---|
2664 | * |
---|
2665 | * @param s A standard %string to copy the substring from. |
---|
2666 | * @param pos An index of the first character to copy from. |
---|
2667 | * @param n A number of characters to copy. |
---|
2668 | */ |
---|
2669 | uri (const std::basic_string<C>& s, |
---|
2670 | std::size_t pos, |
---|
2671 | std::size_t n = std::basic_string<C>::npos) |
---|
2672 | : base_type (s, pos, n) |
---|
2673 | { |
---|
2674 | } |
---|
2675 | |
---|
2676 | public: |
---|
2677 | /** |
---|
2678 | * @brief Copy constructor. |
---|
2679 | * |
---|
2680 | * @param x An instance to make a copy of. |
---|
2681 | * @param f Flags to create the copy with. |
---|
2682 | * @param c A pointer to the object that will contain the copy. |
---|
2683 | * |
---|
2684 | * For polymorphic object models use the @c _clone function instead. |
---|
2685 | */ |
---|
2686 | uri (const uri& x, flags f = 0, container* c = 0) |
---|
2687 | : B (x, f, c), base_type (x) |
---|
2688 | { |
---|
2689 | } |
---|
2690 | |
---|
2691 | /** |
---|
2692 | * @brief Copy the instance polymorphically. |
---|
2693 | * |
---|
2694 | * @param f Flags to create the copy with. |
---|
2695 | * @param c A pointer to the object that will contain the copy. |
---|
2696 | * @return A pointer to the dynamically allocated copy. |
---|
2697 | * |
---|
2698 | * This function ensures that the dynamic type of the instance |
---|
2699 | * is used for copying and should be used for polymorphic object |
---|
2700 | * models instead of the copy constructor. |
---|
2701 | */ |
---|
2702 | virtual uri* |
---|
2703 | _clone (flags f = 0, container* c = 0) const; |
---|
2704 | |
---|
2705 | public: |
---|
2706 | /** |
---|
2707 | * @brief Create an instance from a data representation |
---|
2708 | * stream. |
---|
2709 | * |
---|
2710 | * @param s A stream to extract the data from. |
---|
2711 | * @param f Flags to create the new instance with. |
---|
2712 | * @param c A pointer to the object that will contain the new |
---|
2713 | * instance. |
---|
2714 | */ |
---|
2715 | template <typename S> |
---|
2716 | uri (istream<S>& s, flags f = 0, container* c = 0); |
---|
2717 | |
---|
2718 | /** |
---|
2719 | * @brief Create an instance from a DOM element. |
---|
2720 | * |
---|
2721 | * @param e A DOM element to extract the data from. |
---|
2722 | * @param f Flags to create the new instance with. |
---|
2723 | * @param c A pointer to the object that will contain the new |
---|
2724 | * instance. |
---|
2725 | */ |
---|
2726 | uri (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
2727 | |
---|
2728 | /** |
---|
2729 | * @brief Create an instance from a DOM Attribute. |
---|
2730 | * |
---|
2731 | * @param a A DOM attribute to extract the data from. |
---|
2732 | * @param f Flags to create the new instance with. |
---|
2733 | * @param c A pointer to the object that will contain the new |
---|
2734 | * instance. |
---|
2735 | */ |
---|
2736 | uri (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
2737 | |
---|
2738 | /** |
---|
2739 | * @brief Create an instance from a %string fragment. |
---|
2740 | * |
---|
2741 | * @param s A %string fragment to extract the data from. |
---|
2742 | * @param e A pointer to DOM element containing the %string fragment. |
---|
2743 | * @param f Flags to create the new instance with. |
---|
2744 | * @param c A pointer to the object that will contain the new |
---|
2745 | * instance. |
---|
2746 | */ |
---|
2747 | uri (const std::basic_string<C>& s, |
---|
2748 | const xercesc::DOMElement* e, |
---|
2749 | flags f = 0, |
---|
2750 | container* c = 0); |
---|
2751 | //@} |
---|
2752 | |
---|
2753 | public: |
---|
2754 | /** |
---|
2755 | * @brief Assign a character to the instance. |
---|
2756 | * |
---|
2757 | * The resulting %uri has only one character. |
---|
2758 | * |
---|
2759 | * @param c A character to assign. |
---|
2760 | * @return A reference to the instance. |
---|
2761 | */ |
---|
2762 | uri& |
---|
2763 | operator= (C c) |
---|
2764 | { |
---|
2765 | base () = c; |
---|
2766 | return *this; |
---|
2767 | } |
---|
2768 | |
---|
2769 | /** |
---|
2770 | * @brief Assign a C %string to the instance. |
---|
2771 | * |
---|
2772 | * The resulting %uri contains a copy of the C %string. |
---|
2773 | * |
---|
2774 | * @param s A C %string to assign. |
---|
2775 | * @return A reference to the instance. |
---|
2776 | */ |
---|
2777 | uri& |
---|
2778 | operator= (const C* s) |
---|
2779 | { |
---|
2780 | base () = s; |
---|
2781 | return *this; |
---|
2782 | } |
---|
2783 | |
---|
2784 | /** |
---|
2785 | * @brief Assign a standard %string to the instance. |
---|
2786 | * |
---|
2787 | * The resulting %uri contains a copy of the standard %string. |
---|
2788 | * |
---|
2789 | * @param s A standard %string to assign. |
---|
2790 | * @return A reference to the instance. |
---|
2791 | */ |
---|
2792 | uri& |
---|
2793 | operator= (const std::basic_string<C>& s) |
---|
2794 | { |
---|
2795 | base () = s; |
---|
2796 | return *this; |
---|
2797 | } |
---|
2798 | |
---|
2799 | /** |
---|
2800 | * @brief Copy assignment operator. |
---|
2801 | * |
---|
2802 | * @param x An instance to assign. |
---|
2803 | * @return A reference to the instance. |
---|
2804 | */ |
---|
2805 | uri& |
---|
2806 | operator= (const uri& x) |
---|
2807 | { |
---|
2808 | base () = x; |
---|
2809 | return *this; |
---|
2810 | } |
---|
2811 | |
---|
2812 | protected: |
---|
2813 | //@cond |
---|
2814 | |
---|
2815 | uri () |
---|
2816 | : base_type () |
---|
2817 | { |
---|
2818 | } |
---|
2819 | |
---|
2820 | //@endcond |
---|
2821 | |
---|
2822 | template <typename, typename, typename, typename> |
---|
2823 | friend class qname; |
---|
2824 | }; |
---|
2825 | |
---|
2826 | |
---|
2827 | /** |
---|
2828 | * @brief Class corresponding to the XML Schema QName built-in |
---|
2829 | * type. |
---|
2830 | * |
---|
2831 | * The %qname class represents a potentially namespace-qualified |
---|
2832 | * XML %name. |
---|
2833 | * |
---|
2834 | * @nosubgrouping |
---|
2835 | */ |
---|
2836 | template <typename C, typename B, typename uri, typename ncname> |
---|
2837 | class qname: public B |
---|
2838 | { |
---|
2839 | public: |
---|
2840 | /** |
---|
2841 | * @name Constructors |
---|
2842 | */ |
---|
2843 | //@{ |
---|
2844 | |
---|
2845 | /** |
---|
2846 | * @brief Initialize an instance with a %name only. |
---|
2847 | * |
---|
2848 | * The resulting %qname is unqualified. |
---|
2849 | * |
---|
2850 | * @param n An XML %name (ncname). |
---|
2851 | */ |
---|
2852 | qname (const ncname& n) |
---|
2853 | : ns_ (), name_ (n) |
---|
2854 | { |
---|
2855 | } |
---|
2856 | |
---|
2857 | /** |
---|
2858 | * @brief Initialize an instance with a %name and a namespace. |
---|
2859 | * |
---|
2860 | * The resulting %qname is qualified. |
---|
2861 | * |
---|
2862 | * @param ns An XML namespace (uri). |
---|
2863 | * @param n An XML %name (ncname). |
---|
2864 | */ |
---|
2865 | qname (const uri& ns, const ncname& n) |
---|
2866 | : ns_ (ns), name_ (n) |
---|
2867 | { |
---|
2868 | } |
---|
2869 | |
---|
2870 | public: |
---|
2871 | /** |
---|
2872 | * @brief Copy constructor. |
---|
2873 | * |
---|
2874 | * @param x An instance to make a copy of. |
---|
2875 | * @param f Flags to create the copy with. |
---|
2876 | * @param c A pointer to the object that will contain the copy. |
---|
2877 | * |
---|
2878 | * For polymorphic object models use the @c _clone function instead. |
---|
2879 | */ |
---|
2880 | qname (const qname& x, flags f = 0, container* c = 0) |
---|
2881 | : B (x, f, c), |
---|
2882 | ns_ (x.ns_), |
---|
2883 | name_ (x.name_) |
---|
2884 | { |
---|
2885 | // Note that ns_ and name_ have no DOM association. |
---|
2886 | // |
---|
2887 | } |
---|
2888 | |
---|
2889 | /** |
---|
2890 | * @brief Copy the instance polymorphically. |
---|
2891 | * |
---|
2892 | * @param f Flags to create the copy with. |
---|
2893 | * @param c A pointer to the object that will contain the copy. |
---|
2894 | * @return A pointer to the dynamically allocated copy. |
---|
2895 | * |
---|
2896 | * This function ensures that the dynamic type of the instance |
---|
2897 | * is used for copying and should be used for polymorphic object |
---|
2898 | * models instead of the copy constructor. |
---|
2899 | */ |
---|
2900 | virtual qname* |
---|
2901 | _clone (flags f = 0, container* c = 0) const; |
---|
2902 | |
---|
2903 | public: |
---|
2904 | /** |
---|
2905 | * @brief Create an instance from a data representation |
---|
2906 | * stream. |
---|
2907 | * |
---|
2908 | * @param s A stream to extract the data from. |
---|
2909 | * @param f Flags to create the new instance with. |
---|
2910 | * @param c A pointer to the object that will contain the new |
---|
2911 | * instance. |
---|
2912 | */ |
---|
2913 | template <typename S> |
---|
2914 | qname (istream<S>& s, flags f = 0, container* c = 0); |
---|
2915 | |
---|
2916 | /** |
---|
2917 | * @brief Create an instance from a DOM element. |
---|
2918 | * |
---|
2919 | * @param e A DOM element to extract the data from. |
---|
2920 | * @param f Flags to create the new instance with. |
---|
2921 | * @param c A pointer to the object that will contain the new |
---|
2922 | * instance. |
---|
2923 | */ |
---|
2924 | qname (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
2925 | |
---|
2926 | /** |
---|
2927 | * @brief Create an instance from a DOM Attribute. |
---|
2928 | * |
---|
2929 | * @param a A DOM attribute to extract the data from. |
---|
2930 | * @param f Flags to create the new instance with. |
---|
2931 | * @param c A pointer to the object that will contain the new |
---|
2932 | * instance. |
---|
2933 | */ |
---|
2934 | qname (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
2935 | |
---|
2936 | /** |
---|
2937 | * @brief Create an instance from a %string fragment. |
---|
2938 | * |
---|
2939 | * @param s A %string fragment to extract the data from. |
---|
2940 | * @param e A pointer to DOM element containing the %string fragment. |
---|
2941 | * @param f Flags to create the new instance with. |
---|
2942 | * @param c A pointer to the object that will contain the new |
---|
2943 | * instance. |
---|
2944 | */ |
---|
2945 | qname (const std::basic_string<C>& s, |
---|
2946 | const xercesc::DOMElement* e, |
---|
2947 | flags f = 0, |
---|
2948 | container* c = 0); |
---|
2949 | //@} |
---|
2950 | |
---|
2951 | public: |
---|
2952 | /** |
---|
2953 | * @brief Determine if the %name is qualified. |
---|
2954 | * |
---|
2955 | * @return True if the %name is qualified, false otherwise. |
---|
2956 | */ |
---|
2957 | bool |
---|
2958 | qualified () const |
---|
2959 | { |
---|
2960 | return !ns_.empty (); |
---|
2961 | } |
---|
2962 | |
---|
2963 | /** |
---|
2964 | * @brief Get XML namespace. |
---|
2965 | * |
---|
2966 | * @return A constant reference to qualifying XML namespace. |
---|
2967 | */ |
---|
2968 | const uri& |
---|
2969 | namespace_ () const |
---|
2970 | { |
---|
2971 | return ns_; |
---|
2972 | } |
---|
2973 | |
---|
2974 | /** |
---|
2975 | * @brief Get XML %name. |
---|
2976 | * |
---|
2977 | * @return A constant reference to unqualified XML %name. |
---|
2978 | */ |
---|
2979 | const ncname& |
---|
2980 | name () const |
---|
2981 | { |
---|
2982 | return name_; |
---|
2983 | } |
---|
2984 | |
---|
2985 | protected: |
---|
2986 | //@cond |
---|
2987 | |
---|
2988 | qname () |
---|
2989 | : ns_ (), name_ () |
---|
2990 | { |
---|
2991 | } |
---|
2992 | |
---|
2993 | //@endcond |
---|
2994 | |
---|
2995 | private: |
---|
2996 | static uri |
---|
2997 | resolve (const std::basic_string<C>&, const xercesc::DOMElement*); |
---|
2998 | |
---|
2999 | private: |
---|
3000 | uri ns_; |
---|
3001 | ncname name_; |
---|
3002 | }; |
---|
3003 | |
---|
3004 | /** |
---|
3005 | * @brief %qname comparison operator. |
---|
3006 | * |
---|
3007 | * @return True if the names are equal, false otherwise. |
---|
3008 | */ |
---|
3009 | template <typename C, typename B, typename uri, typename ncname> |
---|
3010 | inline bool |
---|
3011 | operator== (const qname<C, B, uri, ncname>& a, |
---|
3012 | const qname<C, B, uri, ncname>& b) |
---|
3013 | { |
---|
3014 | return a.name () == b.name () && a.namespace_ () == b.namespace_ (); |
---|
3015 | } |
---|
3016 | |
---|
3017 | /** |
---|
3018 | * @brief %qname comparison operator. |
---|
3019 | * |
---|
3020 | * @return True if the names are not equal, false otherwise. |
---|
3021 | */ |
---|
3022 | template <typename C, typename B, typename uri, typename ncname> |
---|
3023 | inline bool |
---|
3024 | operator!= (const qname<C, B, uri, ncname>& a, |
---|
3025 | const qname<C, B, uri, ncname>& b) |
---|
3026 | { |
---|
3027 | return !(a == b); |
---|
3028 | } |
---|
3029 | |
---|
3030 | |
---|
3031 | /** |
---|
3032 | * @brief Class corresponding to the XML Schema base64Binary |
---|
3033 | * built-in type. |
---|
3034 | * |
---|
3035 | * The %base64_binary class is a binary %buffer abstraction with |
---|
3036 | * base64-encoded representation in XML. It publicly inherits from |
---|
3037 | * the buffer class which provides the %buffer functionality. |
---|
3038 | * |
---|
3039 | * @nosubgrouping |
---|
3040 | */ |
---|
3041 | template <typename C, typename B> |
---|
3042 | class base64_binary: public B, public buffer<C> |
---|
3043 | { |
---|
3044 | public: |
---|
3045 | typedef typename buffer<C>::size_t size_t; |
---|
3046 | |
---|
3047 | public: |
---|
3048 | /** |
---|
3049 | * @name Constructors |
---|
3050 | */ |
---|
3051 | //@{ |
---|
3052 | |
---|
3053 | /** |
---|
3054 | * @brief Allocate a %buffer of the specified size. |
---|
3055 | * |
---|
3056 | * The resulting %buffer has the same size and capacity. |
---|
3057 | * |
---|
3058 | * @param size A %buffer size in bytes. |
---|
3059 | */ |
---|
3060 | explicit |
---|
3061 | base64_binary (size_t size = 0); |
---|
3062 | |
---|
3063 | /** |
---|
3064 | * @brief Allocate a %buffer of the specified size and capacity. |
---|
3065 | * |
---|
3066 | * @param size A %buffer size in bytes. |
---|
3067 | * @param capacity A %buffer capacity in bytes. |
---|
3068 | * @throw bounds If @a size exceeds @a capacity |
---|
3069 | */ |
---|
3070 | base64_binary (size_t size, size_t capacity); |
---|
3071 | |
---|
3072 | /** |
---|
3073 | * @brief Allocate a %buffer of the specified size and copy |
---|
3074 | * the data. |
---|
3075 | * |
---|
3076 | * The resulting %buffer has the same size and capacity with |
---|
3077 | * @a size bytes copied from @a data. |
---|
3078 | * |
---|
3079 | * @param data A %buffer to copy the data from. |
---|
3080 | * @param size A %buffer size in bytes. |
---|
3081 | */ |
---|
3082 | base64_binary (const void* data, size_t size); |
---|
3083 | |
---|
3084 | /** |
---|
3085 | * @brief Allocate a %buffer of the specified size and capacity |
---|
3086 | * and copy the data. |
---|
3087 | * |
---|
3088 | * @a size bytes are copied from @a data to the resulting |
---|
3089 | * %buffer. |
---|
3090 | * |
---|
3091 | * @param data A %buffer to copy the data from. |
---|
3092 | * @param size A %buffer size in bytes. |
---|
3093 | * @param capacity A %buffer capacity in bytes. |
---|
3094 | * @throw bounds If @a size exceeds @a capacity |
---|
3095 | */ |
---|
3096 | base64_binary (const void* data, size_t size, size_t capacity); |
---|
3097 | |
---|
3098 | /** |
---|
3099 | * @brief Assume ownership of the specified %buffer. |
---|
3100 | * |
---|
3101 | * If the @a assume_ownership argument is true, the %buffer will |
---|
3102 | * assume ownership of @a data and will release the memory |
---|
3103 | * by calling @c operator @c delete(). |
---|
3104 | * |
---|
3105 | * @param data A %buffer to assume ownership of. |
---|
3106 | * @param size A %buffer size in bytes. |
---|
3107 | * @param capacity A %buffer capacity in bytes. |
---|
3108 | * @param assume_ownership A boolean value indication whether to |
---|
3109 | * assume ownership. |
---|
3110 | * @throw bounds If @a size exceeds @a capacity |
---|
3111 | */ |
---|
3112 | base64_binary (void* data, |
---|
3113 | size_t size, |
---|
3114 | size_t capacity, |
---|
3115 | bool assume_ownership); |
---|
3116 | public: |
---|
3117 | /** |
---|
3118 | * @brief Copy constructor. |
---|
3119 | * |
---|
3120 | * @param x An instance to make a copy of. |
---|
3121 | * @param f Flags to create the copy with. |
---|
3122 | * @param c A pointer to the object that will contain the copy. |
---|
3123 | * |
---|
3124 | * For polymorphic object models use the @c _clone function instead. |
---|
3125 | */ |
---|
3126 | base64_binary (const base64_binary& x, |
---|
3127 | flags f = 0, |
---|
3128 | container* c = 0) |
---|
3129 | : B (x, f, c), buffer<C> (x) |
---|
3130 | { |
---|
3131 | } |
---|
3132 | |
---|
3133 | /** |
---|
3134 | * @brief Copy the instance polymorphically. |
---|
3135 | * |
---|
3136 | * @param f Flags to create the copy with. |
---|
3137 | * @param c A pointer to the object that will contain the copy. |
---|
3138 | * @return A pointer to the dynamically allocated copy. |
---|
3139 | * |
---|
3140 | * This function ensures that the dynamic type of the instance |
---|
3141 | * is used for copying and should be used for polymorphic object |
---|
3142 | * models instead of the copy constructor. |
---|
3143 | */ |
---|
3144 | virtual base64_binary* |
---|
3145 | _clone (flags f = 0, container* c = 0) const; |
---|
3146 | |
---|
3147 | public: |
---|
3148 | /** |
---|
3149 | * @brief Create an instance from a data representation |
---|
3150 | * stream. |
---|
3151 | * |
---|
3152 | * @param s A stream to extract the data from. |
---|
3153 | * @param f Flags to create the new instance with. |
---|
3154 | * @param c A pointer to the object that will contain the new |
---|
3155 | * instance. |
---|
3156 | */ |
---|
3157 | template <typename S> |
---|
3158 | base64_binary (istream<S>& s, flags f = 0, container* c = 0); |
---|
3159 | |
---|
3160 | /** |
---|
3161 | * @brief Create an instance from a DOM element. |
---|
3162 | * |
---|
3163 | * @param e A DOM element to extract the data from. |
---|
3164 | * @param f Flags to create the new instance with. |
---|
3165 | * @param c A pointer to the object that will contain the new |
---|
3166 | * instance. |
---|
3167 | */ |
---|
3168 | base64_binary (const xercesc::DOMElement& e, |
---|
3169 | flags f = 0, |
---|
3170 | container* c = 0); |
---|
3171 | |
---|
3172 | /** |
---|
3173 | * @brief Create an instance from a DOM Attribute. |
---|
3174 | * |
---|
3175 | * @param a A DOM attribute to extract the data from. |
---|
3176 | * @param f Flags to create the new instance with. |
---|
3177 | * @param c A pointer to the object that will contain the new |
---|
3178 | * instance. |
---|
3179 | */ |
---|
3180 | base64_binary (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
3181 | |
---|
3182 | /** |
---|
3183 | * @brief Create an instance from a %string fragment. |
---|
3184 | * |
---|
3185 | * @param s A %string fragment to extract the data from. |
---|
3186 | * @param e A pointer to DOM element containing the %string fragment. |
---|
3187 | * @param f Flags to create the new instance with. |
---|
3188 | * @param c A pointer to the object that will contain the new |
---|
3189 | * instance. |
---|
3190 | */ |
---|
3191 | base64_binary (const std::basic_string<C>& s, |
---|
3192 | const xercesc::DOMElement* e, |
---|
3193 | flags f = 0, |
---|
3194 | container* c = 0); |
---|
3195 | //@} |
---|
3196 | |
---|
3197 | public: |
---|
3198 | /** |
---|
3199 | * @brief Copy assignment operator. |
---|
3200 | * |
---|
3201 | * @param x An instance to assign. |
---|
3202 | * @return A reference to the instance. |
---|
3203 | */ |
---|
3204 | base64_binary& |
---|
3205 | operator= (const base64_binary& x) |
---|
3206 | { |
---|
3207 | buffer<C>& b (*this); |
---|
3208 | b = x; |
---|
3209 | return *this; |
---|
3210 | } |
---|
3211 | |
---|
3212 | public: |
---|
3213 | /** |
---|
3214 | * @brief Encode the %buffer in base64 encoding. |
---|
3215 | * |
---|
3216 | * @return A %string with base64-encoded data. |
---|
3217 | */ |
---|
3218 | std::basic_string<C> |
---|
3219 | encode () const; |
---|
3220 | |
---|
3221 | private: |
---|
3222 | void |
---|
3223 | decode (const XMLCh*); |
---|
3224 | }; |
---|
3225 | |
---|
3226 | |
---|
3227 | /** |
---|
3228 | * @brief Class corresponding to the XML Schema hexBinary |
---|
3229 | * built-in type. |
---|
3230 | * |
---|
3231 | * The %hex_binary class is a binary %buffer abstraction with |
---|
3232 | * hex-encoded representation in XML. It publicly inherits from |
---|
3233 | * the buffer class which provides the %buffer functionality. |
---|
3234 | * |
---|
3235 | * @nosubgrouping |
---|
3236 | */ |
---|
3237 | template <typename C, typename B> |
---|
3238 | class hex_binary: public B, public buffer<C> |
---|
3239 | { |
---|
3240 | public: |
---|
3241 | typedef typename buffer<C>::size_t size_t; |
---|
3242 | |
---|
3243 | public: |
---|
3244 | /** |
---|
3245 | * @name Constructors |
---|
3246 | */ |
---|
3247 | //@{ |
---|
3248 | |
---|
3249 | /** |
---|
3250 | * @brief Allocate a %buffer of the specified size. |
---|
3251 | * |
---|
3252 | * The resulting %buffer has the same size and capacity. |
---|
3253 | * |
---|
3254 | * @param size A %buffer size in bytes. |
---|
3255 | */ |
---|
3256 | explicit |
---|
3257 | hex_binary (size_t size = 0); |
---|
3258 | |
---|
3259 | /** |
---|
3260 | * @brief Allocate a %buffer of the specified size and capacity. |
---|
3261 | * |
---|
3262 | * @param size A %buffer size in bytes. |
---|
3263 | * @param capacity A %buffer capacity in bytes. |
---|
3264 | * @throw bounds If @a size exceeds @a capacity |
---|
3265 | */ |
---|
3266 | hex_binary (size_t size, size_t capacity); |
---|
3267 | |
---|
3268 | /** |
---|
3269 | * @brief Allocate a %buffer of the specified size and copy |
---|
3270 | * the data. |
---|
3271 | * |
---|
3272 | * The resulting %buffer has the same size and capacity with |
---|
3273 | * @a size bytes copied from @a data. |
---|
3274 | * |
---|
3275 | * @param data A %buffer to copy the data from. |
---|
3276 | * @param size A %buffer size in bytes. |
---|
3277 | */ |
---|
3278 | hex_binary (const void* data, size_t size); |
---|
3279 | |
---|
3280 | /** |
---|
3281 | * @brief Allocate a %buffer of the specified size and capacity |
---|
3282 | * and copy the data. |
---|
3283 | * |
---|
3284 | * @a size bytes are copied from @a data to the resulting |
---|
3285 | * %buffer. |
---|
3286 | * |
---|
3287 | * @param data A %buffer to copy the data from. |
---|
3288 | * @param size A %buffer size in bytes. |
---|
3289 | * @param capacity A %buffer capacity in bytes. |
---|
3290 | * @throw bounds If @a size exceeds @a capacity |
---|
3291 | */ |
---|
3292 | hex_binary (const void* data, size_t size, size_t capacity); |
---|
3293 | |
---|
3294 | /** |
---|
3295 | * @brief Assume ownership of the specified %buffer. |
---|
3296 | * |
---|
3297 | * If the @a assume_ownership argument is true, the %buffer will |
---|
3298 | * assume ownership of @a data and will release the memory |
---|
3299 | * by calling @c operator @c delete(). |
---|
3300 | * |
---|
3301 | * @param data A %buffer to assume ownership of. |
---|
3302 | * @param size A %buffer size in bytes. |
---|
3303 | * @param capacity A %buffer capacity in bytes. |
---|
3304 | * @param assume_ownership A boolean value indication whether to |
---|
3305 | * assume ownership. |
---|
3306 | * @throw bounds If @a size exceeds @a capacity |
---|
3307 | */ |
---|
3308 | hex_binary (void* data, |
---|
3309 | size_t size, |
---|
3310 | size_t capacity, |
---|
3311 | bool assume_ownership); |
---|
3312 | |
---|
3313 | public: |
---|
3314 | /** |
---|
3315 | * @brief Copy constructor. |
---|
3316 | * |
---|
3317 | * @param x An instance to make a copy of. |
---|
3318 | * @param f Flags to create the copy with. |
---|
3319 | * @param c A pointer to the object that will contain the copy. |
---|
3320 | * |
---|
3321 | * For polymorphic object models use the @c _clone function instead. |
---|
3322 | */ |
---|
3323 | hex_binary (const hex_binary& x, flags f = 0, container* c = 0) |
---|
3324 | : B (x, f, c), buffer<C> (x) |
---|
3325 | { |
---|
3326 | } |
---|
3327 | |
---|
3328 | /** |
---|
3329 | * @brief Copy the instance polymorphically. |
---|
3330 | * |
---|
3331 | * @param f Flags to create the copy with. |
---|
3332 | * @param c A pointer to the object that will contain the copy. |
---|
3333 | * @return A pointer to the dynamically allocated copy. |
---|
3334 | * |
---|
3335 | * This function ensures that the dynamic type of the instance |
---|
3336 | * is used for copying and should be used for polymorphic object |
---|
3337 | * models instead of the copy constructor. |
---|
3338 | */ |
---|
3339 | virtual hex_binary* |
---|
3340 | _clone (flags f = 0, container* c = 0) const; |
---|
3341 | |
---|
3342 | public: |
---|
3343 | /** |
---|
3344 | * @brief Create an instance from a data representation |
---|
3345 | * stream. |
---|
3346 | * |
---|
3347 | * @param s A stream to extract the data from. |
---|
3348 | * @param f Flags to create the new instance with. |
---|
3349 | * @param c A pointer to the object that will contain the new |
---|
3350 | * instance. |
---|
3351 | */ |
---|
3352 | template <typename S> |
---|
3353 | hex_binary (istream<S>& s, flags f = 0, container* c = 0); |
---|
3354 | |
---|
3355 | /** |
---|
3356 | * @brief Create an instance from a DOM element. |
---|
3357 | * |
---|
3358 | * @param e A DOM element to extract the data from. |
---|
3359 | * @param f Flags to create the new instance with. |
---|
3360 | * @param c A pointer to the object that will contain the new |
---|
3361 | * instance. |
---|
3362 | */ |
---|
3363 | hex_binary (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
3364 | |
---|
3365 | /** |
---|
3366 | * @brief Create an instance from a DOM Attribute. |
---|
3367 | * |
---|
3368 | * @param a A DOM attribute to extract the data from. |
---|
3369 | * @param f Flags to create the new instance with. |
---|
3370 | * @param c A pointer to the object that will contain the new |
---|
3371 | * instance. |
---|
3372 | */ |
---|
3373 | hex_binary (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
3374 | |
---|
3375 | /** |
---|
3376 | * @brief Create an instance from a %string fragment. |
---|
3377 | * |
---|
3378 | * @param s A %string fragment to extract the data from. |
---|
3379 | * @param e A pointer to DOM element containing the %string fragment. |
---|
3380 | * @param f Flags to create the new instance with. |
---|
3381 | * @param c A pointer to the object that will contain the new |
---|
3382 | * instance. |
---|
3383 | */ |
---|
3384 | hex_binary (const std::basic_string<C>& s, |
---|
3385 | const xercesc::DOMElement* e, |
---|
3386 | flags f = 0, |
---|
3387 | container* c = 0); |
---|
3388 | //@} |
---|
3389 | |
---|
3390 | public: |
---|
3391 | /** |
---|
3392 | * @brief Copy assignment operator. |
---|
3393 | * |
---|
3394 | * @param x An instance to assign. |
---|
3395 | * @return A reference to the instance. |
---|
3396 | */ |
---|
3397 | hex_binary& |
---|
3398 | operator= (const hex_binary& x) |
---|
3399 | { |
---|
3400 | buffer<C>& b (*this); |
---|
3401 | b = x; |
---|
3402 | return *this; |
---|
3403 | } |
---|
3404 | |
---|
3405 | public: |
---|
3406 | /** |
---|
3407 | * @brief Encode the %buffer in hex encoding. |
---|
3408 | * |
---|
3409 | * @return A %string with hex-encoded data. |
---|
3410 | */ |
---|
3411 | std::basic_string<C> |
---|
3412 | encode () const; |
---|
3413 | |
---|
3414 | private: |
---|
3415 | void |
---|
3416 | decode (const XMLCh*); |
---|
3417 | }; |
---|
3418 | |
---|
3419 | |
---|
3420 | /** |
---|
3421 | * @brief Class corresponding to the XML Schema ENTITY built-in |
---|
3422 | * type. |
---|
3423 | * |
---|
3424 | * The %entity class publicly inherits from and has the same set |
---|
3425 | * of constructors as @c std::basic_string. It therefore can be |
---|
3426 | * used as @c std::string (or @c std::wstring if you are using |
---|
3427 | * @c wchar_t as the character type). |
---|
3428 | * |
---|
3429 | * @nosubgrouping |
---|
3430 | */ |
---|
3431 | template <typename C, typename B> |
---|
3432 | class entity: public B |
---|
3433 | { |
---|
3434 | typedef B base_type; |
---|
3435 | |
---|
3436 | base_type& |
---|
3437 | base () |
---|
3438 | { |
---|
3439 | return *this; |
---|
3440 | } |
---|
3441 | |
---|
3442 | public: |
---|
3443 | /** |
---|
3444 | * @name Constructors |
---|
3445 | */ |
---|
3446 | //@{ |
---|
3447 | |
---|
3448 | /** |
---|
3449 | * @brief Initialize an instance with a copy of a C %string. |
---|
3450 | * |
---|
3451 | * @param s A C %string to copy. |
---|
3452 | */ |
---|
3453 | entity (const C* s) |
---|
3454 | : base_type (s) |
---|
3455 | { |
---|
3456 | } |
---|
3457 | |
---|
3458 | /** |
---|
3459 | * @brief Initialize an instance with a character array. |
---|
3460 | * |
---|
3461 | * @param s A character array to copy. |
---|
3462 | * @param n A number of character to copy. |
---|
3463 | */ |
---|
3464 | entity (const C* s, std::size_t n) |
---|
3465 | : base_type (s, n) |
---|
3466 | { |
---|
3467 | } |
---|
3468 | |
---|
3469 | /** |
---|
3470 | * @brief Initialize an instance with multiple copies of the same |
---|
3471 | * character. |
---|
3472 | * |
---|
3473 | * @param n A number of copies to create. |
---|
3474 | * @param c A character to copy. |
---|
3475 | */ |
---|
3476 | entity (std::size_t n, C c) |
---|
3477 | : base_type (n, c) |
---|
3478 | { |
---|
3479 | } |
---|
3480 | |
---|
3481 | /** |
---|
3482 | * @brief Initialize an instance with a copy of a standard %string. |
---|
3483 | * |
---|
3484 | * @param s A standard %string to copy. |
---|
3485 | */ |
---|
3486 | entity (const std::basic_string<C>& s) |
---|
3487 | : base_type (s) |
---|
3488 | { |
---|
3489 | } |
---|
3490 | |
---|
3491 | /** |
---|
3492 | * @brief Initialize an instance with a copy of a substring. |
---|
3493 | * |
---|
3494 | * @param s A standard %string to copy the substring from. |
---|
3495 | * @param pos An index of the first character to copy from. |
---|
3496 | * @param n A number of characters to copy. |
---|
3497 | */ |
---|
3498 | entity (const std::basic_string<C>& s, |
---|
3499 | std::size_t pos, |
---|
3500 | std::size_t n = std::basic_string<C>::npos) |
---|
3501 | : base_type (s, pos, n) |
---|
3502 | { |
---|
3503 | } |
---|
3504 | |
---|
3505 | public: |
---|
3506 | /** |
---|
3507 | * @brief Copy constructor. |
---|
3508 | * |
---|
3509 | * @param x An instance to make a copy of. |
---|
3510 | * @param f Flags to create the copy with. |
---|
3511 | * @param c A pointer to the object that will contain the copy. |
---|
3512 | * |
---|
3513 | * For polymorphic object models use the @c _clone function instead. |
---|
3514 | */ |
---|
3515 | entity (const entity& x, flags f = 0, container* c = 0) |
---|
3516 | : base_type (x, f, c) |
---|
3517 | { |
---|
3518 | } |
---|
3519 | |
---|
3520 | /** |
---|
3521 | * @brief Copy the instance polymorphically. |
---|
3522 | * |
---|
3523 | * @param f Flags to create the copy with. |
---|
3524 | * @param c A pointer to the object that will contain the copy. |
---|
3525 | * @return A pointer to the dynamically allocated copy. |
---|
3526 | * |
---|
3527 | * This function ensures that the dynamic type of the instance |
---|
3528 | * is used for copying and should be used for polymorphic object |
---|
3529 | * models instead of the copy constructor. |
---|
3530 | */ |
---|
3531 | virtual entity* |
---|
3532 | _clone (flags f = 0, container* c = 0) const; |
---|
3533 | |
---|
3534 | public: |
---|
3535 | /** |
---|
3536 | * @brief Create an instance from a data representation |
---|
3537 | * stream. |
---|
3538 | * |
---|
3539 | * @param s A stream to extract the data from. |
---|
3540 | * @param f Flags to create the new instance with. |
---|
3541 | * @param c A pointer to the object that will contain the new |
---|
3542 | * instance. |
---|
3543 | */ |
---|
3544 | template <typename S> |
---|
3545 | entity (istream<S>& s, flags f = 0, container* c = 0); |
---|
3546 | |
---|
3547 | /** |
---|
3548 | * @brief Create an instance from a DOM element. |
---|
3549 | * |
---|
3550 | * @param e A DOM element to extract the data from. |
---|
3551 | * @param f Flags to create the new instance with. |
---|
3552 | * @param c A pointer to the object that will contain the new |
---|
3553 | * instance. |
---|
3554 | */ |
---|
3555 | entity (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
3556 | |
---|
3557 | /** |
---|
3558 | * @brief Create an instance from a DOM Attribute. |
---|
3559 | * |
---|
3560 | * @param a A DOM attribute to extract the data from. |
---|
3561 | * @param f Flags to create the new instance with. |
---|
3562 | * @param c A pointer to the object that will contain the new |
---|
3563 | * instance. |
---|
3564 | */ |
---|
3565 | entity (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
3566 | |
---|
3567 | /** |
---|
3568 | * @brief Create an instance from a %string fragment. |
---|
3569 | * |
---|
3570 | * @param s A %string fragment to extract the data from. |
---|
3571 | * @param e A pointer to DOM element containing the %string fragment. |
---|
3572 | * @param f Flags to create the new instance with. |
---|
3573 | * @param c A pointer to the object that will contain the new |
---|
3574 | * instance. |
---|
3575 | */ |
---|
3576 | entity (const std::basic_string<C>& s, |
---|
3577 | const xercesc::DOMElement* e, |
---|
3578 | flags f = 0, |
---|
3579 | container* c = 0); |
---|
3580 | //@} |
---|
3581 | |
---|
3582 | public: |
---|
3583 | /** |
---|
3584 | * @brief Assign a character to the instance. |
---|
3585 | * |
---|
3586 | * The resulting %entity has only one character. |
---|
3587 | * |
---|
3588 | * @param c A character to assign. |
---|
3589 | * @return A reference to the instance. |
---|
3590 | */ |
---|
3591 | entity& |
---|
3592 | operator= (C c) |
---|
3593 | { |
---|
3594 | base () = c; |
---|
3595 | return *this; |
---|
3596 | } |
---|
3597 | |
---|
3598 | /** |
---|
3599 | * @brief Assign a C %string to the instance. |
---|
3600 | * |
---|
3601 | * The resulting %entity contains a copy of the C %string. |
---|
3602 | * |
---|
3603 | * @param s A C %string to assign. |
---|
3604 | * @return A reference to the instance. |
---|
3605 | */ |
---|
3606 | entity& |
---|
3607 | operator= (const C* s) |
---|
3608 | { |
---|
3609 | base () = s; |
---|
3610 | return *this; |
---|
3611 | } |
---|
3612 | |
---|
3613 | /** |
---|
3614 | * @brief Assign a standard %string to the instance. |
---|
3615 | * |
---|
3616 | * The resulting %entity contains a copy of the standard %string. |
---|
3617 | * |
---|
3618 | * @param s A standard %string to assign. |
---|
3619 | * @return A reference to the instance. |
---|
3620 | */ |
---|
3621 | entity& |
---|
3622 | operator= (const std::basic_string<C>& s) |
---|
3623 | { |
---|
3624 | base () = s; |
---|
3625 | return *this; |
---|
3626 | } |
---|
3627 | |
---|
3628 | /** |
---|
3629 | * @brief Copy assignment operator. |
---|
3630 | * |
---|
3631 | * @param x An instance to assign. |
---|
3632 | * @return A reference to the instance. |
---|
3633 | */ |
---|
3634 | entity& |
---|
3635 | operator= (const entity& x) |
---|
3636 | { |
---|
3637 | base () = x; |
---|
3638 | return *this; |
---|
3639 | } |
---|
3640 | |
---|
3641 | protected: |
---|
3642 | //@cond |
---|
3643 | |
---|
3644 | entity () |
---|
3645 | : base_type () |
---|
3646 | { |
---|
3647 | } |
---|
3648 | |
---|
3649 | //@endcond |
---|
3650 | }; |
---|
3651 | |
---|
3652 | |
---|
3653 | /** |
---|
3654 | * @brief Class corresponding to the XML Schema ENTITIES built-in |
---|
3655 | * type. |
---|
3656 | * |
---|
3657 | * The %entities class is a vector (or %list in XML Schema terminology) |
---|
3658 | * of entity elements. It is implemented in terms of the list class |
---|
3659 | * template. |
---|
3660 | * |
---|
3661 | * @nosubgrouping |
---|
3662 | */ |
---|
3663 | template <typename C, typename B, typename entity> |
---|
3664 | class entities: public B, public list<entity, C> |
---|
3665 | { |
---|
3666 | typedef list<entity, C> base_type; |
---|
3667 | |
---|
3668 | public: |
---|
3669 | /** |
---|
3670 | * @name Constructors |
---|
3671 | */ |
---|
3672 | //@{ |
---|
3673 | |
---|
3674 | /** |
---|
3675 | * @brief Default constructor creates no elements. |
---|
3676 | */ |
---|
3677 | entities () |
---|
3678 | { |
---|
3679 | } |
---|
3680 | |
---|
3681 | /** |
---|
3682 | * @brief Initialize the instance with copies of an exemplar elements. |
---|
3683 | * |
---|
3684 | * @param n A number of elements to copy. |
---|
3685 | * @param x An exemplar element to copy. |
---|
3686 | */ |
---|
3687 | entities (typename base_type::size_type n, const entity& x) |
---|
3688 | : base_type (n, x) |
---|
3689 | { |
---|
3690 | } |
---|
3691 | |
---|
3692 | /** |
---|
3693 | * @brief Initialize the instance with copies of elements from an |
---|
3694 | * iterator range. |
---|
3695 | * |
---|
3696 | * @param begin An iterator pointing to the first element. |
---|
3697 | * @param end An iterator pointing to the one past the last element. |
---|
3698 | */ |
---|
3699 | template <typename I> |
---|
3700 | entities (const I& begin, const I& end) |
---|
3701 | : base_type (begin, end) |
---|
3702 | { |
---|
3703 | } |
---|
3704 | |
---|
3705 | public: |
---|
3706 | /** |
---|
3707 | * @brief Copy constructor. |
---|
3708 | * |
---|
3709 | * @param x An instance to make a copy of. |
---|
3710 | * @param f Flags to create the copy with. |
---|
3711 | * @param c A pointer to the object that will contain the copy. |
---|
3712 | * |
---|
3713 | * For polymorphic object models use the @c _clone function instead. |
---|
3714 | */ |
---|
3715 | entities (const entities& x, flags f = 0, container* c = 0) |
---|
3716 | : B (x, f, c), base_type (x, f, c) |
---|
3717 | { |
---|
3718 | } |
---|
3719 | |
---|
3720 | /** |
---|
3721 | * @brief Copy the instance polymorphically. |
---|
3722 | * |
---|
3723 | * @param f Flags to create the copy with. |
---|
3724 | * @param c A pointer to the object that will contain the copy. |
---|
3725 | * @return A pointer to the dynamically allocated copy. |
---|
3726 | * |
---|
3727 | * This function ensures that the dynamic type of the instance |
---|
3728 | * is used for copying and should be used for polymorphic object |
---|
3729 | * models instead of the copy constructor. |
---|
3730 | */ |
---|
3731 | virtual entities* |
---|
3732 | _clone (flags f = 0, container* c = 0) const; |
---|
3733 | |
---|
3734 | public: |
---|
3735 | /** |
---|
3736 | * @brief Create an instance from a data representation |
---|
3737 | * stream. |
---|
3738 | * |
---|
3739 | * @param s A stream to extract the data from. |
---|
3740 | * @param f Flags to create the new instance with. |
---|
3741 | * @param c A pointer to the object that will contain the new |
---|
3742 | * instance. |
---|
3743 | */ |
---|
3744 | template <typename S> |
---|
3745 | entities (istream<S>& s, flags f = 0, container* c = 0); |
---|
3746 | |
---|
3747 | /** |
---|
3748 | * @brief Create an instance from a DOM element. |
---|
3749 | * |
---|
3750 | * @param e A DOM element to extract the data from. |
---|
3751 | * @param f Flags to create the new instance with. |
---|
3752 | * @param c A pointer to the object that will contain the new |
---|
3753 | * instance. |
---|
3754 | */ |
---|
3755 | entities (const xercesc::DOMElement& e, flags f = 0, container* c = 0); |
---|
3756 | |
---|
3757 | /** |
---|
3758 | * @brief Create an instance from a DOM Attribute. |
---|
3759 | * |
---|
3760 | * @param a A DOM attribute to extract the data from. |
---|
3761 | * @param f Flags to create the new instance with. |
---|
3762 | * @param c A pointer to the object that will contain the new |
---|
3763 | * instance. |
---|
3764 | */ |
---|
3765 | entities (const xercesc::DOMAttr& a, flags f = 0, container* c = 0); |
---|
3766 | |
---|
3767 | /** |
---|
3768 | * @brief Create an instance from a %string fragment. |
---|
3769 | * |
---|
3770 | * @param s A %string fragment to extract the data from. |
---|
3771 | * @param e A pointer to DOM element containing the %string fragment. |
---|
3772 | * @param f Flags to create the new instance with. |
---|
3773 | * @param c A pointer to the object that will contain the new |
---|
3774 | * instance. |
---|
3775 | */ |
---|
3776 | entities (const std::basic_string<C>& s, |
---|
3777 | const xercesc::DOMElement* e, |
---|
3778 | flags f = 0, |
---|
3779 | container* c = 0); |
---|
3780 | //@} |
---|
3781 | }; |
---|
3782 | } |
---|
3783 | } |
---|
3784 | } |
---|
3785 | |
---|
3786 | #include <xsd/cxx/tree/types.txx> |
---|
3787 | |
---|
3788 | #endif // XSD_CXX_TREE_TYPES_HXX |
---|