Multi-line svn commit, see body.
[shibboleth/cpp-xmltooling.git] / xmltooling / base.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file xmltooling/base.h
19  * 
20  * Base header file definitions
21  * Must be included prior to including any other header
22  */
23
24 #ifndef __xmltooling_base_h__
25 #define __xmltooling_base_h__
26
27 #if defined (_MSC_VER) || defined(__BORLANDC__)
28   #include <xmltooling/config_pub_win32.h>
29 #else
30   #include <xmltooling/config_pub.h>
31 #endif
32
33 #ifdef XMLTOOLING_LITE
34 # define XMLTOOLING_NO_XMLSEC 1
35 #endif
36
37 // Windows and GCC4 Symbol Visibility Macros
38 #ifdef WIN32
39   #define XMLTOOL_IMPORT __declspec(dllimport)
40   #define XMLTOOL_EXPORT __declspec(dllexport)
41   #define XMLTOOL_DLLLOCAL
42   #define XMLTOOL_DLLPUBLIC
43 #else
44   #define XMLTOOL_IMPORT
45   #ifdef GCC_HASCLASSVISIBILITY
46     #define XMLTOOL_EXPORT __attribute__ ((visibility("default")))
47     #define XMLTOOL_DLLLOCAL __attribute__ ((visibility("hidden")))
48     #define XMLTOOL_DLLPUBLIC __attribute__ ((visibility("default")))
49   #else
50     #define XMLTOOL_EXPORT
51     #define XMLTOOL_DLLLOCAL
52     #define XMLTOOL_DLLPUBLIC
53   #endif
54 #endif
55
56 // Define XMLTOOL_API for DLL builds
57 #ifdef XMLTOOLING_EXPORTS
58   #define XMLTOOL_API XMLTOOL_EXPORT
59 #else
60   #define XMLTOOL_API XMLTOOL_IMPORT
61 #endif
62
63 // Throwable classes must always be visible on GCC in all binaries
64 #ifdef WIN32
65   #define XMLTOOL_EXCEPTIONAPI(api) api
66 #elif defined(GCC_HASCLASSVISIBILITY)
67   #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT
68 #else
69   #define XMLTOOL_EXCEPTIONAPI(api)
70 #endif
71
72 #ifdef _MSC_VER
73     #define XMLTOOLING_DOXYGEN(desc) /##** desc */
74 #else
75     #define XMLTOOLING_DOXYGEN(desc)
76 #endif
77
78 /**
79  * Blocks copy c'tor and assignment operator for a class.
80  */
81 #define MAKE_NONCOPYABLE(type) \
82     private: \
83         type(const type&); \
84         type& operator=(const type&)
85
86 #ifndef DOXYGEN_SKIP
87 #ifndef NULL
88 #define NULL    0
89 #endif
90 #define UNICODE_LITERAL_1(a) {xercesc::chLatin_##a, xercesc::chNull}
91 #define UNICODE_LITERAL_2(a,b) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chNull}
92 #define UNICODE_LITERAL_3(a,b,c) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chNull}
93 #define UNICODE_LITERAL_4(a,b,c,d) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chNull}
94 #define UNICODE_LITERAL_5(a,b,c,d,e) \
95     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chNull}
96 #define UNICODE_LITERAL_6(a,b,c,d,e,f) \
97     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chNull}
98 #define UNICODE_LITERAL_7(a,b,c,d,e,f,g) \
99     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chNull}
100 #define UNICODE_LITERAL_8(a,b,c,d,e,f,g,h) \
101     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chNull}
102 #define UNICODE_LITERAL_9(a,b,c,d,e,f,g,h,i) \
103     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, xercesc::chNull}
104 #define UNICODE_LITERAL_10(a,b,c,d,e,f,g,h,i,j) \
105     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
106         xercesc::chLatin_##j, xercesc::chNull}
107 #define UNICODE_LITERAL_11(a,b,c,d,e,f,g,h,i,j,k) \
108     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
109         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chNull}
110 #define UNICODE_LITERAL_12(a,b,c,d,e,f,g,h,i,j,k,l) \
111     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
112         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chNull}
113 #define UNICODE_LITERAL_13(a,b,c,d,e,f,g,h,i,j,k,l,m) \
114     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
115         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chNull}
116 #define UNICODE_LITERAL_14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) \
117     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
118         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chNull}
119 #define UNICODE_LITERAL_15(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \
120     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
121         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chNull}
122 #define UNICODE_LITERAL_16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
123     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
124         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chNull}
125 #define UNICODE_LITERAL_17(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) \
126     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
127         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chNull}
128 #define UNICODE_LITERAL_18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) \
129     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
130         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, xercesc::chNull}
131 #define UNICODE_LITERAL_19(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) \
132     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
133         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
134         xercesc::chLatin_##s, xercesc::chNull}
135 #define UNICODE_LITERAL_20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) \
136     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
137         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
138         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chNull}
139 #define UNICODE_LITERAL_21(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) \
140     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
141         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
142         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chNull}
143 #define UNICODE_LITERAL_22(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) \
144     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
145         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
146         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chNull}
147 #define UNICODE_LITERAL_23(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) \
148     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
149         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
150         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chNull}
151 #define UNICODE_LITERAL_24(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) \
152     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
153         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
154         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chNull}
155 #define UNICODE_LITERAL_25(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) \
156     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
157         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
158         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chNull}
159 #define UNICODE_LITERAL_26(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) \
160     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
161         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
162         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, xercesc::chNull}
163 #define UNICODE_LITERAL_27(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa) \
164     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
165         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
166         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
167         xercesc::chLatin_##aa, xercesc::chNull}
168 #define UNICODE_LITERAL_28(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb) \
169     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
170         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
171         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
172         xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chNull}
173 #define UNICODE_LITERAL_29(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc) \
174     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
175         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
176         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
177         xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chNull}
178 #define UNICODE_LITERAL_30(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd) \
179     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
180         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
181         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
182         xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chNull}
183 #define UNICODE_LITERAL_31(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee) \
184     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
185         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
186         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
187         xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chNull}
188 #define UNICODE_LITERAL_32(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff) \
189     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
190         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
191         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
192         xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chNull}
193 #define UNICODE_LITERAL_33(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg) \
194     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
195         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
196         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
197         xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chLatin_##gg, xercesc::chNull}
198 #define UNICODE_LITERAL_34(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg,hh) \
199     {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
200         xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chLatin_##r, \
201         xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
202         xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chLatin_##gg, xercesc::chLatin_##hh, xercesc::chNull}
203 #endif /* DOXYGEN_SKIP */
204
205 /**
206  * Begins the declaration of an XMLObject specialization for an abstract element/type.
207  * Basic boilerplate includes a protected constructor, empty virtual destructor,
208  * and Unicode constants for the default associated element's name and prefix.
209  * 
210  * @param linkage   linkage specifier for the class
211  * @param cname     the name of the class to declare
212  * @param base      the base class to derive from using public virtual inheritance
213  * @param desc      documentation comment for class
214  */
215 #define DECL_XMLOBJECT_ABSTRACT(linkage,cname,base,desc) \
216     XMLTOOLING_DOXYGEN(desc) \
217     class linkage cname : public virtual base { \
218     protected: \
219         cname() {} \
220     public: \
221         virtual ~cname() {} \
222         XMLTOOLING_DOXYGEN(Element local name) \
223         static const XMLCh LOCAL_NAME[]; \
224     }
225
226 /**
227  * Begins the declaration of an XMLObject specialization.
228  * Basic boilerplate includes a protected constructor, empty virtual destructor,
229  * and Unicode constants for the default associated element's name and prefix.
230  * 
231  * @param linkage   linkage specifier for the class
232  * @param cname     the name of the class to declare
233  * @param base      the base class to derive from using public virtual inheritance
234  * @param desc      documentation comment for class
235  */
236 #define BEGIN_XMLOBJECT(linkage,cname,base,desc) \
237     XMLTOOLING_DOXYGEN(desc) \
238     class linkage cname : public virtual base { \
239     protected: \
240         cname() {} \
241     public: \
242         virtual ~cname() {} \
243         XMLTOOLING_DOXYGEN(Type-specific clone method.) \
244         virtual cname* clone##cname() const=0; \
245         XMLTOOLING_DOXYGEN(Element local name) \
246         static const XMLCh LOCAL_NAME[]
247
248 /**
249  * Begins the declaration of an XMLObject specialization with two base classes.
250  * Basic boilerplate includes a protected constructor, empty virtual destructor,
251  * and Unicode constants for the default associated element's name and prefix.
252  * 
253  * @param linkage   linkage specifier for the class
254  * @param cname     the name of the class to declare
255  * @param base      the first base class to derive from using public virtual inheritance
256  * @param base2     the second base class to derive from using public virtual inheritance
257  * @param desc      documentation comment for class
258  */
259 #define BEGIN_XMLOBJECT2(linkage,cname,base,base2,desc) \
260     XMLTOOLING_DOXYGEN(desc) \
261     class linkage cname : public virtual base, public virtual base2 { \
262     protected: \
263         cname() {} \
264     public: \
265         virtual ~cname() {} \
266         XMLTOOLING_DOXYGEN(Type-specific clone method.) \
267         virtual cname* clone##cname() const=0; \
268         XMLTOOLING_DOXYGEN(Element local name) \
269         static const XMLCh LOCAL_NAME[]
270
271 /**
272  * Begins the declaration of an XMLObject specialization with three base classes.
273  * Basic boilerplate includes a protected constructor, empty virtual destructor,
274  * and Unicode constants for the default associated element's name and prefix.
275  * 
276  * @param linkage   linkage specifier for the class
277  * @param cname     the name of the class to declare
278  * @param base      the first base class to derive from using public virtual inheritance
279  * @param base2     the second base class to derive from using public virtual inheritance
280  * @param base3     the third base class to derive from using public virtual inheritance
281  * @param desc      documentation comment for class
282  */
283 #define BEGIN_XMLOBJECT3(linkage,cname,base,base2,base3,desc) \
284     XMLTOOLING_DOXYGEN(desc) \
285     class linkage cname : public virtual base, public virtual base2, public virtual base3 { \
286     protected: \
287         cname() {} \
288     public: \
289         virtual ~cname() {} \
290         XMLTOOLING_DOXYGEN(Type-specific clone method.) \
291         virtual cname* clone##cname() const=0; \
292         XMLTOOLING_DOXYGEN(Element local name) \
293         static const XMLCh LOCAL_NAME[]
294
295 /**
296  * Begins the declaration of an XMLObject specialization with four base classes.
297  * Basic boilerplate includes a protected constructor, empty virtual destructor,
298  * and Unicode constants for the default associated element's name and prefix.
299  * 
300  * @param linkage   linkage specifier for the class
301  * @param cname     the name of the class to declare
302  * @param base      the first base class to derive from using public virtual inheritance
303  * @param base2     the second base class to derive from using public virtual inheritance
304  * @param base3     the third base class to derive from using public virtual inheritance
305  * @param base4     the fourth base class to derive from using public virtual inheritance
306  * @param desc      documentation comment for class
307  */
308 #define BEGIN_XMLOBJECT4(linkage,cname,base,base2,base3,base4,desc) \
309     XMLTOOLING_DOXYGEN(desc) \
310     class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4 { \
311     protected: \
312         cname() {} \
313     public: \
314         virtual ~cname() {} \
315         XMLTOOLING_DOXYGEN(Type-specific clone method.) \
316         virtual cname* clone##cname() const=0; \
317         XMLTOOLING_DOXYGEN(Element local name) \
318         static const XMLCh LOCAL_NAME[]
319
320 /**
321  * Begins the declaration of an XMLObject specialization with five base classes.
322  * Basic boilerplate includes a protected constructor, empty virtual destructor,
323  * and Unicode constants for the default associated element's name and prefix.
324  * 
325  * @param linkage   linkage specifier for the class
326  * @param cname     the name of the class to declare
327  * @param base      the first base class to derive from using public virtual inheritance
328  * @param base2     the second base class to derive from using public virtual inheritance
329  * @param base3     the third base class to derive from using public virtual inheritance
330  * @param base4     the fourth base class to derive from using public virtual inheritance
331  * @param base5     the fifth base class to derive from using public virtual inheritance
332  * @param desc      documentation comment for class
333  */
334 #define BEGIN_XMLOBJECT5(linkage,cname,base,base2,base3,base4,base5,desc) \
335     XMLTOOLING_DOXYGEN(desc) \
336     class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4, public virtual base5 { \
337     protected: \
338         cname() {} \
339     public: \
340         virtual ~cname() {} \
341         XMLTOOLING_DOXYGEN(Type-specific clone method.) \
342         virtual cname* clone##cname() const=0; \
343         XMLTOOLING_DOXYGEN(Element local name) \
344         static const XMLCh LOCAL_NAME[]
345
346 /**
347  * Ends the declaration of an XMLObject specialization.
348  */
349 #define END_XMLOBJECT }
350
351 /**
352  * Declares a static variable holding the XMLObject's element QName.
353  */
354 #define DECL_ELEMENT_QNAME \
355     public: \
356         XMLTOOLING_DOXYGEN(Element QName) \
357         static xmltooling::QName ELEMENT_QNAME
358
359 /**
360  * Declares a static variable holding the XMLObject's schema type QName.
361  */
362 #define DECL_TYPE_QNAME \
363     public: \
364         XMLTOOLING_DOXYGEN(Type QName) \
365         static xmltooling::QName TYPE_QNAME
366
367 /**
368  * Implements a static variable holding an XMLObject's element QName.
369  * 
370  * @param cname             the name of the XMLObject specialization
371  * @param namespaceURI      the XML namespace of the default associated element
372  * @param namespacePrefix   the XML namespace prefix of the default associated element
373  */
374 #define IMPL_ELEMENT_QNAME(cname,namespaceURI,namespacePrefix) \
375     xmltooling::QName cname::ELEMENT_QNAME(namespaceURI,cname::LOCAL_NAME,namespacePrefix)
376
377 /**
378  * Implements a static variable holding an XMLObject's schema type QName.
379  * 
380  * @param cname             the name of the XMLObject specialization
381  * @param namespaceURI      the XML namespace of the default associated element
382  * @param namespacePrefix   the XML namespace prefix of the default associated element
383  */
384 #define IMPL_TYPE_QNAME(cname,namespaceURI,namespacePrefix) \
385     xmltooling::QName cname::TYPE_QNAME(namespaceURI,cname::TYPE_NAME,namespacePrefix)
386
387 /**
388  * Declares abstract set method for a typed XML attribute.
389  * The get method is omitted.
390  * 
391  * @param proper    the proper name of the attribute
392  * @param upcased   the upcased name of the attribute
393  * @param type      the attribute's data type
394  */
395 #define DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,type) \
396     public: \
397         XMLTOOLING_DOXYGEN(proper attribute name) \
398         static const XMLCh upcased##_ATTRIB_NAME[]; \
399         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
400         virtual void set##proper(const type* proper)=0
401
402 /**
403  * Declares abstract get/set methods for a typed XML attribute.
404  * 
405  * @param proper    the proper name of the attribute
406  * @param upcased   the upcased name of the attribute
407  * @param type      the attribute's data type
408  */
409 #define DECL_XMLOBJECT_ATTRIB(proper,upcased,type) \
410     public: \
411         XMLTOOLING_DOXYGEN(proper attribute name) \
412         static const XMLCh upcased##_ATTRIB_NAME[]; \
413         XMLTOOLING_DOXYGEN(Returns the proper attribute.) \
414         virtual const type* get##proper() const=0; \
415         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
416         virtual void set##proper(const type* proper)=0
417
418 /**
419  * Declares abstract set method for a string XML attribute.
420  * The get method is omitted.
421  * 
422  * @param proper    the proper name of the attribute
423  * @param upcased   the upcased name of the attribute
424  */
425 #define DECL_INHERITED_STRING_ATTRIB(proper,upcased) \
426     DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,XMLCh)
427
428 /**
429  * Declares abstract get/set methods for a string XML attribute.
430  * 
431  * @param proper    the proper name of the attribute
432  * @param upcased   the upcased name of the attribute
433  */
434 #define DECL_STRING_ATTRIB(proper,upcased) \
435     DECL_XMLOBJECT_ATTRIB(proper,upcased,XMLCh)
436
437 /**
438  * Declares abstract set method for a DateTime XML attribute.
439  * The get method is omitted.
440  * 
441  * @param proper    the proper name of the attribute
442  * @param upcased   the upcased name of the attribute
443  */
444 #define DECL_INHERITED_DATETIME_ATTRIB(proper,upcased) \
445     DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
446     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
447     virtual void set##proper(time_t proper)=0; \
448     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
449     virtual void set##proper(const XMLCh* proper)=0
450
451 /**
452  * Declares abstract get/set methods for a DateTime XML attribute.
453  * 
454  * @param proper    the proper name of the attribute
455  * @param upcased   the upcased name of the attribute
456  */
457 #define DECL_DATETIME_ATTRIB(proper,upcased) \
458     DECL_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
459     XMLTOOLING_DOXYGEN(Returns the proper attribute in epoch form.) \
460     virtual time_t get##proper##Epoch() const=0; \
461     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
462     virtual void set##proper(time_t proper)=0; \
463     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
464     virtual void set##proper(const XMLCh* proper)=0
465
466 /**
467  * Declares abstract set method for an integer XML attribute.
468  * The get method is omitted.
469  * 
470  * @param proper    the proper name of the attribute
471  * @param upcased   the upcased name of the attribute
472  */
473 #define DECL_INHERITED_INTEGER_ATTRIB(proper,upcased) \
474     public: \
475         XMLTOOLING_DOXYGEN(proper attribute name) \
476         static const XMLCh upcased##_ATTRIB_NAME[]; \
477         XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \
478         virtual void set##proper(const XMLCh* proper)=0; \
479         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
480         virtual void set##proper(int proper)=0
481
482 /**
483  * Declares abstract get/set methods for an integer XML attribute.
484  * 
485  * @param proper    the proper name of the attribute
486  * @param upcased   the upcased name of the attribute
487  */
488 #define DECL_INTEGER_ATTRIB(proper,upcased) \
489     public: \
490         XMLTOOLING_DOXYGEN(proper attribute name) \
491         static const XMLCh upcased##_ATTRIB_NAME[]; \
492         XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \
493         virtual std::pair<bool,int> get##proper() const=0; \
494         XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \
495         virtual void set##proper(const XMLCh* proper)=0; \
496         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
497         virtual void set##proper(int proper)=0
498
499 /**
500  * Declares abstract get/set methods for a boolean XML attribute.
501  * 
502  * @param proper    the proper name of the attribute
503  * @param upcased   the upcased name of the attribute
504  * @param def       the default/presumed value, if no explicit value has been set
505  */
506 #define DECL_BOOLEAN_ATTRIB(proper,upcased,def) \
507     public: \
508         XMLTOOLING_DOXYGEN(proper attribute name) \
509         static const XMLCh upcased##_ATTRIB_NAME[]; \
510         XMLTOOLING_DOXYGEN(Returns the proper attribute or def if not set.) \
511         bool proper() const { \
512             switch (get##proper()) { \
513                 case xmlconstants::XML_BOOL_TRUE: \
514                 case xmlconstants::XML_BOOL_ONE: \
515                     return true; \
516                 case xmlconstants::XML_BOOL_FALSE: \
517                 case xmlconstants::XML_BOOL_ZERO: \
518                     return false; \
519                 default: \
520                     return def; \
521             } \
522         } \
523         XMLTOOLING_DOXYGEN(Returns the proper attribute as an explicit enumerated value.) \
524         virtual xmlconstants::xmltooling_bool_t get##proper() const=0; \
525         XMLTOOLING_DOXYGEN(Sets the proper attribute using an enumerated value.) \
526         virtual void proper(xmlconstants::xmltooling_bool_t value)=0; \
527         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
528         void proper(bool value) { \
529             proper(value ? xmlconstants::XML_BOOL_ONE : xmlconstants::XML_BOOL_ZERO); \
530         } \
531         XMLTOOLING_DOXYGEN(Sets the proper attribute using a string constant.) \
532         void set##proper(const XMLCh* value) { \
533             if (value) { \
534                 switch (*value) { \
535                     case xercesc::chLatin_t: \
536                         proper(xmlconstants::XML_BOOL_TRUE); \
537                         break; \
538                     case xercesc::chLatin_f: \
539                         proper(xmlconstants::XML_BOOL_FALSE); \
540                         break; \
541                     case xercesc::chDigit_1: \
542                         proper(xmlconstants::XML_BOOL_ONE); \
543                         break; \
544                     case xercesc::chDigit_0: \
545                         proper(xmlconstants::XML_BOOL_ZERO); \
546                         break; \
547                     default: \
548                         proper(xmlconstants::XML_BOOL_NULL); \
549                 } \
550             } \
551             else \
552                 proper(xmlconstants::XML_BOOL_NULL); \
553         }
554
555 /**
556  * Implements get/set methods and a private member for a typed XML attribute.
557  * 
558  * @param proper    the proper name of the attribute
559  * @param type      the attribute's data type
560  */
561 #define IMPL_XMLOBJECT_ATTRIB(proper,type) \
562     protected: \
563         type* m_##proper; \
564     public: \
565         const type* get##proper() const { \
566             return m_##proper; \
567         } \
568         void set##proper(const type* proper) { \
569             m_##proper = prepareForAssignment(m_##proper,proper); \
570         }
571
572 /**
573  * Implements get/set methods and a private member for a string XML attribute.
574  * 
575  * @param proper    the proper name of the attribute
576  */
577 #define IMPL_STRING_ATTRIB(proper) \
578     IMPL_XMLOBJECT_ATTRIB(proper,XMLCh)
579
580 /**
581  * Implements get/set methods and a private member for a string XML attribute,
582  * plus a getXMLID override.
583  * 
584  * @param proper    the proper name of the attribute
585  */
586 #define IMPL_ID_ATTRIB(proper) \
587     IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) \
588     const XMLCh* getXMLID() const { \
589         return m_##proper; \
590     }
591
592 /**
593  * Implements get/set methods and a private member for a DateTime XML attribute.
594  * 
595  * @param proper    the proper name of the attribute
596  * @param fallback  epoch to return when attribute is NULL
597  */
598 #define IMPL_DATETIME_ATTRIB(proper,fallback) \
599     protected: \
600         DateTime* m_##proper; \
601         time_t m_##proper##Epoch; \
602     public: \
603         const DateTime* get##proper() const { \
604             return m_##proper; \
605         } \
606         time_t get##proper##Epoch() const { \
607             return m_##proper ? m_##proper##Epoch : fallback; \
608         } \
609         void set##proper(const DateTime* proper) { \
610             m_##proper = prepareForAssignment(m_##proper,proper); \
611             if (m_##proper) \
612                 m_##proper##Epoch=m_##proper->getEpoch(); \
613         } \
614         void set##proper(time_t proper) { \
615             m_##proper = prepareForAssignment(m_##proper,proper); \
616             m_##proper##Epoch = proper; \
617         } \
618         void set##proper(const XMLCh* proper) { \
619             m_##proper = prepareForAssignment(m_##proper,proper); \
620             if (m_##proper) \
621                 m_##proper##Epoch=m_##proper->getEpoch(); \
622         }
623
624 /**
625  * Implements get/set methods and a private member for an integer XML attribute.
626  * 
627  * @param proper    the proper name of the attribute
628  */
629 #define IMPL_INTEGER_ATTRIB(proper) \
630     protected: \
631         XMLCh* m_##proper; \
632     public: \
633         pair<bool,int> get##proper() const { \
634             return make_pair((m_##proper!=NULL),(m_##proper!=NULL ? xercesc::XMLString::parseInt(m_##proper): 0)); \
635         } \
636         void set##proper(const XMLCh* proper) { \
637             m_##proper = prepareForAssignment(m_##proper,proper); \
638         } \
639         void set##proper(int proper) { \
640             char buf##proper[64]; \
641             sprintf(buf##proper,"%d",proper); \
642             auto_ptr_XMLCh wide##proper(buf##proper); \
643             set##proper(wide##proper.get()); \
644         }
645
646 /**
647  * Implements get/set methods and a private member for a boolean XML attribute.
648  * 
649  * @param proper    the proper name of the attribute
650  */
651 #define IMPL_BOOLEAN_ATTRIB(proper) \
652     protected: \
653         xmlconstants::xmltooling_bool_t m_##proper; \
654     public: \
655         xmlconstants::xmltooling_bool_t get##proper() const { \
656             return m_##proper; \
657         } \
658         void proper(xmlconstants::xmltooling_bool_t value) { \
659             if (m_##proper != value) { \
660                 releaseThisandParentDOM(); \
661                 m_##proper = value; \
662             } \
663         }
664
665 /**
666  * Declares abstract set method for a typed XML child object in a foreign namespace.
667  * The get method is omitted.
668  * 
669  * @param proper    the proper name of the child type
670  * @param ns        the C++ namespace for the type
671  */
672 #define DECL_INHERITED_TYPED_FOREIGN_CHILD(proper,ns) \
673     public: \
674         XMLTOOLING_DOXYGEN(Sets the proper child.) \
675         virtual void set##proper(ns::proper* child)=0
676
677 /**
678  * Declares abstract get/set methods for a typed XML child object in a foreign namespace.
679  * 
680  * @param proper    the proper name of the child type
681  * @param ns        the C++ namespace for the type
682  */
683 #define DECL_TYPED_FOREIGN_CHILD(proper,ns) \
684     public: \
685         XMLTOOLING_DOXYGEN(Returns the proper child.) \
686         virtual ns::proper* get##proper() const=0; \
687         XMLTOOLING_DOXYGEN(Sets the proper child.) \
688         virtual void set##proper(ns::proper* child)=0
689
690 /**
691  * Declares abstract set method for a typed XML child object.
692  * The get method is omitted.
693  * 
694  * @param proper    the proper name of the child type
695  */
696 #define DECL_INHERITED_TYPED_CHILD(proper) \
697     public: \
698         XMLTOOLING_DOXYGEN(Sets the proper child.) \
699         virtual void set##proper(proper* child)=0
700
701 /**
702  * Declares abstract get/set methods for a typed XML child object.
703  * 
704  * @param proper    the proper name of the child type
705  */
706 #define DECL_TYPED_CHILD(proper) \
707     public: \
708         XMLTOOLING_DOXYGEN(Returns the proper child.) \
709         virtual proper* get##proper() const=0; \
710         XMLTOOLING_DOXYGEN(Sets the proper child.) \
711         virtual void set##proper(proper* child)=0
712
713 /**
714  * Declares abstract get/set methods for a generic XML child object.
715  * 
716  * @param proper    the proper name of the child
717  */
718 #define DECL_XMLOBJECT_CHILD(proper) \
719     public: \
720         XMLTOOLING_DOXYGEN(Returns the proper child.) \
721         virtual xmltooling::XMLObject* get##proper() const=0; \
722         XMLTOOLING_DOXYGEN(Sets the proper child.) \
723         virtual void set##proper(xmltooling::XMLObject* child)=0
724
725
726 /**
727  * Implements get/set methods and a private list iterator member for a typed XML child object.
728  * 
729  * @param proper    the proper name of the child type
730  */
731 #define IMPL_TYPED_CHILD(proper) \
732     protected: \
733         proper* m_##proper; \
734         std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
735     public: \
736         proper* get##proper() const { \
737             return m_##proper; \
738         } \
739         void set##proper(proper* child) { \
740             prepareForAssignment(m_##proper,child); \
741             *m_pos_##proper = m_##proper = child; \
742         }
743
744 /**
745  * Implements get/set methods and a private list iterator member for
746  * a typed XML child object in a foreign namespace
747  * 
748  * @param proper    the proper name of the child type
749  * @param ns        the C++ namespace for the type
750  */
751 #define IMPL_TYPED_FOREIGN_CHILD(proper,ns) \
752     protected: \
753         ns::proper* m_##proper; \
754         std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
755     public: \
756         ns::proper* get##proper() const { \
757             return m_##proper; \
758         } \
759         void set##proper(ns::proper* child) { \
760             prepareForAssignment(m_##proper,child); \
761             *m_pos_##proper = m_##proper = child; \
762         }
763
764 /**
765  * Implements get/set methods and a private list iterator member for a generic XML child object.
766  * 
767  * @param proper    the proper name of the child
768  */
769 #define IMPL_XMLOBJECT_CHILD(proper) \
770     protected: \
771         xmltooling::XMLObject* m_##proper; \
772         std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
773     public: \
774         xmltooling::XMLObject* get##proper() const { \
775             return m_##proper; \
776         } \
777         void set##proper(xmltooling::XMLObject* child) { \
778             prepareForAssignment(m_##proper,child); \
779             *m_pos_##proper = m_##proper = child; \
780         }
781
782 /**
783  * Declares abstract get/set methods for a typed XML child collection.
784  * 
785  * @param proper    the proper name of the child type
786  */
787 #define DECL_TYPED_CHILDREN(proper) \
788     public: \
789         XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
790         virtual VectorOf(proper) get##proper##s()=0; \
791         XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
792         virtual const std::vector<proper*>& get##proper##s() const=0
793
794 /**
795  * Declares abstract get/set methods for a typed XML child collection in a foreign namespace.
796  * 
797  * @param proper    the proper name of the child type
798  * @param ns        the C++ namespace for the type
799  */
800 #define DECL_TYPED_FOREIGN_CHILDREN(proper,ns) \
801     public: \
802         XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
803         virtual VectorOf(ns::proper) get##proper##s()=0; \
804         XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
805         virtual const std::vector<ns::proper*>& get##proper##s() const=0
806
807 /**
808  * Declares abstract get/set methods for a generic XML child collection.
809  * 
810  * @param proper    the proper name of the child
811  */
812 #define DECL_XMLOBJECT_CHILDREN(proper) \
813     public: \
814         XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
815         virtual VectorOf(xmltooling::XMLObject) get##proper##s()=0; \
816         XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
817         virtual const std::vector<xmltooling::XMLObject*>& get##proper##s() const=0
818
819 /**
820  * Implements get method and a private vector member for a typed XML child collection.
821  * 
822  * @param proper    the proper name of the child type
823  * @param fence     insertion fence for new objects of the child collection in backing list
824  */
825 #define IMPL_TYPED_CHILDREN(proper,fence) \
826     protected: \
827         std::vector<proper*> m_##proper##s; \
828     public: \
829         VectorOf(proper) get##proper##s() { \
830             return VectorOf(proper)(this, m_##proper##s, &m_children, fence); \
831         } \
832         const std::vector<proper*>& get##proper##s() const { \
833             return m_##proper##s; \
834         } 
835
836 /**
837  * Implements get method and a private vector member for a typed XML child collection
838  * in a foreign namespace.
839  * 
840  * @param proper    the proper name of the child type
841  * @param ns        the C++ namespace for the type
842  * @param fence     insertion fence for new objects of the child collection in backing list
843  */
844 #define IMPL_TYPED_FOREIGN_CHILDREN(proper,ns,fence) \
845     protected: \
846         std::vector<ns::proper*> m_##proper##s; \
847     public: \
848         VectorOf(ns::proper) get##proper##s() { \
849             return VectorOf(ns::proper)(this, m_##proper##s, &m_children, fence); \
850         } \
851         const std::vector<ns::proper*>& get##proper##s() const { \
852             return m_##proper##s; \
853         } 
854
855 /**
856  * Implements get method and a private vector member for a generic XML child collection.
857  * 
858  * @param proper    the proper name of the child
859  * @param fence     insertion fence for new objects of the child collection in backing list
860  */
861 #define IMPL_XMLOBJECT_CHILDREN(proper,fence) \
862     protected: \
863         std::vector<xmltooling::XMLObject*> m_##proper##s; \
864     public: \
865         VectorOf(xmltooling::XMLObject) get##proper##s() { \
866             return VectorOf(xmltooling::XMLObject)(this, m_##proper##s, &m_children, fence); \
867         } \
868         const std::vector<xmltooling::XMLObject*>& get##proper##s() const { \
869             return m_##proper##s; \
870         } 
871
872 /**
873  * Implements marshalling for a string attribute
874  * 
875  * @param proper        the proper name of the attribute
876  * @param ucase         the upcased name of the attribute
877  * @param namespaceURI  the XML namespace of the attribute
878  */
879 #define MARSHALL_STRING_ATTRIB(proper,ucase,namespaceURI) \
880     if (m_##proper && *m_##proper) { \
881         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
882     }
883
884 /**
885  * Implements marshalling for a DateTime attribute
886  * 
887  * @param proper        the proper name of the attribute
888  * @param ucase         the upcased name of the attribute
889  * @param namespaceURI  the XML namespace of the attribute
890  */
891 #define MARSHALL_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
892     if (m_##proper) { \
893         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper->getRawData()); \
894     }
895
896 /**
897  * Implements marshalling for an integer attribute
898  * 
899  * @param proper        the proper name of the attribute
900  * @param ucase         the upcased name of the attribute
901  * @param namespaceURI  the XML namespace of the attribute
902  */
903 #define MARSHALL_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
904     if (m_##proper && *m_##proper) { \
905         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
906     }
907
908 /**
909  * Implements marshalling for a boolean attribute
910  * 
911  * @param proper        the proper name of the attribute
912  * @param ucase         the upcased name of the attribute
913  * @param namespaceURI  the XML namespace of the attribute
914  */
915 #define MARSHALL_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
916     switch (m_##proper) { \
917         case xmlconstants::XML_BOOL_TRUE: \
918             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_TRUE); \
919             break; \
920         case xmlconstants::XML_BOOL_ONE: \
921             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ONE); \
922             break; \
923         case xmlconstants::XML_BOOL_FALSE: \
924             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_FALSE); \
925             break; \
926         case xmlconstants::XML_BOOL_ZERO: \
927             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ZERO); \
928             break; \
929         case xmlconstants::XML_BOOL_NULL: \
930             break; \
931     }
932
933 /**
934  * Implements marshalling for a QName attribute
935  * 
936  * @param proper        the proper name of the attribute
937  * @param ucase         the upcased name of the attribute
938  * @param namespaceURI  the XML namespace of the attribute
939  */
940 #define MARSHALL_QNAME_ATTRIB(proper,ucase,namespaceURI) \
941     if (m_##proper) { \
942         auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \
943         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \
944     }
945
946 /**
947  * Implements marshalling for an ID attribute
948  * 
949  * @param proper        the proper name of the attribute
950  * @param ucase         the upcased name of the attribute
951  * @param namespaceURI  the XML namespace of the attribute
952  */
953 #define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \
954     if (m_##proper && *m_##proper) { \
955         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
956         domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \
957     }
958
959 /**
960  * Implements unmarshalling process branch for a string attribute
961  * 
962  * @param proper        the proper name of the attribute
963  * @param ucase         the upcased name of the attribute
964  * @param namespaceURI  the XML namespace of the attribute
965  */
966 #define PROC_STRING_ATTRIB(proper,ucase,namespaceURI) \
967     if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
968         set##proper(attribute->getValue()); \
969         return; \
970     }
971
972 /**
973  * Implements unmarshalling process branch for an ID attribute
974  * 
975  * @param proper        the proper name of the attribute
976  * @param ucase         the upcased name of the attribute
977  * @param namespaceURI  the XML namespace of the attribute
978  */
979 #define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \
980     if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
981         set##proper(attribute->getValue()); \
982         attribute->getOwnerElement()->setIdAttributeNode(attribute); \
983         return; \
984     }
985
986 /**
987  * Implements unmarshalling process branch for a DateTime attribute
988  * 
989  * @param proper        the proper name of the attribute
990  * @param ucase         the upcased name of the attribute
991  * @param namespaceURI  the XML namespace of the attribute
992  */
993 #define PROC_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
994     PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
995
996 /**
997  * Implements unmarshalling process branch for a DateTime attribute
998  * 
999  * @param proper        the proper name of the attribute
1000  * @param ucase         the upcased name of the attribute
1001  * @param namespaceURI  the XML namespace of the attribute
1002  */
1003 #define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \
1004     if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
1005         set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \
1006         return; \
1007     }
1008
1009 /**
1010  * Implements unmarshalling process branch for an integer attribute
1011  * 
1012  * @param proper        the proper name of the attribute
1013  * @param ucase         the upcased name of the attribute
1014  * @param namespaceURI  the XML namespace of the attribute
1015  */
1016 #define PROC_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
1017     PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
1018
1019 /**
1020  * Implements unmarshalling process branch for a boolean attribute
1021  * 
1022  * @param proper        the proper name of the attribute
1023  * @param ucase         the upcased name of the attribute
1024  * @param namespaceURI  the XML namespace of the attribute
1025  */
1026 #define PROC_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
1027     PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
1028
1029 /**
1030  * Implements unmarshalling process branch for typed child collection element
1031  * 
1032  * @param proper        the proper name of the child type
1033  * @param namespaceURI  the XML namespace of the child element
1034  * @param force         bypass use of hint and just cast down to check child
1035  */
1036 #define PROC_TYPED_CHILDREN(proper,namespaceURI,force) \
1037     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1038         proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
1039         if (typesafe) { \
1040             get##proper##s().push_back(typesafe); \
1041             return; \
1042         } \
1043     }
1044
1045 /**
1046  * Implements unmarshalling process branch for typed child collection element
1047  * in a foreign namespace.
1048  * 
1049  * @param proper        the proper name of the child type
1050  * @param ns            the C++ namespace for the type
1051  * @param namespaceURI  the XML namespace of the child element
1052  * @param force         bypass use of hint and just cast down to check child
1053  */
1054 #define PROC_TYPED_FOREIGN_CHILDREN(proper,ns,namespaceURI,force) \
1055     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
1056         ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
1057         if (typesafe) { \
1058             get##proper##s().push_back(typesafe); \
1059             return; \
1060         } \
1061     }
1062
1063 /**
1064  * Implements unmarshalling process branch for typed child singleton element
1065  * 
1066  * @param proper        the proper name of the child type
1067  * @param namespaceURI  the XML namespace of the child element
1068  * @param force         bypass use of hint and just cast down to check child
1069  */
1070 #define PROC_TYPED_CHILD(proper,namespaceURI,force) \
1071     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1072         proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
1073         if (typesafe && !m_##proper) { \
1074             typesafe->setParent(this); \
1075             *m_pos_##proper = m_##proper = typesafe; \
1076             return; \
1077         } \
1078     }
1079
1080 /**
1081  * Implements unmarshalling process branch for typed child singleton element
1082  * in a foreign namespace.
1083  * 
1084  * @param proper        the proper name of the child type
1085  * @param ns            the C++ namespace for the type
1086  * @param namespaceURI  the XML namespace of the child element
1087  * @param force         bypass use of hint and just cast down to check child
1088  */
1089 #define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \
1090     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
1091         ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
1092         if (typesafe && !m_##proper) { \
1093             typesafe->setParent(this); \
1094             *m_pos_##proper = m_##proper = typesafe; \
1095             return; \
1096         } \
1097     }
1098
1099 /**
1100  * Implements unmarshalling process branch for a generic child singleton element
1101  * 
1102  * @param proper        the proper name of the child type
1103  * @param namespaceURI  the XML namespace of the child element
1104  */
1105 #define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
1106     if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1107         if (!m_##proper) { \
1108             childXMLObject->setParent(this); \
1109             *m_pos_##proper = m_##proper = childXMLObject; \
1110             return; \
1111         } \
1112     }
1113
1114 /**
1115  * Declares aliased get/set methods for named XML element simple content.
1116  * 
1117  * @param proper    the proper name to label the element's content
1118  */
1119 #define DECL_SIMPLE_CONTENT(proper) \
1120     XMLTOOLING_DOXYGEN(Returns proper.) \
1121     const XMLCh* get##proper() const { \
1122         return getTextContent(); \
1123     } \
1124     XMLTOOLING_DOXYGEN(Sets or clears proper.) \
1125     void set##proper(const XMLCh* proper) { \
1126         setTextContent(proper); \
1127     }
1128
1129 /**
1130  * Declares aliased get/set methods for named integer XML element content.
1131  * 
1132  * @param proper    the proper name to label the element's content
1133  */
1134 #define DECL_INTEGER_CONTENT(proper) \
1135     XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \
1136     std::pair<bool,int> get##proper() const { \
1137         return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? xercesc::XMLString::parseInt(getTextContent()) : 0)); \
1138     } \
1139     XMLTOOLING_DOXYGEN(Sets proper.) \
1140     void set##proper(int proper) { \
1141         char buf[64]; \
1142         sprintf(buf,"%d",proper); \
1143         xmltooling::auto_ptr_XMLCh widebuf(buf); \
1144         setTextContent(widebuf.get()); \
1145     } \
1146     XMLTOOLING_DOXYGEN(Sets or clears proper.) \
1147     void set##proper(const XMLCh* proper) { \
1148         setTextContent(proper); \
1149     }
1150
1151 /**
1152  * Implements cloning methods for an XMLObject specialization implementation class.
1153  * 
1154  * @param cname    the name of the XMLObject specialization
1155  */
1156 #define IMPL_XMLOBJECT_CLONE(cname) \
1157     cname* clone##cname() const { \
1158         return dynamic_cast<cname*>(clone()); \
1159     } \
1160     xmltooling::XMLObject* clone() const { \
1161         std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
1162         cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
1163         if (ret) { \
1164             domClone.release(); \
1165             return ret; \
1166         } \
1167         return new cname##Impl(*this); \
1168     }
1169
1170 /**
1171  * Declares an XMLObject specialization with a simple content model and type,
1172  * handling it as string data.
1173  * 
1174  * @param linkage   linkage specifier for the class
1175  * @param cname     the name of the XMLObject specialization
1176  * @param proper    the proper name to label the element's content
1177  * @param desc      documentation for class
1178  */
1179 #define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \
1180     BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \
1181         DECL_SIMPLE_CONTENT(proper); \
1182     END_XMLOBJECT
1183
1184 /**
1185  * Declares and defines an implementation class for an XMLObject with
1186  * a simple content model and type, handling it as string data.
1187  * 
1188  * @param linkage   linkage specifier for the class
1189  * @param cname     the name of the XMLObject specialization
1190  */
1191 #define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname) \
1192     class linkage cname##Impl \
1193         : public virtual cname, \
1194             public xmltooling::AbstractSimpleElement, \
1195             public xmltooling::AbstractDOMCachingXMLObject, \
1196             public xmltooling::AbstractXMLObjectMarshaller, \
1197             public xmltooling::AbstractXMLObjectUnmarshaller \
1198     { \
1199     public: \
1200         virtual ~cname##Impl() {} \
1201         cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \
1202             : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \
1203         } \
1204         cname##Impl(const cname##Impl& src) \
1205             : xmltooling::AbstractXMLObject(src), \
1206                 xmltooling::AbstractSimpleElement(src), \
1207                 xmltooling::AbstractDOMCachingXMLObject(src) {} \
1208         IMPL_XMLOBJECT_CLONE(cname) \
1209     }
1210
1211 #ifdef HAVE_COVARIANT_RETURNS
1212
1213 /**
1214  * Begins the declaration of an XMLObjectBuilder specialization.
1215  * Basic boilerplate includes an empty virtual destructor, and
1216  * a default builder that defaults the element name.
1217  * 
1218  * @param linkage           linkage specifier for the class
1219  * @param cname             the name of the XMLObject specialization
1220  * @param namespaceURI      the XML namespace of the default associated element
1221  * @param namespacePrefix   the XML namespace prefix of the default associated element
1222  */
1223 #define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1224     XMLTOOLING_DOXYGEN(Builder for cname objects.) \
1225     class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \
1226     public: \
1227         virtual ~cname##Builder() {} \
1228         XMLTOOLING_DOXYGEN(Default builder.) \
1229         virtual cname* buildObject() const { \
1230             return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
1231         } \
1232         XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
1233         virtual cname* buildObject( \
1234             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
1235             ) const
1236
1237 /**
1238  * Ends the declaration of an XMLObjectBuilder specialization.
1239  */
1240 #define END_XMLOBJECTBUILDER }
1241
1242 /**
1243  * Declares a generic XMLObjectBuilder specialization.
1244  * 
1245  * @param linkage           linkage specifier for the class
1246  * @param cname             the name of the XMLObject specialization
1247  * @param namespaceURI      the XML namespace of the default associated element
1248  * @param namespacePrefix   the XML namespace prefix of the default associated element
1249  */
1250  #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1251     BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
1252     XMLTOOLING_DOXYGEN(Singleton builder.) \
1253     static cname* build##cname() { \
1254         const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
1255             XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
1256             ); \
1257         if (b) \
1258             return b->buildObject(); \
1259         throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
1260     } \
1261     END_XMLOBJECTBUILDER
1262
1263 /**
1264  * Implements the standard XMLObjectBuilder specialization function. 
1265  * 
1266  * @param cname the name of the XMLObject specialization
1267  */
1268 #define IMPL_XMLOBJECTBUILDER(cname) \
1269     cname* cname##Builder::buildObject( \
1270         const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \
1271         ) const \
1272     { \
1273         return new cname##Impl(nsURI,localName,prefix,schemaType); \
1274     }
1275
1276 #else   /* !HAVE_COVARIANT_RETURNS */
1277
1278 /**
1279  * Begins the declaration of an XMLObjectBuilder specialization.
1280  * Basic boilerplate includes an empty virtual destructor, and
1281  * a default builder that defaults the element name.
1282  * 
1283  * @param linkage           linkage specifier for the class
1284  * @param cname             the name of the XMLObject specialization
1285  * @param namespaceURI      the XML namespace of the default associated element
1286  * @param namespacePrefix   the XML namespace prefix of the default associated element
1287  */
1288 #define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1289     XMLTOOLING_DOXYGEN(Builder for cname objects.) \
1290     class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \
1291     public: \
1292         virtual ~cname##Builder() {} \
1293         XMLTOOLING_DOXYGEN(Default builder.) \
1294         virtual xmltooling::XMLObject* buildObject() const { \
1295             return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
1296         } \
1297         XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
1298         virtual xmltooling::XMLObject* buildObject( \
1299             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
1300             ) const
1301
1302 /**
1303  * Ends the declaration of an XMLObjectBuilder specialization.
1304  */
1305 #define END_XMLOBJECTBUILDER }
1306
1307 /**
1308  * Declares a generic XMLObjectBuilder specialization.
1309  * 
1310  * @param linkage           linkage specifier for the class
1311  * @param cname             the name of the XMLObject specialization
1312  * @param namespaceURI      the XML namespace of the default associated element
1313  * @param namespacePrefix   the XML namespace prefix of the default associated element
1314  */
1315  #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1316     BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
1317     XMLTOOLING_DOXYGEN(Singleton builder.) \
1318     static cname* build##cname() { \
1319         const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
1320             XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
1321             ); \
1322         if (b) \
1323             return dynamic_cast<cname*>(b->buildObject()); \
1324         throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
1325     } \
1326     END_XMLOBJECTBUILDER
1327
1328 /**
1329  * Implements the standard XMLObjectBuilder specialization function. 
1330  * 
1331  * @param cname the name of the XMLObject specialization
1332  */
1333 #define IMPL_XMLOBJECTBUILDER(cname) \
1334     xmltooling::XMLObject* cname##Builder::buildObject( \
1335         const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \
1336         ) const \
1337     { \
1338         return new cname##Impl(nsURI,localName,prefix,schemaType); \
1339     }
1340
1341 #endif  /* HAVE_COVARIANT_RETURNS */
1342
1343 /**
1344  * Begins the declaration of a Schema Validator specialization.
1345  * 
1346  * @param linkage           linkage specifier for the class
1347  * @param cname the base name of the Validator specialization
1348  */
1349  #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \
1350     class linkage cname##SchemaValidator : public xmltooling::Validator \
1351     { \
1352     public: \
1353         virtual ~cname##SchemaValidator() {} \
1354         virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1355             const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1356             if (!ptr) \
1357                 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())); \
1358             if (ptr->nil() && (ptr->hasChildren() || ptr->getTextContent())) \
1359                 throw xmltooling::ValidationException("Object has nil property but with children or content.")
1360
1361 /**
1362  * Begins the declaration of a Schema Validator specialization subclass.
1363  * 
1364  * @param linkage   linkage specifier for the class
1365  * @param cname     the base name of the Validator specialization
1366  * @param base      base class for the validator
1367  */
1368  #define BEGIN_XMLOBJECTVALIDATOR_SUB(linkage,cname,base) \
1369     class linkage cname##SchemaValidator : public base##SchemaValidator \
1370     { \
1371     public: \
1372         virtual ~cname##SchemaValidator() {} \
1373         virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1374             const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1375             if (!ptr) \
1376                 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()));
1377
1378 /**
1379  * Ends the declaration of a Validator specialization.
1380  */
1381 #define END_XMLOBJECTVALIDATOR } }
1382
1383 /**
1384  * Validator code that checks the object type.
1385  * 
1386  * @param cname     the name of the XMLObject specialization
1387  */
1388 #define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \
1389     const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1390     if (!ptr) \
1391         throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1392
1393 /**
1394  * Validator code that checks for a required attribute, content, or singleton.
1395  * 
1396  * @param cname     the name of the XMLObject specialization
1397  * @param proper    the proper name of the attribute, content, or singleton member 
1398  */
1399 #define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \
1400     if (!ptr->get##proper()) \
1401         throw xmltooling::ValidationException(#cname" must have "#proper".")
1402
1403 /**
1404  * Validator code that checks for a required integer attribute
1405  * 
1406  * @param cname     the name of the XMLObject specialization
1407  * @param proper    the proper name of the attribute, content, or singleton member 
1408  */
1409 #define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \
1410     if (!ptr->get##proper().first) \
1411         throw xmltooling::ValidationException(#cname" must have "#proper".")
1412
1413 /**
1414  * Validator code that checks for one of a pair of
1415  * required attributes, content, or singletons.
1416  * 
1417  * @param cname     the name of the XMLObject specialization
1418  * @param proper1   the proper name of the first attribute, content, or singleton member 
1419  * @param proper2   the proper name of the second attribute, content, or singleton member 
1420  */
1421 #define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \
1422     if (!ptr->get##proper1() && !ptr->get##proper2()) \
1423         throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2".")
1424
1425 /**
1426  * Validator code that checks for one of a pair of
1427  * required attributes, content, or singletons, but disallows both.
1428  * 
1429  * @param cname     the name of the XMLObject specialization
1430  * @param proper1   the proper name of the first attribute, content, or singleton member 
1431  * @param proper2   the proper name of the second attribute, content, or singleton member 
1432  */
1433 #define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \
1434     if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \
1435         throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2" but not both.")
1436
1437 /**
1438  * Validator code that checks for one of a set of three
1439  * required attributes, content, or singletons.
1440  * 
1441  * @param cname     the name of the XMLObject specialization
1442  * @param proper1   the proper name of the first attribute, content, or singleton member
1443  * @param proper2   the proper name of the second attribute, content, or singleton member
1444  * @param proper3   the proper name of the third attribute, content, or singleton member
1445  */
1446 #define XMLOBJECTVALIDATOR_ONEOF3(cname,proper1,proper2,proper3) \
1447     if (!ptr->get##proper1() && !ptr->get##proper2() && !ptr->get##proper3()) \
1448         throw xmltooling::ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".")
1449
1450 /**
1451  * Validator code that checks for one of a set of three
1452  * required attributes, content, or singletons but disallows more than one.
1453  * 
1454  * @param cname     the name of the XMLObject specialization
1455  * @param proper1   the proper name of the first attribute, content, or singleton member
1456  * @param proper2   the proper name of the second attribute, content, or singleton member
1457  * @param proper3   the proper name of the third attribute, content, or singleton member
1458  */
1459 #define XMLOBJECTVALIDATOR_ONLYONEOF3(cname,proper1,proper2,proper3) \
1460     int c##proper1##proper2##proper3=0; \
1461     if (ptr->get##proper1()!=NULL) \
1462         c##proper1##proper2##proper3++; \
1463     if (ptr->get##proper2()!=NULL) \
1464         c##proper1##proper2##proper3++; \
1465     if (ptr->get##proper3()!=NULL) \
1466         c##proper1##proper2##proper3++; \
1467     if (c##proper1##proper2##proper3 != 1) \
1468         throw xmltooling::ValidationException(#cname" must have only one of "#proper1", "#proper2", or "#proper3".")
1469
1470 /**
1471  * Validator code that checks a co-constraint (if one present, the other must be)
1472  * between a pair of attributes, content, or singletons.
1473  * 
1474  * @param cname     the name of the XMLObject specialization
1475  * @param proper1   the proper name of the first attribute, content, or singleton member 
1476  * @param proper2   the proper name of the second attribute, content, or singleton member 
1477  */
1478 #define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \
1479     if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \
1480         throw xmltooling::ValidationException(#cname" cannot have "#proper1" without "#proper2".")
1481
1482 /**
1483  * Validator code that checks for a non-empty collection.
1484  * 
1485  * @param cname     the name of the XMLObject specialization
1486  * @param proper    the proper name of the collection item 
1487  */
1488 #define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \
1489     if (ptr->get##proper##s().empty()) \
1490         throw xmltooling::ValidationException(#cname" must have at least one "#proper".")
1491
1492 /**
1493  * Declares/defines a Validator specialization that checks object type and
1494  * a non-empty simple content model.
1495  * 
1496  * @param linkage   linkage specifier for the class
1497  * @param cname     the name of the XMLObject specialization
1498  */
1499 #define XMLOBJECTVALIDATOR_SIMPLE(linkage,cname) \
1500     BEGIN_XMLOBJECTVALIDATOR(linkage,cname); \
1501         XMLOBJECTVALIDATOR_REQUIRE(cname,TextContent); \
1502     END_XMLOBJECTVALIDATOR
1503
1504 #include <utility>
1505
1506 /**
1507  * @namespace xmltooling
1508  * Public namespace of XML Tooling library
1509  */
1510 namespace xmltooling {
1511
1512     /**
1513      * Template function for cloning a sequence of XMLObjects.
1514      * Invokes the clone() member on each element of the input sequence and adds the copy to
1515      * the output sequence. Order is preserved.
1516      * 
1517      * @param in    input sequence to clone
1518      * @param out   output sequence to copy cloned pointers into
1519      */
1520     template<class InputSequence,class OutputSequence> void clone(const InputSequence& in, OutputSequence& out) {
1521         for (typename InputSequence::const_iterator i=in.begin(); i!=in.end(); i++) {
1522             if (*i)
1523                 out.push_back((*i)->clone());
1524             else
1525                 out.push_back(*i);
1526         }
1527     }
1528
1529     /**
1530      * Functor for cleaning up heap objects in containers.
1531      */
1532     template<class T> struct cleanup
1533     {
1534         /**
1535          * Function operator to delete an object.
1536          * 
1537          * @param ptr   object to delete
1538          */
1539         void operator()(T* ptr) {delete ptr;}
1540         
1541         /**
1542          * Function operator to delete an object stored as const.
1543          * 
1544          * @param ptr   object to delete after casting away const
1545          */
1546         void operator()(const T* ptr) {delete const_cast<T*>(ptr);}
1547     };
1548
1549     /**
1550      * Functor for cleaning up heap objects in key/value containers.
1551      */
1552     template<class A,class B> struct cleanup_pair
1553     {
1554         /**
1555          * Function operator to delete an object.
1556          * 
1557          * @param p   a pair in which the second component is the object to delete
1558          */
1559         void operator()(const std::pair<const A,B*>& p) {delete p.second;}
1560     };
1561
1562     /**
1563      * Functor for cleaning up const heap objects in key/value containers.
1564      */
1565     template<class A,class B> struct cleanup_const_pair
1566     {
1567         /**
1568          * Function operator to delete an object stored as const
1569          * 
1570          * @param p   a pair in which the second component is the const object to delete
1571          */
1572         void operator()(const std::pair<const A,const B*>& p) {delete const_cast<B*>(p.second);}
1573     };
1574 };
1575
1576 #endif /* __xmltooling_base_h__ */