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