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