237f79830b57e83d1136b1ac10f2e5eb435b693a
[shibboleth/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 abstract set method for a typed XML attribute.
353  * The get method is omitted.
354  * 
355  * @param proper    the proper name of the attribute
356  * @param upcased   the upcased name of the attribute
357  * @param type      the attribute's data type
358  */
359 #define DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,type) \
360     public: \
361         XMLTOOLING_DOXYGEN(proper attribute name) \
362         static const XMLCh upcased##_ATTRIB_NAME[]; \
363         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
364         virtual void set##proper(const type* proper)=0
365
366 /**
367  * Declares abstract get/set methods for a typed XML attribute.
368  * 
369  * @param proper    the proper name of the attribute
370  * @param upcased   the upcased name of the attribute
371  * @param type      the attribute's data type
372  */
373 #define DECL_XMLOBJECT_ATTRIB(proper,upcased,type) \
374     public: \
375         XMLTOOLING_DOXYGEN(proper attribute name) \
376         static const XMLCh upcased##_ATTRIB_NAME[]; \
377         XMLTOOLING_DOXYGEN(Returns the proper attribute.) \
378         virtual const type* get##proper() const=0; \
379         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
380         virtual void set##proper(const type* proper)=0
381
382 /**
383  * Declares abstract set method for a string XML attribute.
384  * The get method is omitted.
385  * 
386  * @param proper    the proper name of the attribute
387  * @param upcased   the upcased name of the attribute
388  */
389 #define DECL_INHERITED_STRING_ATTRIB(proper,upcased) \
390     DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,XMLCh)
391
392 /**
393  * Declares abstract get/set methods for a string XML attribute.
394  * 
395  * @param proper    the proper name of the attribute
396  * @param upcased   the upcased name of the attribute
397  */
398 #define DECL_STRING_ATTRIB(proper,upcased) \
399     DECL_XMLOBJECT_ATTRIB(proper,upcased,XMLCh)
400
401 /**
402  * Declares abstract set method for a DateTime XML attribute.
403  * The get method is omitted.
404  * 
405  * @param proper    the proper name of the attribute
406  * @param upcased   the upcased name of the attribute
407  */
408 #define DECL_INHERITED_DATETIME_ATTRIB(proper,upcased) \
409     DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
410     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
411     virtual void set##proper(time_t proper)=0; \
412     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
413     virtual void set##proper(const XMLCh* proper)=0
414
415 /**
416  * Declares abstract get/set methods for a DateTime XML attribute.
417  * 
418  * @param proper    the proper name of the attribute
419  * @param upcased   the upcased name of the attribute
420  */
421 #define DECL_DATETIME_ATTRIB(proper,upcased) \
422     DECL_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
423     XMLTOOLING_DOXYGEN(Returns the proper attribute in epoch form.) \
424     virtual time_t get##proper##Epoch() const=0; \
425     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
426     virtual void set##proper(time_t proper)=0; \
427     XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
428     virtual void set##proper(const XMLCh* proper)=0
429
430 /**
431  * Declares abstract set method for an integer XML attribute.
432  * The get method is omitted.
433  * 
434  * @param proper    the proper name of the attribute
435  * @param upcased   the upcased name of the attribute
436  */
437 #define DECL_INHERITED_INTEGER_ATTRIB(proper,upcased) \
438     public: \
439         XMLTOOLING_DOXYGEN(proper attribute name) \
440         static const XMLCh upcased##_ATTRIB_NAME[]; \
441         XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \
442         virtual void set##proper(const XMLCh* proper)=0; \
443         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
444         virtual void set##proper(int proper)=0
445
446 /**
447  * Declares abstract get/set methods for an integer XML attribute.
448  * 
449  * @param proper    the proper name of the attribute
450  * @param upcased   the upcased name of the attribute
451  */
452 #define DECL_INTEGER_ATTRIB(proper,upcased) \
453     public: \
454         XMLTOOLING_DOXYGEN(proper attribute name) \
455         static const XMLCh upcased##_ATTRIB_NAME[]; \
456         XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \
457         virtual std::pair<bool,int> get##proper() const=0; \
458         XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \
459         virtual void set##proper(const XMLCh* proper)=0; \
460         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
461         virtual void set##proper(int proper)=0
462
463 /**
464  * Declares abstract get/set methods for a boolean XML attribute.
465  * 
466  * @param proper    the proper name of the attribute
467  * @param upcased   the upcased name of the attribute
468  * @param def       the default/presumed value, if no explicit value has been set
469  */
470 #define DECL_BOOLEAN_ATTRIB(proper,upcased,def) \
471     public: \
472         XMLTOOLING_DOXYGEN(proper attribute name) \
473         static const XMLCh upcased##_ATTRIB_NAME[]; \
474         XMLTOOLING_DOXYGEN(Returns the proper attribute or def if not set.) \
475         bool proper() const { \
476             switch (get##proper()) { \
477                 case xmlconstants::XML_BOOL_TRUE: \
478                 case xmlconstants::XML_BOOL_ONE: \
479                     return true; \
480                 case xmlconstants::XML_BOOL_FALSE: \
481                 case xmlconstants::XML_BOOL_ZERO: \
482                     return false; \
483                 default: \
484                     return def; \
485             } \
486         } \
487         XMLTOOLING_DOXYGEN(Returns the proper attribute as an explicit enumerated value.) \
488         virtual xmlconstants::xmltooling_bool_t get##proper() const=0; \
489         XMLTOOLING_DOXYGEN(Sets the proper attribute using an enumerated value.) \
490         virtual void proper(xmlconstants::xmltooling_bool_t value)=0; \
491         XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
492         void proper(bool value) { \
493             proper(value ? xmlconstants::XML_BOOL_ONE : xmlconstants::XML_BOOL_ZERO); \
494         } \
495         XMLTOOLING_DOXYGEN(Sets the proper attribute using a string constant.) \
496         void set##proper(const XMLCh* value) { \
497             if (value) { \
498                 switch (*value) { \
499                     case xercesc::chLatin_t: \
500                         proper(xmlconstants::XML_BOOL_TRUE); \
501                         break; \
502                     case xercesc::chLatin_f: \
503                         proper(xmlconstants::XML_BOOL_FALSE); \
504                         break; \
505                     case xercesc::chDigit_1: \
506                         proper(xmlconstants::XML_BOOL_ONE); \
507                         break; \
508                     case xercesc::chDigit_0: \
509                         proper(xmlconstants::XML_BOOL_ZERO); \
510                         break; \
511                     default: \
512                         proper(xmlconstants::XML_BOOL_NULL); \
513                 } \
514             } \
515             else \
516                 proper(xmlconstants::XML_BOOL_NULL); \
517         }
518
519 /**
520  * Implements get/set methods and a private member for a typed XML attribute.
521  * 
522  * @param proper    the proper name of the attribute
523  * @param type      the attribute's data type
524  */
525 #define IMPL_XMLOBJECT_ATTRIB(proper,type) \
526     protected: \
527         type* m_##proper; \
528     public: \
529         const type* get##proper() const { \
530             return m_##proper; \
531         } \
532         void set##proper(const type* proper) { \
533             m_##proper = prepareForAssignment(m_##proper,proper); \
534         }
535
536 /**
537  * Implements get/set methods and a private member for a string XML attribute.
538  * 
539  * @param proper    the proper name of the attribute
540  */
541 #define IMPL_STRING_ATTRIB(proper) \
542     IMPL_XMLOBJECT_ATTRIB(proper,XMLCh)
543
544 /**
545  * Implements get/set methods and a private member for a string XML attribute,
546  * plus a getXMLID override.
547  * 
548  * @param proper    the proper name of the attribute
549  */
550 #define IMPL_ID_ATTRIB(proper) \
551     IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) \
552     const XMLCh* getXMLID() const { \
553         return m_##proper; \
554     }
555
556 /**
557  * Implements get/set methods and a private member for a DateTime XML attribute.
558  * 
559  * @param proper    the proper name of the attribute
560  * @param fallback  epoch to return when attribute is NULL
561  */
562 #define IMPL_DATETIME_ATTRIB(proper,fallback) \
563     protected: \
564         DateTime* m_##proper; \
565         time_t m_##proper##Epoch; \
566     public: \
567         const DateTime* get##proper() const { \
568             return m_##proper; \
569         } \
570         time_t get##proper##Epoch() const { \
571             return m_##proper ? m_##proper##Epoch : fallback; \
572         } \
573         void set##proper(const DateTime* proper) { \
574             m_##proper = prepareForAssignment(m_##proper,proper); \
575             if (m_##proper) \
576                 m_##proper##Epoch=m_##proper->getEpoch(); \
577         } \
578         void set##proper(time_t proper) { \
579             m_##proper = prepareForAssignment(m_##proper,proper); \
580             m_##proper##Epoch = proper; \
581         } \
582         void set##proper(const XMLCh* proper) { \
583             m_##proper = prepareForAssignment(m_##proper,proper); \
584             if (m_##proper) \
585                 m_##proper##Epoch=m_##proper->getEpoch(); \
586         }
587
588 /**
589  * Implements get/set methods and a private member for an integer XML attribute.
590  * 
591  * @param proper    the proper name of the attribute
592  */
593 #define IMPL_INTEGER_ATTRIB(proper) \
594     protected: \
595         XMLCh* m_##proper; \
596     public: \
597         pair<bool,int> get##proper() const { \
598             return make_pair((m_##proper!=NULL),(m_##proper!=NULL ? xercesc::XMLString::parseInt(m_##proper): 0)); \
599         } \
600         void set##proper(const XMLCh* proper) { \
601             m_##proper = prepareForAssignment(m_##proper,proper); \
602         } \
603         void set##proper(int proper) { \
604             char buf##proper[64]; \
605             sprintf(buf##proper,"%d",proper); \
606             auto_ptr_XMLCh wide##proper(buf##proper); \
607             set##proper(wide##proper.get()); \
608         }
609
610 /**
611  * Implements get/set methods and a private member for a boolean XML attribute.
612  * 
613  * @param proper    the proper name of the attribute
614  */
615 #define IMPL_BOOLEAN_ATTRIB(proper) \
616     protected: \
617         xmlconstants::xmltooling_bool_t m_##proper; \
618     public: \
619         xmlconstants::xmltooling_bool_t get##proper() const { \
620             return m_##proper; \
621         } \
622         void proper(xmlconstants::xmltooling_bool_t value) { \
623             if (m_##proper != value) { \
624                 releaseThisandParentDOM(); \
625                 m_##proper = value; \
626             } \
627         }
628
629 /**
630  * Declares abstract set method for a typed XML child object in a foreign namespace.
631  * The get method is omitted.
632  * 
633  * @param proper    the proper name of the child type
634  * @param ns        the C++ namespace for the type
635  */
636 #define DECL_INHERITED_TYPED_FOREIGN_CHILD(proper,ns) \
637     public: \
638         XMLTOOLING_DOXYGEN(Sets the proper child.) \
639         virtual void set##proper(ns::proper* child)=0
640
641 /**
642  * Declares abstract get/set methods for a typed XML child object in a foreign namespace.
643  * 
644  * @param proper    the proper name of the child type
645  * @param ns        the C++ namespace for the type
646  */
647 #define DECL_TYPED_FOREIGN_CHILD(proper,ns) \
648     public: \
649         XMLTOOLING_DOXYGEN(Returns the proper child.) \
650         virtual ns::proper* get##proper() const=0; \
651         XMLTOOLING_DOXYGEN(Sets the proper child.) \
652         virtual void set##proper(ns::proper* child)=0
653
654 /**
655  * Declares abstract set method for a typed XML child object.
656  * The get method is omitted.
657  * 
658  * @param proper    the proper name of the child type
659  */
660 #define DECL_INHERITED_TYPED_CHILD(proper) \
661     public: \
662         XMLTOOLING_DOXYGEN(Sets the proper child.) \
663         virtual void set##proper(proper* child)=0
664
665 /**
666  * Declares abstract get/set methods for a typed XML child object.
667  * 
668  * @param proper    the proper name of the child type
669  */
670 #define DECL_TYPED_CHILD(proper) \
671     public: \
672         XMLTOOLING_DOXYGEN(Returns the proper child.) \
673         virtual proper* get##proper() const=0; \
674         XMLTOOLING_DOXYGEN(Sets the proper child.) \
675         virtual void set##proper(proper* child)=0
676
677 /**
678  * Declares abstract get/set methods for a generic XML child object.
679  * 
680  * @param proper    the proper name of the child
681  */
682 #define DECL_XMLOBJECT_CHILD(proper) \
683     public: \
684         XMLTOOLING_DOXYGEN(Returns the proper child.) \
685         virtual xmltooling::XMLObject* get##proper() const=0; \
686         XMLTOOLING_DOXYGEN(Sets the proper child.) \
687         virtual void set##proper(xmltooling::XMLObject* child)=0
688
689
690 /**
691  * Implements get/set methods and a private list iterator member for a typed XML child object.
692  * 
693  * @param proper    the proper name of the child type
694  */
695 #define IMPL_TYPED_CHILD(proper) \
696     protected: \
697         proper* m_##proper; \
698         std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
699     public: \
700         proper* get##proper() const { \
701             return m_##proper; \
702         } \
703         void set##proper(proper* child) { \
704             prepareForAssignment(m_##proper,child); \
705             *m_pos_##proper = m_##proper = child; \
706         }
707
708 /**
709  * Implements get/set methods and a private list iterator member for
710  * a typed XML child object in a foreign namespace
711  * 
712  * @param proper    the proper name of the child type
713  * @param ns        the C++ namespace for the type
714  */
715 #define IMPL_TYPED_FOREIGN_CHILD(proper,ns) \
716     protected: \
717         ns::proper* m_##proper; \
718         std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
719     public: \
720         ns::proper* get##proper() const { \
721             return m_##proper; \
722         } \
723         void set##proper(ns::proper* child) { \
724             prepareForAssignment(m_##proper,child); \
725             *m_pos_##proper = m_##proper = child; \
726         }
727
728 /**
729  * Implements get/set methods and a private list iterator member for a generic XML child object.
730  * 
731  * @param proper    the proper name of the child
732  */
733 #define IMPL_XMLOBJECT_CHILD(proper) \
734     protected: \
735         xmltooling::XMLObject* m_##proper; \
736         std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
737     public: \
738         xmltooling::XMLObject* get##proper() const { \
739             return m_##proper; \
740         } \
741         void set##proper(xmltooling::XMLObject* child) { \
742             prepareForAssignment(m_##proper,child); \
743             *m_pos_##proper = m_##proper = child; \
744         }
745
746 /**
747  * Declares abstract get/set methods for a typed XML child collection.
748  * 
749  * @param proper    the proper name of the child type
750  */
751 #define DECL_TYPED_CHILDREN(proper) \
752     public: \
753         XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
754         virtual VectorOf(proper) get##proper##s()=0; \
755         XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
756         virtual const std::vector<proper*>& get##proper##s() const=0
757
758 /**
759  * Declares abstract get/set methods for a typed XML child collection in a foreign namespace.
760  * 
761  * @param proper    the proper name of the child type
762  * @param ns        the C++ namespace for the type
763  */
764 #define DECL_TYPED_FOREIGN_CHILDREN(proper,ns) \
765     public: \
766         XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
767         virtual VectorOf(ns::proper) get##proper##s()=0; \
768         XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
769         virtual const std::vector<ns::proper*>& get##proper##s() const=0
770
771 /**
772  * Declares abstract get/set methods for a generic XML child collection.
773  * 
774  * @param proper    the proper name of the child
775  */
776 #define DECL_XMLOBJECT_CHILDREN(proper) \
777     public: \
778         XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
779         virtual VectorOf(xmltooling::XMLObject) get##proper##s()=0; \
780         XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
781         virtual const std::vector<xmltooling::XMLObject*>& get##proper##s() const=0
782
783 /**
784  * Implements get method and a private vector member for a typed XML child collection.
785  * 
786  * @param proper    the proper name of the child type
787  * @param fence     insertion fence for new objects of the child collection in backing list
788  */
789 #define IMPL_TYPED_CHILDREN(proper,fence) \
790     protected: \
791         std::vector<proper*> m_##proper##s; \
792     public: \
793         VectorOf(proper) get##proper##s() { \
794             return VectorOf(proper)(this, m_##proper##s, &m_children, fence); \
795         } \
796         const std::vector<proper*>& get##proper##s() const { \
797             return m_##proper##s; \
798         } 
799
800 /**
801  * Implements get method and a private vector member for a typed XML child collection
802  * in a foreign namespace.
803  * 
804  * @param proper    the proper name of the child type
805  * @param ns        the C++ namespace for the type
806  * @param fence     insertion fence for new objects of the child collection in backing list
807  */
808 #define IMPL_TYPED_FOREIGN_CHILDREN(proper,ns,fence) \
809     protected: \
810         std::vector<ns::proper*> m_##proper##s; \
811     public: \
812         VectorOf(ns::proper) get##proper##s() { \
813             return VectorOf(ns::proper)(this, m_##proper##s, &m_children, fence); \
814         } \
815         const std::vector<ns::proper*>& get##proper##s() const { \
816             return m_##proper##s; \
817         } 
818
819 /**
820  * Implements get method and a private vector member for a generic XML child collection.
821  * 
822  * @param proper    the proper name of the child
823  * @param fence     insertion fence for new objects of the child collection in backing list
824  */
825 #define IMPL_XMLOBJECT_CHILDREN(proper,fence) \
826     protected: \
827         std::vector<xmltooling::XMLObject*> m_##proper##s; \
828     public: \
829         VectorOf(xmltooling::XMLObject) get##proper##s() { \
830             return VectorOf(xmltooling::XMLObject)(this, m_##proper##s, &m_children, fence); \
831         } \
832         const std::vector<xmltooling::XMLObject*>& get##proper##s() const { \
833             return m_##proper##s; \
834         } 
835
836 /**
837  * Implements marshalling for a string attribute
838  * 
839  * @param proper        the proper name of the attribute
840  * @param ucase         the upcased name of the attribute
841  * @param namespaceURI  the XML namespace of the attribute
842  */
843 #define MARSHALL_STRING_ATTRIB(proper,ucase,namespaceURI) \
844     if (m_##proper) { \
845         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
846     }
847
848 /**
849  * Implements marshalling for a DateTime attribute
850  * 
851  * @param proper        the proper name of the attribute
852  * @param ucase         the upcased name of the attribute
853  * @param namespaceURI  the XML namespace of the attribute
854  */
855 #define MARSHALL_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
856     if (m_##proper) { \
857         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper->getRawData()); \
858     }
859
860 /**
861  * Implements marshalling for an integer attribute
862  * 
863  * @param proper        the proper name of the attribute
864  * @param ucase         the upcased name of the attribute
865  * @param namespaceURI  the XML namespace of the attribute
866  */
867 #define MARSHALL_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
868     if (m_##proper) { \
869         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
870     }
871
872 /**
873  * Implements marshalling for a boolean 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_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
880     switch (m_##proper) { \
881         case xmlconstants::XML_BOOL_TRUE: \
882             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_TRUE); \
883             break; \
884         case xmlconstants::XML_BOOL_ONE: \
885             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ONE); \
886             break; \
887         case xmlconstants::XML_BOOL_FALSE: \
888             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_FALSE); \
889             break; \
890         case xmlconstants::XML_BOOL_ZERO: \
891             domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ZERO); \
892             break; \
893         case xmlconstants::XML_BOOL_NULL: \
894             break; \
895     }
896
897 /**
898  * Implements marshalling for a QName attribute
899  * 
900  * @param proper        the proper name of the attribute
901  * @param ucase         the upcased name of the attribute
902  * @param namespaceURI  the XML namespace of the attribute
903  */
904 #define MARSHALL_QNAME_ATTRIB(proper,ucase,namespaceURI) \
905     if (m_##proper) { \
906         auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \
907         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \
908     }
909
910 /**
911  * Implements marshalling for an ID attribute
912  * 
913  * @param proper        the proper name of the attribute
914  * @param ucase         the upcased name of the attribute
915  * @param namespaceURI  the XML namespace of the attribute
916  */
917 #define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \
918     if (m_##proper) { \
919         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
920         domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \
921     }
922
923 /**
924  * Implements unmarshalling process branch for a string attribute
925  * 
926  * @param proper        the proper name of the attribute
927  * @param ucase         the upcased name of the attribute
928  * @param namespaceURI  the XML namespace of the attribute
929  */
930 #define PROC_STRING_ATTRIB(proper,ucase,namespaceURI) \
931     if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
932         set##proper(attribute->getValue()); \
933         return; \
934     }
935
936 /**
937  * Implements unmarshalling process branch for an ID attribute
938  * 
939  * @param proper        the proper name of the attribute
940  * @param ucase         the upcased name of the attribute
941  * @param namespaceURI  the XML namespace of the attribute
942  */
943 #define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \
944     if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
945         set##proper(attribute->getValue()); \
946         attribute->getOwnerElement()->setIdAttributeNode(attribute); \
947         return; \
948     }
949
950 /**
951  * Implements unmarshalling process branch for a DateTime attribute
952  * 
953  * @param proper        the proper name of the attribute
954  * @param ucase         the upcased name of the attribute
955  * @param namespaceURI  the XML namespace of the attribute
956  */
957 #define PROC_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
958     PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
959
960 /**
961  * Implements unmarshalling process branch for a DateTime attribute
962  * 
963  * @param proper        the proper name of the attribute
964  * @param ucase         the upcased name of the attribute
965  * @param namespaceURI  the XML namespace of the attribute
966  */
967 #define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \
968     if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
969         set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \
970         return; \
971     }
972
973 /**
974  * Implements unmarshalling process branch for an integer attribute
975  * 
976  * @param proper        the proper name of the attribute
977  * @param ucase         the upcased name of the attribute
978  * @param namespaceURI  the XML namespace of the attribute
979  */
980 #define PROC_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
981     PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
982
983 /**
984  * Implements unmarshalling process branch for a boolean attribute
985  * 
986  * @param proper        the proper name of the attribute
987  * @param ucase         the upcased name of the attribute
988  * @param namespaceURI  the XML namespace of the attribute
989  */
990 #define PROC_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
991     PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
992
993 /**
994  * Implements unmarshalling process branch for typed child collection element
995  * 
996  * @param proper        the proper name of the child type
997  * @param namespaceURI  the XML namespace of the child element
998  * @param force         bypass use of hint and just cast down to check child
999  */
1000 #define PROC_TYPED_CHILDREN(proper,namespaceURI,force) \
1001     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1002         proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
1003         if (typesafe) { \
1004             get##proper##s().push_back(typesafe); \
1005             return; \
1006         } \
1007     }
1008
1009 /**
1010  * Implements unmarshalling process branch for typed child collection element
1011  * in a foreign namespace.
1012  * 
1013  * @param proper        the proper name of the child type
1014  * @param ns            the C++ namespace for the type
1015  * @param namespaceURI  the XML namespace of the child element
1016  * @param force         bypass use of hint and just cast down to check child
1017  */
1018 #define PROC_TYPED_FOREIGN_CHILDREN(proper,ns,namespaceURI,force) \
1019     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
1020         ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
1021         if (typesafe) { \
1022             get##proper##s().push_back(typesafe); \
1023             return; \
1024         } \
1025     }
1026
1027 /**
1028  * Implements unmarshalling process branch for typed child singleton element
1029  * 
1030  * @param proper        the proper name of the child type
1031  * @param namespaceURI  the XML namespace of the child element
1032  * @param force         bypass use of hint and just cast down to check child
1033  */
1034 #define PROC_TYPED_CHILD(proper,namespaceURI,force) \
1035     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1036         proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
1037         if (typesafe) { \
1038             set##proper(typesafe); \
1039             return; \
1040         } \
1041     }
1042
1043 /**
1044  * Implements unmarshalling process branch for typed child singleton element
1045  * in a foreign namespace.
1046  * 
1047  * @param proper        the proper name of the child type
1048  * @param ns            the C++ namespace for the type
1049  * @param namespaceURI  the XML namespace of the child element
1050  * @param force         bypass use of hint and just cast down to check child
1051  */
1052 #define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \
1053     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
1054         ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
1055         if (typesafe) { \
1056             set##proper(typesafe); \
1057             return; \
1058         } \
1059     }
1060
1061 /**
1062  * Implements unmarshalling process branch for a generic child singleton element
1063  * 
1064  * @param proper        the proper name of the child type
1065  * @param namespaceURI  the XML namespace of the child element
1066  */
1067 #define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
1068     if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1069         set##proper(childXMLObject); \
1070         return; \
1071     }
1072
1073 /**
1074  * Declares aliased get/set methods for named XML element simple content.
1075  * 
1076  * @param proper    the proper name to label the element's content
1077  */
1078 #define DECL_SIMPLE_CONTENT(proper) \
1079     XMLTOOLING_DOXYGEN(Returns proper.) \
1080     const XMLCh* get##proper() const { \
1081         return getTextContent(); \
1082     } \
1083     XMLTOOLING_DOXYGEN(Sets or clears proper.) \
1084     void set##proper(const XMLCh* proper) { \
1085         setTextContent(proper); \
1086     }
1087
1088 /**
1089  * Declares aliased get/set methods for named integer XML element content.
1090  * 
1091  * @param proper    the proper name to label the element's content
1092  */
1093 #define DECL_INTEGER_CONTENT(proper) \
1094     XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \
1095     std::pair<bool,int> get##proper() const { \
1096         return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? xercesc::XMLString::parseInt(getTextContent()) : NULL)); \
1097     } \
1098     XMLTOOLING_DOXYGEN(Sets proper.) \
1099     void set##proper(int proper) { \
1100         char buf[64]; \
1101         sprintf(buf,"%d",proper); \
1102         xmltooling::auto_ptr_XMLCh widebuf(buf); \
1103         setTextContent(widebuf.get()); \
1104     } \
1105     XMLTOOLING_DOXYGEN(Sets or clears proper.) \
1106     void set##proper(const XMLCh* proper) { \
1107         setTextContent(proper); \
1108     }
1109
1110 /**
1111  * Implements cloning methods for an XMLObject specialization implementation class.
1112  * 
1113  * @param cname    the name of the XMLObject specialization
1114  */
1115 #define IMPL_XMLOBJECT_CLONE(cname) \
1116     cname* clone##cname() const { \
1117         return dynamic_cast<cname*>(clone()); \
1118     } \
1119     xmltooling::XMLObject* clone() const { \
1120         std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
1121         cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
1122         if (ret) { \
1123             domClone.release(); \
1124             return ret; \
1125         } \
1126         return new cname##Impl(*this); \
1127     }
1128
1129 /**
1130  * Declares an XMLObject specialization with a simple content model and type,
1131  * handling it as string data.
1132  * 
1133  * @param linkage   linkage specifier for the class
1134  * @param cname     the name of the XMLObject specialization
1135  * @param proper    the proper name to label the element's content
1136  * @param desc      documentation for class
1137  */
1138 #define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \
1139     BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \
1140         DECL_SIMPLE_CONTENT(proper); \
1141     END_XMLOBJECT
1142
1143 /**
1144  * Declares and defines an implementation class for an XMLObject with
1145  * a simple content model and type, handling it as string data.
1146  * 
1147  * @param linkage   linkage specifier for the class
1148  * @param cname     the name of the XMLObject specialization
1149  */
1150 #define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname) \
1151     class linkage cname##Impl \
1152         : public virtual cname, \
1153             public xmltooling::AbstractSimpleElement, \
1154             public xmltooling::AbstractDOMCachingXMLObject, \
1155             public xmltooling::AbstractXMLObjectMarshaller, \
1156             public xmltooling::AbstractXMLObjectUnmarshaller \
1157     { \
1158     public: \
1159         virtual ~cname##Impl() {} \
1160         cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \
1161             : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \
1162         } \
1163         cname##Impl(const cname##Impl& src) \
1164             : xmltooling::AbstractXMLObject(src), \
1165                 xmltooling::AbstractSimpleElement(src), \
1166                 xmltooling::AbstractDOMCachingXMLObject(src) {} \
1167         IMPL_XMLOBJECT_CLONE(cname) \
1168     }
1169
1170 #ifdef HAVE_COVARIANT_RETURNS
1171
1172 /**
1173  * Begins the declaration of an XMLObjectBuilder specialization.
1174  * Basic boilerplate includes an empty virtual destructor, and
1175  * a default builder that defaults the element name.
1176  * 
1177  * @param linkage           linkage specifier for the class
1178  * @param cname             the name of the XMLObject specialization
1179  * @param namespaceURI      the XML namespace of the default associated element
1180  * @param namespacePrefix   the XML namespace prefix of the default associated element
1181  */
1182 #define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1183     XMLTOOLING_DOXYGEN(Builder for cname objects.) \
1184     class linkage cname##Builder : public xmltooling::XMLObjectBuilder { \
1185     public: \
1186         virtual ~cname##Builder() {} \
1187         XMLTOOLING_DOXYGEN(Default builder.) \
1188         virtual cname* buildObject() const { \
1189             return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
1190         } \
1191         XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
1192         virtual cname* buildObject( \
1193             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
1194             ) const
1195
1196 /**
1197  * Ends the declaration of an XMLObjectBuilder specialization.
1198  */
1199 #define END_XMLOBJECTBUILDER }
1200
1201 /**
1202  * Declares a generic XMLObjectBuilder specialization.
1203  * 
1204  * @param linkage           linkage specifier for the class
1205  * @param cname             the name of the XMLObject specialization
1206  * @param namespaceURI      the XML namespace of the default associated element
1207  * @param namespacePrefix   the XML namespace prefix of the default associated element
1208  */
1209  #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1210     BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
1211     XMLTOOLING_DOXYGEN(Singleton builder.) \
1212     static cname* build##cname() { \
1213         const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
1214             XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
1215             ); \
1216         if (b) \
1217             return b->buildObject(); \
1218         throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
1219     } \
1220     END_XMLOBJECTBUILDER
1221
1222 /**
1223  * Implements the standard XMLObjectBuilder specialization function. 
1224  * 
1225  * @param cname the name of the XMLObject specialization
1226  */
1227 #define IMPL_XMLOBJECTBUILDER(cname) \
1228     cname* cname##Builder::buildObject( \
1229         const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \
1230         ) const \
1231     { \
1232         return new cname##Impl(nsURI,localName,prefix,schemaType); \
1233     }
1234
1235 #else   /* !HAVE_COVARIANT_RETURNS */
1236
1237 /**
1238  * Begins the declaration of an XMLObjectBuilder specialization.
1239  * Basic boilerplate includes an empty virtual destructor, and
1240  * a default builder that defaults the element name.
1241  * 
1242  * @param linkage           linkage specifier for the class
1243  * @param cname             the name of the XMLObject specialization
1244  * @param namespaceURI      the XML namespace of the default associated element
1245  * @param namespacePrefix   the XML namespace prefix of the default associated element
1246  */
1247 #define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1248     XMLTOOLING_DOXYGEN(Builder for cname objects.) \
1249     class linkage cname##Builder : public xmltooling::XMLObjectBuilder { \
1250     public: \
1251         virtual ~cname##Builder() {} \
1252         XMLTOOLING_DOXYGEN(Default builder.) \
1253         virtual xmltooling::XMLObject* buildObject() const { \
1254             return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
1255         } \
1256         XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
1257         virtual xmltooling::XMLObject* buildObject( \
1258             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
1259             ) const
1260
1261 /**
1262  * Ends the declaration of an XMLObjectBuilder specialization.
1263  */
1264 #define END_XMLOBJECTBUILDER }
1265
1266 /**
1267  * Declares a generic XMLObjectBuilder specialization.
1268  * 
1269  * @param linkage           linkage specifier for the class
1270  * @param cname             the name of the XMLObject specialization
1271  * @param namespaceURI      the XML namespace of the default associated element
1272  * @param namespacePrefix   the XML namespace prefix of the default associated element
1273  */
1274  #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1275     BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
1276     XMLTOOLING_DOXYGEN(Singleton builder.) \
1277     static cname* build##cname() { \
1278         const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
1279             XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
1280             ); \
1281         if (b) \
1282             return dynamic_cast<cname*>(b->buildObject()); \
1283         throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
1284     } \
1285     END_XMLOBJECTBUILDER
1286
1287 /**
1288  * Implements the standard XMLObjectBuilder specialization function. 
1289  * 
1290  * @param cname the name of the XMLObject specialization
1291  */
1292 #define IMPL_XMLOBJECTBUILDER(cname) \
1293     xmltooling::XMLObject* cname##Builder::buildObject( \
1294         const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \
1295         ) const \
1296     { \
1297         return new cname##Impl(nsURI,localName,prefix,schemaType); \
1298     }
1299
1300 #endif  /* HAVE_COVARIANT_RETURNS */
1301
1302 /**
1303  * Begins the declaration of a Schema Validator specialization.
1304  * 
1305  * @param linkage           linkage specifier for the class
1306  * @param cname the base name of the Validator specialization
1307  */
1308  #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \
1309     class linkage cname##SchemaValidator : public xmltooling::Validator \
1310     { \
1311     public: \
1312         virtual ~cname##SchemaValidator() {} \
1313         virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1314             const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1315             if (!ptr) \
1316                 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1317
1318 /**
1319  * Begins the declaration of a Schema Validator specialization subclass.
1320  * 
1321  * @param linkage   linkage specifier for the class
1322  * @param cname     the base name of the Validator specialization
1323  * @param base      base class for the validator
1324  */
1325  #define BEGIN_XMLOBJECTVALIDATOR_SUB(linkage,cname,base) \
1326     class linkage cname##SchemaValidator : public base##SchemaValidator \
1327     { \
1328     public: \
1329         virtual ~cname##SchemaValidator() {} \
1330         virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1331             const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1332             if (!ptr) \
1333                 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1334
1335 /**
1336  * Ends the declaration of a Validator specialization.
1337  */
1338 #define END_XMLOBJECTVALIDATOR } }
1339
1340 /**
1341  * Validator code that checks the object type.
1342  * 
1343  * @param cname     the name of the XMLObject specialization
1344  */
1345 #define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \
1346     const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1347     if (!ptr) \
1348         throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1349
1350 /**
1351  * Validator code that checks for a required attribute, content, or singleton.
1352  * 
1353  * @param cname     the name of the XMLObject specialization
1354  * @param proper    the proper name of the attribute, content, or singleton member 
1355  */
1356 #define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \
1357     if (!ptr->get##proper()) \
1358         throw xmltooling::ValidationException(#cname" must have "#proper".")
1359
1360 /**
1361  * Validator code that checks for a required integer attribute
1362  * 
1363  * @param cname     the name of the XMLObject specialization
1364  * @param proper    the proper name of the attribute, content, or singleton member 
1365  */
1366 #define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \
1367     if (!ptr->get##proper().first) \
1368         throw xmltooling::ValidationException(#cname" must have "#proper".")
1369
1370 /**
1371  * Validator code that checks for one of a pair of
1372  * required attributes, content, or singletons.
1373  * 
1374  * @param cname     the name of the XMLObject specialization
1375  * @param proper1   the proper name of the first attribute, content, or singleton member 
1376  * @param proper2   the proper name of the second attribute, content, or singleton member 
1377  */
1378 #define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \
1379     if (!ptr->get##proper1() && !ptr->get##proper2()) \
1380         throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2".")
1381
1382 /**
1383  * Validator code that checks for one of a pair of
1384  * required attributes, content, or singletons, but disallows both.
1385  * 
1386  * @param cname     the name of the XMLObject specialization
1387  * @param proper1   the proper name of the first attribute, content, or singleton member 
1388  * @param proper2   the proper name of the second attribute, content, or singleton member 
1389  */
1390 #define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \
1391     if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \
1392         throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2" but not both.")
1393
1394 /**
1395  * Validator code that checks for one of a set of three
1396  * required attributes, content, or singletons.
1397  * 
1398  * @param cname     the name of the XMLObject specialization
1399  * @param proper1   the proper name of the first attribute, content, or singleton member
1400  * @param proper2   the proper name of the second attribute, content, or singleton member
1401  * @param proper3   the proper name of the third attribute, content, or singleton member
1402  */
1403 #define XMLOBJECTVALIDATOR_ONEOF3(cname,proper1,proper2,proper3) \
1404     if (!ptr->get##proper1() && !ptr->get##proper2() && !ptr->get##proper3()) \
1405         throw xmltooling::ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".")
1406
1407 /**
1408  * Validator code that checks for one of a set of three
1409  * required attributes, content, or singletons but disallows more than one.
1410  * 
1411  * @param cname     the name of the XMLObject specialization
1412  * @param proper1   the proper name of the first attribute, content, or singleton member
1413  * @param proper2   the proper name of the second attribute, content, or singleton member
1414  * @param proper3   the proper name of the third attribute, content, or singleton member
1415  */
1416 #define XMLOBJECTVALIDATOR_ONLYONEOF3(cname,proper1,proper2,proper3) \
1417     int c##proper1##proper2##proper3=0; \
1418     if (ptr->get##proper1()!=NULL) \
1419         c##proper1##proper2##proper3++; \
1420     if (ptr->get##proper2()!=NULL) \
1421         c##proper1##proper2##proper3++; \
1422     if (ptr->get##proper3()!=NULL) \
1423         c##proper1##proper2##proper3++; \
1424     if (c##proper1##proper2##proper3 != 1) \
1425         throw xmltooling::ValidationException(#cname" must have only one of "#proper1", "#proper2", or "#proper3".")
1426
1427 /**
1428  * Validator code that checks a co-constraint (if one present, the other must be)
1429  * between a pair of attributes, content, or singletons.
1430  * 
1431  * @param cname     the name of the XMLObject specialization
1432  * @param proper1   the proper name of the first attribute, content, or singleton member 
1433  * @param proper2   the proper name of the second attribute, content, or singleton member 
1434  */
1435 #define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \
1436     if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \
1437         throw xmltooling::ValidationException(#cname" cannot have "#proper1" without "#proper2".")
1438
1439 /**
1440  * Validator code that checks for a non-empty collection.
1441  * 
1442  * @param cname     the name of the XMLObject specialization
1443  * @param proper    the proper name of the collection item 
1444  */
1445 #define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \
1446     if (ptr->get##proper##s().empty()) \
1447         throw xmltooling::ValidationException(#cname" must have at least one "#proper".")
1448
1449 /**
1450  * Declares/defines a Validator specialization that checks object type and
1451  * a non-empty simple content model.
1452  * 
1453  * @param linkage   linkage specifier for the class
1454  * @param cname     the name of the XMLObject specialization
1455  */
1456 #define XMLOBJECTVALIDATOR_SIMPLE(linkage,cname) \
1457     BEGIN_XMLOBJECTVALIDATOR(linkage,cname); \
1458         XMLOBJECTVALIDATOR_REQUIRE(cname,TextContent); \
1459     END_XMLOBJECTVALIDATOR
1460
1461 #include <utility>
1462
1463 /**
1464  * @namespace xmltooling
1465  * Public namespace of XML Tooling library
1466  */
1467 namespace xmltooling {
1468
1469     /**
1470      * Template function for cloning a sequence of XMLObjects.
1471      * Invokes the clone() member on each element of the input sequence and adds the copy to
1472      * the output sequence. Order is preserved.
1473      * 
1474      * @param in    input sequence to clone
1475      * @param out   output sequence to copy cloned pointers into
1476      */
1477     template<class InputSequence,class OutputSequence> void clone(const InputSequence& in, OutputSequence& out) {
1478         for (typename InputSequence::const_iterator i=in.begin(); i!=in.end(); i++) {
1479             if (*i)
1480                 out.push_back((*i)->clone());
1481             else
1482                 out.push_back(*i);
1483         }
1484     }
1485
1486     /**
1487      * Functor for cleaning up heap objects in containers.
1488      */
1489     template<class T> struct cleanup
1490     {
1491         /**
1492          * Function operator to delete an object.
1493          * 
1494          * @param ptr   object to delete
1495          */
1496         void operator()(T* ptr) {delete ptr;}
1497         
1498         /**
1499          * Function operator to delete an object stored as const.
1500          * 
1501          * @param ptr   object to delete after casting away const
1502          */
1503         void operator()(const T* ptr) {delete const_cast<T*>(ptr);}
1504     };
1505
1506     /**
1507      * Functor for cleaning up heap objects in key/value containers.
1508      */
1509     template<class A,class B> struct cleanup_pair
1510     {
1511         /**
1512          * Function operator to delete an object.
1513          * 
1514          * @param p   a pair in which the second component is the object to delete
1515          */
1516         void operator()(const std::pair<const A,B*>& p) {delete p.second;}
1517     };
1518
1519     /**
1520      * Functor for cleaning up const heap objects in key/value containers.
1521      */
1522     template<class A,class B> struct cleanup_const_pair
1523     {
1524         /**
1525          * Function operator to delete an object stored as const
1526          * 
1527          * @param p   a pair in which the second component is the const object to delete
1528          */
1529         void operator()(const std::pair<const A,const B*>& p) {delete const_cast<B*>(p.second);}
1530     };
1531 };
1532
1533 #endif /* __xmltooling_base_h__ */