1 | // file : xsd/cxx/parser/elements.hxx |
---|
2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
---|
3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
---|
4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
---|
5 | |
---|
6 | #ifndef XSD_CXX_PARSER_ELEMENTS_HXX |
---|
7 | #define XSD_CXX_PARSER_ELEMENTS_HXX |
---|
8 | |
---|
9 | #include <xsd/cxx/ro-string.hxx> |
---|
10 | |
---|
11 | namespace xsd |
---|
12 | { |
---|
13 | namespace cxx |
---|
14 | { |
---|
15 | namespace parser |
---|
16 | { |
---|
17 | // pre() and post() are overridable pre/post callbacks, i.e., the |
---|
18 | // derived parser can override them without calling the base version. |
---|
19 | // _pre() and _post() are not overridable pre/post callbacks in the |
---|
20 | // sense that the derived parser may override them but has to call |
---|
21 | // the base version. The call sequence is as shown below: |
---|
22 | // |
---|
23 | // pre () |
---|
24 | // _pre () |
---|
25 | // _post () |
---|
26 | // post () |
---|
27 | // |
---|
28 | template <typename C> |
---|
29 | class parser_base |
---|
30 | { |
---|
31 | public: |
---|
32 | virtual |
---|
33 | ~parser_base (); |
---|
34 | |
---|
35 | virtual void |
---|
36 | pre (); |
---|
37 | |
---|
38 | virtual void |
---|
39 | _pre (); |
---|
40 | |
---|
41 | // The type argument is a type name and namespace from the |
---|
42 | // xsi:type attribute in the form "<name> <namespace>" with |
---|
43 | // the space and namespace part absent if the type does not |
---|
44 | // have a namespace or 0 if xsi:type is not present. |
---|
45 | // |
---|
46 | virtual void |
---|
47 | _start_element (const ro_string<C>& ns, |
---|
48 | const ro_string<C>& name, |
---|
49 | const ro_string<C>* type) = 0; |
---|
50 | |
---|
51 | virtual void |
---|
52 | _end_element (const ro_string<C>& ns, |
---|
53 | const ro_string<C>& name) = 0; |
---|
54 | |
---|
55 | virtual void |
---|
56 | _attribute (const ro_string<C>& ns, |
---|
57 | const ro_string<C>& name, |
---|
58 | const ro_string<C>& value) = 0; |
---|
59 | |
---|
60 | virtual void |
---|
61 | _characters (const ro_string<C>&) = 0; |
---|
62 | |
---|
63 | virtual void |
---|
64 | _post (); |
---|
65 | |
---|
66 | // The post() signature varies depending on the parser return |
---|
67 | // type. |
---|
68 | // |
---|
69 | |
---|
70 | // Implementation callbacks for _pre and _post. The _pre and _post |
---|
71 | // callbacks should never be called directly. Instead, the *_impl |
---|
72 | // versions should be used. By default _pre_impl and _post_impl |
---|
73 | // simply call _pre and _post respectively. |
---|
74 | // |
---|
75 | virtual void |
---|
76 | _pre_impl (); |
---|
77 | |
---|
78 | virtual void |
---|
79 | _post_impl (); |
---|
80 | |
---|
81 | public: |
---|
82 | // Dynamic type in the form "<name> <namespace>" with |
---|
83 | // the space and namespace part absent if the type does |
---|
84 | // not have a namespace. Used in polymorphism-aware code. |
---|
85 | // |
---|
86 | virtual const C* |
---|
87 | _dynamic_type () const; |
---|
88 | }; |
---|
89 | } |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | #include <xsd/cxx/parser/elements.txx> |
---|
94 | |
---|
95 | #endif // XSD_CXX_PARSER_ELEMENTS_HXX |
---|