2 * Copyright 2001-2006 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * Base header file definitions
21 * Must be included prior to including any other header
24 #ifndef __xmltooling_base_h__
25 #define __xmltooling_base_h__
27 #if defined (_MSC_VER) || defined(__BORLANDC__)
28 #include <xmltooling/config_pub_win32.h>
30 #include <xmltooling/config_pub.h>
33 // Windows and GCC4 Symbol Visibility Macros
35 #define XMLTOOL_IMPORT __declspec(dllimport)
36 #define XMLTOOL_EXPORT __declspec(dllexport)
37 #define XMLTOOL_DLLLOCAL
38 #define XMLTOOL_DLLPUBLIC
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")))
46 #define XMLTOOL_EXPORT
47 #define XMLTOOL_DLLLOCAL
48 #define XMLTOOL_DLLPUBLIC
52 // Define XMLTOOL_API for DLL builds
53 #ifdef XMLTOOLING_EXPORTS
54 #define XMLTOOL_API XMLTOOL_EXPORT
56 #define XMLTOOL_API XMLTOOL_IMPORT
59 // Throwable classes must always be visible on GCC in all binaries
61 #define XMLTOOL_EXCEPTIONAPI(api) api
62 #elif defined(GCC_HASCLASSVISIBILITY)
63 #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT
65 #define XMLTOOL_EXCEPTIONAPI(api)
69 #define XMLTOOLING_DOXYGEN(desc) /##** desc */
71 #define XMLTOOLING_DOXYGEN(desc)
75 * Blocks copy c'tor and assignment operator for a class.
77 #define MAKE_NONCOPYABLE(type) \
80 type& operator=(const type&);
86 #define UNICODE_LITERAL_1(a) {chLatin_##a, chNull}
87 #define UNICODE_LITERAL_2(a,b) {chLatin_##a, chLatin_##b, chNull}
88 #define UNICODE_LITERAL_3(a,b,c) {chLatin_##a, chLatin_##b, chLatin_##c, chNull}
89 #define UNICODE_LITERAL_4(a,b,c,d) {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chNull}
90 #define UNICODE_LITERAL_5(a,b,c,d,e) {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chNull}
91 #define UNICODE_LITERAL_6(a,b,c,d,e,f) {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chNull}
92 #define UNICODE_LITERAL_7(a,b,c,d,e,f,g) \
93 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chNull}
94 #define UNICODE_LITERAL_8(a,b,c,d,e,f,g,h) \
95 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chNull}
96 #define UNICODE_LITERAL_9(a,b,c,d,e,f,g,h,i) \
97 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, chNull}
98 #define UNICODE_LITERAL_10(a,b,c,d,e,f,g,h,i,j) \
99 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
101 #define UNICODE_LITERAL_11(a,b,c,d,e,f,g,h,i,j,k) \
102 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
103 chLatin_##j, chLatin_##k, chNull}
104 #define UNICODE_LITERAL_12(a,b,c,d,e,f,g,h,i,j,k,l) \
105 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
106 chLatin_##j, chLatin_##k, chLatin_##l, chNull}
107 #define UNICODE_LITERAL_13(a,b,c,d,e,f,g,h,i,j,k,l,m) \
108 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
109 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chNull}
110 #define UNICODE_LITERAL_14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) \
111 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
112 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chNull}
113 #define UNICODE_LITERAL_15(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \
114 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
115 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chNull}
116 #define UNICODE_LITERAL_16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
117 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
118 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chNull}
119 #define UNICODE_LITERAL_17(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) \
120 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
121 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chNull}
122 #define UNICODE_LITERAL_18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) \
123 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
124 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, chNull}
125 #define UNICODE_LITERAL_19(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) \
126 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
127 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
129 #define UNICODE_LITERAL_20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) \
130 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
131 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
132 chLatin_##s, chLatin_##t, chNull}
133 #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) \
134 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
135 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
136 chLatin_##s, chLatin_##t, chLatin_##u, chNull}
137 #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) \
138 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
139 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
140 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chNull}
141 #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) \
142 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
143 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
144 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chNull}
145 #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) \
146 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
147 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
148 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chNull}
149 #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) \
150 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
151 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
152 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chNull}
153 #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) \
154 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
155 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
156 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, chNull}
157 #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) \
158 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
159 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
160 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
161 chLatin_##aa, chNull}
162 #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) \
163 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
164 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
165 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
166 chLatin_##aa, chLatin_##bb, chNull}
167 #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) \
168 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
169 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
170 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
171 chLatin_##aa, chLatin_##bb, chLatin_##cc, chNull}
172 #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) \
173 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
174 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
175 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
176 chLatin_##aa, chLatin_##bb, chLatin_##cc, chLatin_##dd, chNull}
177 #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) \
178 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
179 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
180 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
181 chLatin_##aa, chLatin_##bb, chLatin_##cc, chLatin_##dd, chLatin_##ee, chNull}
182 #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) \
183 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
184 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
185 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
186 chLatin_##aa, chLatin_##bb, chLatin_##cc, chLatin_##dd, chLatin_##ee, chLatin_##ff, chNull}
187 #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) \
188 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
189 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
190 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
191 chLatin_##aa, chLatin_##bb, chLatin_##cc, chLatin_##dd, chLatin_##ee, chLatin_##ff, chLatin_##gg, chNull}
192 #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) \
193 {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
194 chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
195 chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, \
196 chLatin_##aa, chLatin_##bb, chLatin_##cc, chLatin_##dd, chLatin_##ee, chLatin_##ff, chLatin_##gg, chLatin_##hh, chNull}
197 #endif /* DOXYGEN_SKIP */
200 * Begins the declaration of an XMLObject specialization for an abstract element/type.
201 * Basic boilerplate includes a protected constructor, empty virtual destructor,
202 * and Unicode constants for the default associated element's name and prefix.
204 * @param linkage linkage specifier for the class
205 * @param cname the name of the class to declare
206 * @param base the base class to derive from using public virtual inheritance
207 * @param desc documentation comment for class
209 #define DECL_XMLOBJECT_ABSTRACT(linkage,cname,base,desc) \
210 XMLTOOLING_DOXYGEN(desc) \
211 class linkage cname : public virtual base { \
215 virtual ~cname() {} \
216 XMLTOOLING_DOXYGEN(Element local name) \
217 static const XMLCh LOCAL_NAME[]; \
221 * Begins the declaration of an XMLObject specialization.
222 * Basic boilerplate includes a protected constructor, empty virtual destructor,
223 * and Unicode constants for the default associated element's name and prefix.
225 * @param linkage linkage specifier for the class
226 * @param cname the name of the class to declare
227 * @param base the base class to derive from using public virtual inheritance
228 * @param desc documentation comment for class
230 #define BEGIN_XMLOBJECT(linkage,cname,base,desc) \
231 XMLTOOLING_DOXYGEN(desc) \
232 class linkage cname : public virtual base, public virtual xmltooling::ValidatingXMLObject { \
236 virtual ~cname() {} \
237 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
238 virtual cname* clone##cname() const=0; \
239 XMLTOOLING_DOXYGEN(Element local name) \
240 static const XMLCh LOCAL_NAME[]
243 * Begins the declaration of an XMLObject specialization with two base classes.
244 * Basic boilerplate includes a protected constructor, empty virtual destructor,
245 * and Unicode constants for the default associated element's name and prefix.
247 * @param linkage linkage specifier for the class
248 * @param cname the name of the class to declare
249 * @param base the first base class to derive from using public virtual inheritance
250 * @param base2 the second base class to derive from using public virtual inheritance
251 * @param desc documentation comment for class
253 #define BEGIN_XMLOBJECT2(linkage,cname,base,base2,desc) \
254 XMLTOOLING_DOXYGEN(desc) \
255 class linkage cname : public virtual base, public virtual base2, public virtual xmltooling::ValidatingXMLObject { \
259 virtual ~cname() {} \
260 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
261 virtual cname* clone##cname() const=0; \
262 XMLTOOLING_DOXYGEN(Element local name) \
263 static const XMLCh LOCAL_NAME[]
266 * Begins the declaration of an XMLObject specialization with three base classes.
267 * Basic boilerplate includes a protected constructor, empty virtual destructor,
268 * and Unicode constants for the default associated element's name and prefix.
270 * @param linkage linkage specifier for the class
271 * @param cname the name of the class to declare
272 * @param base the first base class to derive from using public virtual inheritance
273 * @param base2 the second base class to derive from using public virtual inheritance
274 * @param base3 the third base class to derive from using public virtual inheritance
275 * @param desc documentation comment for class
277 #define BEGIN_XMLOBJECT3(linkage,cname,base,base2,base3,desc) \
278 XMLTOOLING_DOXYGEN(desc) \
279 class linkage cname : public virtual base, public virtual base2, public virtual base3, \
280 public virtual xmltooling::ValidatingXMLObject { \
284 virtual ~cname() {} \
285 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
286 virtual cname* clone##cname() const=0; \
287 XMLTOOLING_DOXYGEN(Element local name) \
288 static const XMLCh LOCAL_NAME[]
291 * Begins the declaration of an XMLObject specialization with four base classes.
292 * Basic boilerplate includes a protected constructor, empty virtual destructor,
293 * and Unicode constants for the default associated element's name and prefix.
295 * @param linkage linkage specifier for the class
296 * @param cname the name of the class to declare
297 * @param base the first base class to derive from using public virtual inheritance
298 * @param base2 the second base class to derive from using public virtual inheritance
299 * @param base3 the third base class to derive from using public virtual inheritance
300 * @param base4 the fourth base class to derive from using public virtual inheritance
301 * @param desc documentation comment for class
303 #define BEGIN_XMLOBJECT4(linkage,cname,base,base2,base3,base4,desc) \
304 XMLTOOLING_DOXYGEN(desc) \
305 class linkage cname : public virtual base, public virtual base2, public virtual base3, \
306 public virtual base4, public virtual xmltooling::ValidatingXMLObject { \
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[]
317 * Ends the declaration of an XMLObject specialization.
319 #define END_XMLOBJECT }
322 * Declares abstract get/set methods for a typed XML attribute.
324 * @param proper the proper name of the attribute
325 * @param upcased the upcased name of the attribute
326 * @param type the attribute's data type
328 #define DECL_XMLOBJECT_ATTRIB(proper,upcased,type) \
330 XMLTOOLING_DOXYGEN(proper attribute name) \
331 static const XMLCh upcased##_ATTRIB_NAME[]; \
332 XMLTOOLING_DOXYGEN(Returns the proper attribute.) \
333 virtual const type* get##proper() const=0; \
334 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
335 virtual void set##proper(const type* proper)=0
338 * Declares abstract get/set methods for a string XML attribute.
340 * @param proper the proper name of the attribute
341 * @param upcased the upcased name of the attribute
343 #define DECL_STRING_ATTRIB(proper,upcased) \
344 DECL_XMLOBJECT_ATTRIB(proper,upcased,XMLCh)
347 * Declares abstract get/set methods for a string XML attribute.
349 * @param proper the proper name of the attribute
350 * @param upcased the upcased name of the attribute
352 #define DECL_DATETIME_ATTRIB(proper,upcased) \
353 DECL_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
354 XMLTOOLING_DOXYGEN(Returns the proper attribute in epoch form.) \
355 virtual time_t get##proper##Epoch() const=0; \
356 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
357 virtual void set##proper(time_t proper)=0; \
358 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
359 virtual void set##proper(const XMLCh* proper)=0
362 * Declares abstract get/set methods for an integer XML attribute.
364 * @param proper the proper name of the attribute
365 * @param upcased the upcased name of the attribute
367 #define DECL_INTEGER_ATTRIB(proper,upcased) \
369 XMLTOOLING_DOXYGEN(proper attribute name) \
370 static const XMLCh upcased##_ATTRIB_NAME[]; \
371 XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \
372 virtual std::pair<bool,int> get##proper() const=0; \
373 XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \
374 virtual void set##proper(const XMLCh* proper)=0; \
375 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
376 virtual void set##proper(int proper)=0
379 * Declares abstract get/set methods for a boolean XML attribute.
381 * @param proper the proper name of the attribute
382 * @param upcased the upcased name of the attribute
384 #define DECL_BOOLEAN_ATTRIB(proper,upcased) \
386 XMLTOOLING_DOXYGEN(proper attribute name) \
387 static const XMLCh upcased##_ATTRIB_NAME[]; \
388 XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \
389 virtual std::pair<bool,bool> proper() const=0; \
390 XMLTOOLING_DOXYGEN(Sets the proper attribute using an enumerated value.) \
391 virtual void proper(xmltooling::XMLConstants::xmltooling_bool_t value)=0; \
392 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
393 void proper(bool value) { \
394 proper(value ? xmltooling::XMLConstants::XML_BOOL_ONE : xmltooling::XMLConstants::XML_BOOL_ZERO); \
396 XMLTOOLING_DOXYGEN(Sets the proper attribute using a string constant.) \
397 void set##proper(const XMLCh* value) { \
401 proper(xmltooling::XMLConstants::XML_BOOL_TRUE); \
404 proper(xmltooling::XMLConstants::XML_BOOL_FALSE); \
407 proper(xmltooling::XMLConstants::XML_BOOL_ONE); \
410 proper(xmltooling::XMLConstants::XML_BOOL_ZERO); \
413 proper(xmltooling::XMLConstants::XML_BOOL_NULL); \
417 proper(xmltooling::XMLConstants::XML_BOOL_NULL); \
421 * Implements get/set methods and a private member for a typed XML attribute.
423 * @param proper the proper name of the attribute
424 * @param type the attribute's data type
426 #define IMPL_XMLOBJECT_ATTRIB(proper,type) \
430 const type* get##proper() const { \
433 void set##proper(const type* proper) { \
434 m_##proper = prepareForAssignment(m_##proper,proper); \
438 * Implements get/set methods and a private member for a string XML attribute.
440 * @param proper the proper name of the attribute
442 #define IMPL_STRING_ATTRIB(proper) \
443 IMPL_XMLOBJECT_ATTRIB(proper,XMLCh)
446 * Implements get/set methods and a private member for a DateTime XML attribute.
448 * @param proper the proper name of the attribute
449 * @param fallback epoch to return when attribute is NULL
451 #define IMPL_DATETIME_ATTRIB(proper,fallback) \
453 DateTime* m_##proper; \
454 time_t m_##proper##Epoch; \
456 const DateTime* get##proper() const { \
459 time_t get##proper##Epoch() const { \
460 return m_##proper ? m_##proper##Epoch : fallback; \
462 void set##proper(const DateTime* proper) { \
463 m_##proper = prepareForAssignment(m_##proper,proper); \
465 m_##proper##Epoch=m_##proper->getEpoch(); \
467 void set##proper(time_t proper) { \
468 m_##proper = prepareForAssignment(m_##proper,proper); \
469 m_##proper##Epoch = proper; \
471 void set##proper(const XMLCh* proper) { \
472 m_##proper = prepareForAssignment(m_##proper,proper); \
474 m_##proper##Epoch=m_##proper->getEpoch(); \
478 * Implements get/set methods and a private member for an integer XML attribute.
480 * @param proper the proper name of the attribute
482 #define IMPL_INTEGER_ATTRIB(proper) \
486 pair<bool,int> get##proper() const { \
487 return make_pair((m_##proper!=NULL),(m_##proper!=NULL ? XMLString::parseInt(m_##proper): NULL)); \
489 void set##proper(const XMLCh* proper) { \
490 m_##proper = prepareForAssignment(m_##proper,proper); \
492 void set##proper(int proper) { \
493 char buf##proper[64]; \
494 sprintf(buf##proper,"%d",proper); \
495 auto_ptr_XMLCh wide##proper(buf##proper); \
496 set##proper(wide##proper.get()); \
500 * Implements get/set methods and a private member for a boolean XML attribute.
502 * @param proper the proper name of the attribute
504 #define IMPL_BOOLEAN_ATTRIB(proper) \
506 XMLConstants::xmltooling_bool_t m_##proper; \
508 pair<bool,bool> proper() const { \
510 (m_##proper!=XMLConstants::XML_BOOL_NULL), \
511 (m_##proper==XMLConstants::XML_BOOL_TRUE || m_##proper==XMLConstants::XML_BOOL_ONE) \
514 void proper(XMLConstants::xmltooling_bool_t value) { \
515 if (m_##proper != value) { \
516 releaseThisandParentDOM(); \
517 m_##proper = value; \
522 * Declares abstract get/set methods for a typed XML child object in a foreign namespace.
524 * @param proper the proper name of the child type
525 * @param ns the C++ namespace for the type
527 #define DECL_TYPED_FOREIGN_CHILD(proper,ns) \
529 XMLTOOLING_DOXYGEN(Returns the proper child.) \
530 virtual ns::proper* get##proper() const=0; \
531 XMLTOOLING_DOXYGEN(Sets the proper child.) \
532 virtual void set##proper(ns::proper* child)=0
535 * Declares abstract get/set methods for a typed XML child object.
537 * @param proper the proper name of the child type
539 #define DECL_TYPED_CHILD(proper) \
541 XMLTOOLING_DOXYGEN(Returns the proper child.) \
542 virtual proper* get##proper() const=0; \
543 XMLTOOLING_DOXYGEN(Sets the proper child.) \
544 virtual void set##proper(proper* child)=0
547 * Declares abstract get/set methods for a generic XML child object.
549 * @param proper the proper name of the child
551 #define DECL_XMLOBJECT_CHILD(proper) \
553 XMLTOOLING_DOXYGEN(Returns the proper child.) \
554 virtual xmltooling::XMLObject* get##proper() const=0; \
555 XMLTOOLING_DOXYGEN(Sets the proper child.) \
556 virtual void set##proper(xmltooling::XMLObject* child)=0
560 * Implements get/set methods and a private list iterator member for a typed XML child object.
562 * @param proper the proper name of the child type
564 #define IMPL_TYPED_CHILD(proper) \
566 proper* m_##proper; \
567 std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
569 proper* get##proper() const { \
572 void set##proper(proper* child) { \
573 prepareForAssignment(m_##proper,child); \
574 *m_pos_##proper = m_##proper = child; \
578 * Implements get/set methods and a private list iterator member for
579 * a typed XML child object in a foreign namespace
581 * @param proper the proper name of the child type
582 * @param ns the C++ namespace for the type
584 #define IMPL_TYPED_FOREIGN_CHILD(proper,ns) \
586 ns::proper* m_##proper; \
587 std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
589 ns::proper* get##proper() const { \
592 void set##proper(ns::proper* child) { \
593 prepareForAssignment(m_##proper,child); \
594 *m_pos_##proper = m_##proper = child; \
598 * Implements get/set methods and a private list iterator member for a generic XML child object.
600 * @param proper the proper name of the child
602 #define IMPL_XMLOBJECT_CHILD(proper) \
604 xmltooling::XMLObject* m_##proper; \
605 std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
607 xmltooling::XMLObject* get##proper() const { \
610 void set##proper(xmltooling::XMLObject* child) { \
611 prepareForAssignment(m_##proper,child); \
612 *m_pos_##proper = m_##proper = child; \
616 * Declares abstract get/set methods for a typed XML child collection.
618 * @param proper the proper name of the child type
620 #define DECL_TYPED_CHILDREN(proper) \
622 XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
623 virtual VectorOf(proper) get##proper##s()=0; \
624 XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
625 virtual const std::vector<proper*>& get##proper##s() const=0
628 * Declares abstract get/set methods for a typed XML child collection in a foreign namespace.
630 * @param proper the proper name of the child type
631 * @param ns the C++ namespace for the type
633 #define DECL_TYPED_FOREIGN_CHILDREN(proper,ns) \
635 XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
636 virtual VectorOf(ns::proper) get##proper##s()=0; \
637 XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
638 virtual const std::vector<ns::proper*>& get##proper##s() const=0
641 * Declares abstract get/set methods for a generic XML child collection.
643 * @param proper the proper name of the child
645 #define DECL_XMLOBJECT_CHILDREN(proper) \
647 XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
648 virtual VectorOf(xmltooling::XMLObject) get##proper##s()=0; \
649 XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
650 virtual const std::vector<xmltooling::XMLObject*>& get##proper##s() const=0
653 * Implements get method and a private vector member for a typed XML child collection.
655 * @param proper the proper name of the child type
656 * @param fence insertion fence for new objects of the child collection in backing list
658 #define IMPL_TYPED_CHILDREN(proper,fence) \
660 std::vector<proper*> m_##proper##s; \
662 VectorOf(proper) get##proper##s() { \
663 return VectorOf(proper)(this, m_##proper##s, &m_children, fence); \
665 const std::vector<proper*>& get##proper##s() const { \
666 return m_##proper##s; \
670 * Implements get method and a private vector member for a typed XML child collection
671 * in a foreign namespace.
673 * @param proper the proper name of the child type
674 * @param ns the C++ namespace for the type
675 * @param fence insertion fence for new objects of the child collection in backing list
677 #define IMPL_TYPED_FOREIGN_CHILDREN(proper,ns,fence) \
679 std::vector<ns::proper*> m_##proper##s; \
681 VectorOf(ns::proper) get##proper##s() { \
682 return VectorOf(ns::proper)(this, m_##proper##s, &m_children, fence); \
684 const std::vector<ns::proper*>& get##proper##s() const { \
685 return m_##proper##s; \
689 * Implements get method and a private vector member for a generic XML child collection.
691 * @param proper the proper name of the child
692 * @param fence insertion fence for new objects of the child collection in backing list
694 #define IMPL_XMLOBJECT_CHILDREN(proper,fence) \
696 std::vector<xmltooling::XMLObject*> m_##proper##s; \
698 VectorOf(xmltooling::XMLObject) get##proper##s() { \
699 return VectorOf(xmltooling::XMLObject)(this, m_##proper##s, &m_children, fence); \
701 const std::vector<xmltooling::XMLObject*>& get##proper##s() const { \
702 return m_##proper##s; \
706 * Implements marshalling for a string attribute
708 * @param proper the proper name of the attribute
709 * @param ucase the upcased name of the attribute
710 * @param namespaceURI the XML namespace of the attribute
712 #define MARSHALL_STRING_ATTRIB(proper,ucase,namespaceURI) \
714 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
718 * Implements marshalling for a DateTime attribute
720 * @param proper the proper name of the attribute
721 * @param ucase the upcased name of the attribute
722 * @param namespaceURI the XML namespace of the attribute
724 #define MARSHALL_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
726 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper->getRawData()); \
730 * Implements marshalling for an integer attribute
732 * @param proper the proper name of the attribute
733 * @param ucase the upcased name of the attribute
734 * @param namespaceURI the XML namespace of the attribute
736 #define MARSHALL_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
738 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
742 * Implements marshalling for a boolean attribute
744 * @param proper the proper name of the attribute
745 * @param ucase the upcased name of the attribute
746 * @param namespaceURI the XML namespace of the attribute
748 #define MARSHALL_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
749 switch (m_##proper) { \
750 case XMLConstants::XML_BOOL_TRUE: \
751 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, XMLConstants::XML_TRUE); \
753 case XMLConstants::XML_BOOL_ONE: \
754 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, XMLConstants::XML_ONE); \
756 case XMLConstants::XML_BOOL_FALSE: \
757 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, XMLConstants::XML_FALSE); \
759 case XMLConstants::XML_BOOL_ZERO: \
760 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, XMLConstants::XML_ZERO); \
762 case XMLConstants::XML_BOOL_NULL: \
767 * Implements marshalling for a QName attribute
769 * @param proper the proper name of the attribute
770 * @param ucase the upcased name of the attribute
771 * @param namespaceURI the XML namespace of the attribute
773 #define MARSHALL_QNAME_ATTRIB(proper,ucase,namespaceURI) \
775 auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \
776 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \
780 * Implements marshalling for an ID attribute
782 * @param proper the proper name of the attribute
783 * @param ucase the upcased name of the attribute
784 * @param namespaceURI the XML namespace of the attribute
786 #define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \
788 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
789 domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \
793 * Implements unmarshalling process branch for a string attribute
795 * @param proper the proper name of the attribute
796 * @param ucase the upcased name of the attribute
797 * @param namespaceURI the XML namespace of the attribute
799 #define PROC_STRING_ATTRIB(proper,ucase,namespaceURI) \
800 if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
801 set##proper(attribute->getValue()); \
806 * Implements unmarshalling process branch for an ID attribute
808 * @param proper the proper name of the attribute
809 * @param ucase the upcased name of the attribute
810 * @param namespaceURI the XML namespace of the attribute
812 #define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \
813 if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
814 set##proper(attribute->getValue()); \
815 attribute->getOwnerElement()->setIdAttributeNode(attribute); \
820 * Implements unmarshalling process branch for a DateTime attribute
822 * @param proper the proper name of the attribute
823 * @param ucase the upcased name of the attribute
824 * @param namespaceURI the XML namespace of the attribute
826 #define PROC_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
827 PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
830 * Implements unmarshalling process branch for a DateTime attribute
832 * @param proper the proper name of the attribute
833 * @param ucase the upcased name of the attribute
834 * @param namespaceURI the XML namespace of the attribute
836 #define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \
837 if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
838 set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \
843 * Implements unmarshalling process branch for an integer attribute
845 * @param proper the proper name of the attribute
846 * @param ucase the upcased name of the attribute
847 * @param namespaceURI the XML namespace of the attribute
849 #define PROC_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
850 PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
853 * Implements unmarshalling process branch for a boolean attribute
855 * @param proper the proper name of the attribute
856 * @param ucase the upcased name of the attribute
857 * @param namespaceURI the XML namespace of the attribute
859 #define PROC_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
860 PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
863 * Implements unmarshalling process branch for typed child collection element
865 * @param proper the proper name of the child type
866 * @param namespaceURI the XML namespace of the child element
867 * @param force bypass use of hint and just cast down to check child
869 #define PROC_TYPED_CHILDREN(proper,namespaceURI,force) \
870 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
871 proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
873 get##proper##s().push_back(typesafe); \
879 * Implements unmarshalling process branch for typed child collection element
880 * in a foreign namespace.
882 * @param proper the proper name of the child type
883 * @param ns the C++ namespace for the type
884 * @param namespaceURI the XML namespace of the child element
885 * @param force bypass use of hint and just cast down to check child
887 #define PROC_TYPED_FOREIGN_CHILDREN(proper,ns,namespaceURI,force) \
888 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
889 ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
891 get##proper##s().push_back(typesafe); \
897 * Implements unmarshalling process branch for typed child singleton element
899 * @param proper the proper name of the child type
900 * @param namespaceURI the XML namespace of the child element
901 * @param force bypass use of hint and just cast down to check child
903 #define PROC_TYPED_CHILD(proper,namespaceURI,force) \
904 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
905 proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
907 set##proper(typesafe); \
913 * Implements unmarshalling process branch for typed child singleton element
914 * in a foreign namespace.
916 * @param proper the proper name of the child type
917 * @param ns the C++ namespace for the type
918 * @param namespaceURI the XML namespace of the child element
919 * @param force bypass use of hint and just cast down to check child
921 #define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \
922 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
923 ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
925 set##proper(typesafe); \
931 * Implements unmarshalling process branch for a generic child singleton element
933 * @param proper the proper name of the child type
934 * @param namespaceURI the XML namespace of the child element
936 #define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
937 if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
938 set##proper(childXMLObject); \
943 * Declares aliased get/set methods for named XML element content.
945 * @param proper the proper name to label the element's content
947 #define DECL_XMLOBJECT_CONTENT(proper) \
948 XMLTOOLING_DOXYGEN(Returns proper.) \
949 const XMLCh* get##proper() const { \
950 return getTextContent(); \
952 XMLTOOLING_DOXYGEN(Sets or clears proper.) \
953 void set##proper(const XMLCh* proper) { \
954 setTextContent(proper); \
958 * Declares aliased get/set methods for named integer XML element content.
960 * @param proper the proper name to label the element's content
962 #define DECL_INTEGER_CONTENT(proper) \
963 XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \
964 std::pair<bool,int> get##proper() const { \
965 return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? XMLString::parseInt(getTextContent()) : NULL)); \
967 XMLTOOLING_DOXYGEN(Sets proper.) \
968 void set##proper(int proper) { \
970 sprintf(buf,"%d",proper); \
971 xmltooling::auto_ptr_XMLCh widebuf(buf); \
972 setTextContent(widebuf.get()); \
974 XMLTOOLING_DOXYGEN(Sets or clears proper.) \
975 void set##proper(const XMLCh* proper) { \
976 setTextContent(proper); \
980 * Implements marshalling/unmarshalling for element content.
982 #define IMPL_XMLOBJECT_CONTENT \
984 void marshallElementContent(DOMElement* domElement) const { \
985 if(getTextContent()) { \
986 domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent())); \
989 void processElementContent(const XMLCh* elementContent) { \
990 setTextContent(elementContent); \
995 * Implements cloning methods for an XMLObject specialization implementation class.
997 * @param cname the name of the XMLObject specialization
999 #define IMPL_XMLOBJECT_CLONE(cname) \
1000 cname* clone##cname() const { \
1003 cname* clone() const { \
1004 std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
1005 cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
1007 domClone.release(); \
1010 return new cname##Impl(*this); \
1014 * Declares an XMLObject specialization with a simple content model and type,
1015 * handling it as string data.
1017 * @param linkage linkage specifier for the class
1018 * @param cname the name of the XMLObject specialization
1019 * @param proper the proper name to label the element's content
1020 * @param desc documentation for class
1022 #define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \
1023 BEGIN_XMLOBJECT(linkage,cname,xmltooling::SimpleElement,desc); \
1024 DECL_XMLOBJECT_CONTENT(proper); \
1028 * Declares and defines an implementation class for an XMLObject with
1029 * a simple content model and type, handling it as string data.
1031 * @param linkage linkage specifier for the class
1032 * @param cname the name of the XMLObject specialization
1034 #define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname) \
1035 class linkage cname##Impl \
1036 : public virtual cname, \
1037 public xmltooling::AbstractSimpleElement, \
1038 public xmltooling::AbstractChildlessElement, \
1039 public xmltooling::AbstractDOMCachingXMLObject, \
1040 public xmltooling::AbstractValidatingXMLObject, \
1041 public xmltooling::AbstractXMLObjectMarshaller, \
1042 public xmltooling::AbstractXMLObjectUnmarshaller \
1045 virtual ~cname##Impl() {} \
1046 cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \
1047 : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \
1049 cname##Impl(const cname##Impl& src) \
1050 : xmltooling::AbstractXMLObject(src), \
1051 xmltooling::AbstractSimpleElement(src), \
1052 xmltooling::AbstractDOMCachingXMLObject(src), \
1053 xmltooling::AbstractValidatingXMLObject(src) {} \
1054 IMPL_XMLOBJECT_CLONE(cname) \
1055 IMPL_XMLOBJECT_CONTENT \
1059 * Begins the declaration of an XMLObjectBuilder specialization.
1060 * Basic boilerplate includes an empty virtual destructor, and
1061 * a default builder that defaults the element name.
1063 * @param linkage linkage specifier for the class
1064 * @param cname the name of the XMLObject specialization
1065 * @param namespaceURI the XML namespace of the default associated element
1066 * @param namespacePrefix the XML namespace prefix of the default associated element
1068 #define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1069 XMLTOOLING_DOXYGEN(Builder for cname objects.) \
1070 class linkage cname##Builder : public xmltooling::XMLObjectBuilder { \
1072 virtual ~cname##Builder() {} \
1073 XMLTOOLING_DOXYGEN(Default builder.) \
1074 virtual cname* buildObject() const { \
1075 return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
1077 XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
1078 virtual cname* buildObject( \
1079 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
1083 * Ends the declaration of an XMLObjectBuilder specialization.
1085 #define END_XMLOBJECTBUILDER }
1088 * Declares a generic XMLObjectBuilder specialization.
1090 * @param linkage linkage specifier for the class
1091 * @param cname the name of the XMLObject specialization
1092 * @param namespaceURI the XML namespace of the default associated element
1093 * @param namespacePrefix the XML namespace prefix of the default associated element
1095 #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1096 BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
1097 XMLTOOLING_DOXYGEN(Singleton builder.) \
1098 static cname* build##cname() { \
1099 const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
1100 XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
1103 return b->buildObject(); \
1104 throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
1106 END_XMLOBJECTBUILDER
1109 * Implements the standard XMLObjectBuilder specialization function.
1111 * @param cname the name of the XMLObject specialization
1113 #define IMPL_XMLOBJECTBUILDER(cname) \
1114 cname* cname##Builder::buildObject( \
1115 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \
1118 return new cname##Impl(nsURI,localName,prefix,schemaType); \
1122 * Begins the declaration of a Schema Validator specialization.
1124 * @param linkage linkage specifier for the class
1125 * @param cname the base name of the Validator specialization
1127 #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \
1128 class linkage cname##SchemaValidator : public xmltooling::Validator \
1131 virtual ~cname##SchemaValidator() {} \
1132 virtual cname##SchemaValidator* clone() const { \
1133 return new cname##SchemaValidator(); \
1135 virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1136 const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1138 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1141 * Begins the declaration of a Schema Validator specialization subclass.
1143 * @param linkage linkage specifier for the class
1144 * @param cname the base name of the Validator specialization
1145 * @param base base class for the validator
1147 #define BEGIN_XMLOBJECTVALIDATOR_SUB(linkage,cname,base) \
1148 class linkage cname##SchemaValidator : public base##SchemaValidator \
1151 virtual ~cname##SchemaValidator() {} \
1152 virtual cname##SchemaValidator* clone() const { \
1153 return new cname##SchemaValidator(); \
1155 virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1156 const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1158 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1161 * Ends the declaration of a Validator specialization.
1163 #define END_XMLOBJECTVALIDATOR } }
1166 * Validator code that checks the object type.
1168 * @param cname the name of the XMLObject specialization
1170 #define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \
1171 const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1173 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1176 * Validator code that checks for a required attribute, content, or singleton.
1178 * @param cname the name of the XMLObject specialization
1179 * @param proper the proper name of the attribute, content, or singleton member
1181 #define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \
1182 if (!ptr->get##proper()) \
1183 throw xmltooling::ValidationException(#cname" must have "#proper".")
1186 * Validator code that checks for a required integer attribute
1188 * @param cname the name of the XMLObject specialization
1189 * @param proper the proper name of the attribute, content, or singleton member
1191 #define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \
1192 if (!ptr->get##proper().first) \
1193 throw xmltooling::ValidationException(#cname" must have "#proper".")
1196 * Validator code that checks for one of a pair of
1197 * required attributes, content, or singletons.
1199 * @param cname the name of the XMLObject specialization
1200 * @param proper1 the proper name of the first attribute, content, or singleton member
1201 * @param proper2 the proper name of the second attribute, content, or singleton member
1203 #define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \
1204 if (!ptr->get##proper1() && !ptr->get##proper2()) \
1205 throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2".")
1208 * Validator code that checks for one of a pair of
1209 * required attributes, content, or singletons, but disallows both.
1211 * @param cname the name of the XMLObject specialization
1212 * @param proper1 the proper name of the first attribute, content, or singleton member
1213 * @param proper2 the proper name of the second attribute, content, or singleton member
1215 #define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \
1216 if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \
1217 throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2" but not both.")
1220 * Validator code that checks for one of a set of three
1221 * required attributes, content, or singletons.
1223 * @param cname the name of the XMLObject specialization
1224 * @param proper1 the proper name of the first attribute, content, or singleton member
1225 * @param proper2 the proper name of the second attribute, content, or singleton member
1226 * @param proper3 the proper name of the third attribute, content, or singleton member
1228 #define XMLOBJECTVALIDATOR_ONEOF3(cname,proper1,proper2,proper3) \
1229 if (!ptr->get##proper1() && !ptr->get##proper2() && !ptr->get##proper3()) \
1230 throw xmltooling::ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".")
1233 * Validator code that checks for one of a set of three
1234 * required attributes, content, or singletons but disallows more than one.
1236 * @param cname the name of the XMLObject specialization
1237 * @param proper1 the proper name of the first attribute, content, or singleton member
1238 * @param proper2 the proper name of the second attribute, content, or singleton member
1239 * @param proper3 the proper name of the third attribute, content, or singleton member
1241 #define XMLOBJECTVALIDATOR_ONLYONEOF3(cname,proper1,proper2,proper3) \
1242 int c##proper1##proper2##proper3=0; \
1243 if (ptr->get##proper1()!=NULL) \
1244 c##proper1##proper2##proper3++; \
1245 if (ptr->get##proper2()!=NULL) \
1246 c##proper1##proper2##proper3++; \
1247 if (ptr->get##proper3()!=NULL) \
1248 c##proper1##proper2##proper3++; \
1249 if (c##proper1##proper2##proper3 != 1) \
1250 throw xmltooling::ValidationException(#cname" must have only one of "#proper1", "#proper2", or "#proper3".")
1253 * Validator code that checks a co-constraint (if one present, the other must be)
1254 * between a pair of attributes, content, or singletons.
1256 * @param cname the name of the XMLObject specialization
1257 * @param proper1 the proper name of the first attribute, content, or singleton member
1258 * @param proper2 the proper name of the second attribute, content, or singleton member
1260 #define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \
1261 if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \
1262 throw xmltooling::ValidationException(#cname" cannot have "#proper1" without "#proper2".")
1265 * Validator code that checks for a non-empty collection.
1267 * @param cname the name of the XMLObject specialization
1268 * @param proper the proper name of the collection item
1270 #define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \
1271 if (ptr->get##proper##s().empty()) \
1272 throw xmltooling::ValidationException(#cname" must have at least one "#proper".")
1275 * Declares/defines a Validator specialization that checks object type and
1276 * a non-empty simple content model.
1278 * @param linkage linkage specifier for the class
1279 * @param cname the name of the XMLObject specialization
1281 #define XMLOBJECTVALIDATOR_SIMPLE(linkage,cname) \
1282 BEGIN_XMLOBJECTVALIDATOR(linkage,cname); \
1283 XMLOBJECTVALIDATOR_REQUIRE(cname,TextContent); \
1284 END_XMLOBJECTVALIDATOR
1289 * @namespace xmltooling
1290 * Public namespace of XML Tooling library
1292 namespace xmltooling {
1295 * Template function for cloning a sequence of XMLObjects.
1296 * Invokes the clone() member on each element of the input sequence and adds the copy to
1297 * the output sequence. Order is preserved.
1299 * @param in input sequence to clone
1300 * @param out output sequence to copy cloned pointers into
1302 template<class InputSequence,class OutputSequence> void clone(const InputSequence& in, OutputSequence& out) {
1303 for (typename InputSequence::const_iterator i=in.begin(); i!=in.end(); i++) {
1305 out.push_back((*i)->clone());
1312 * Functor for cleaning up heap objects in containers.
1314 template<class T> struct cleanup
1317 * Function operator to delete an object.
1319 * @param ptr object to delete
1321 void operator()(T* ptr) {delete ptr;}
1324 * Function operator to delete an object stored as const.
1326 * @param ptr object to delete after casting away const
1328 void operator()(const T* ptr) {delete const_cast<T*>(ptr);}
1332 * Functor for cleaning up heap objects in key/value containers.
1334 template<class A,class B> struct cleanup_pair
1337 * Function operator to delete an object.
1339 * @param p a pair in which the second component is the object to delete
1341 void operator()(const std::pair<A,B*>& p) {delete p.second;}
1345 #endif /* __xmltooling_base_h__ */