2 * Copyright 2001-2010 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.
18 * @file xmltooling/base.h
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__
29 /* Required for sprintf, used by integer XML attribute macros. */
32 #if defined (_MSC_VER) || defined(__BORLANDC__)
33 #include <xmltooling/config_pub_win32.h>
35 #include <xmltooling/config_pub.h>
38 #ifdef XMLTOOLING_LITE
39 # define XMLTOOLING_NO_XMLSEC 1
46 #if defined(XMLTOOLING_NO_XMLSEC) || !defined(HAVE_XSECSIZE_T)
47 # ifdef XMLTOOLING_XERCESC_64BITSAFE
48 # include <xercesc/util/XercesDefs.hpp>
49 typedef XMLSize_t xsecsize_t;
51 typedef unsigned int xsecsize_t;
55 // Windows and GCC4 Symbol Visibility Macros
57 #define XMLTOOL_IMPORT __declspec(dllimport)
58 #define XMLTOOL_EXPORT __declspec(dllexport)
59 #define XMLTOOL_DLLLOCAL
60 #define XMLTOOL_DLLPUBLIC
62 #define XMLTOOL_IMPORT
63 #ifdef GCC_HASCLASSVISIBILITY
64 #define XMLTOOL_EXPORT __attribute__ ((visibility("default")))
65 #define XMLTOOL_DLLLOCAL __attribute__ ((visibility("hidden")))
66 #define XMLTOOL_DLLPUBLIC __attribute__ ((visibility("default")))
68 #define XMLTOOL_EXPORT
69 #define XMLTOOL_DLLLOCAL
70 #define XMLTOOL_DLLPUBLIC
74 // Define XMLTOOL_API for DLL builds
75 #ifdef XMLTOOLING_EXPORTS
76 #define XMLTOOL_API XMLTOOL_EXPORT
78 #define XMLTOOL_API XMLTOOL_IMPORT
81 // Throwable classes must always be visible on GCC in all binaries
83 #define XMLTOOL_EXCEPTIONAPI(api) api
84 #elif defined(GCC_HASCLASSVISIBILITY)
85 #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT
87 #define XMLTOOL_EXCEPTIONAPI(api)
91 #define XMLTOOLING_DOXYGEN(desc) /##** desc */
93 #define XMLTOOLING_DOXYGEN(desc)
97 * Blocks copy c'tor and assignment operator for a class.
99 #define MAKE_NONCOPYABLE(type) \
102 type& operator=(const type&)
108 #define UNICODE_LITERAL_1(a) {xercesc::chLatin_##a, xercesc::chNull}
109 #define UNICODE_LITERAL_2(a,b) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chNull}
110 #define UNICODE_LITERAL_3(a,b,c) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chNull}
111 #define UNICODE_LITERAL_4(a,b,c,d) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chNull}
112 #define UNICODE_LITERAL_5(a,b,c,d,e) \
113 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chNull}
114 #define UNICODE_LITERAL_6(a,b,c,d,e,f) \
115 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chNull}
116 #define UNICODE_LITERAL_7(a,b,c,d,e,f,g) \
117 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chNull}
118 #define UNICODE_LITERAL_8(a,b,c,d,e,f,g,h) \
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::chNull}
120 #define UNICODE_LITERAL_9(a,b,c,d,e,f,g,h,i) \
121 {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}
122 #define UNICODE_LITERAL_10(a,b,c,d,e,f,g,h,i,j) \
123 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
124 xercesc::chLatin_##j, xercesc::chNull}
125 #define UNICODE_LITERAL_11(a,b,c,d,e,f,g,h,i,j,k) \
126 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
127 xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chNull}
128 #define UNICODE_LITERAL_12(a,b,c,d,e,f,g,h,i,j,k,l) \
129 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
130 xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chNull}
131 #define UNICODE_LITERAL_13(a,b,c,d,e,f,g,h,i,j,k,l,m) \
132 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
133 xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chNull}
134 #define UNICODE_LITERAL_14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) \
135 {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, \
136 xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chNull}
137 #define UNICODE_LITERAL_15(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \
138 {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, \
139 xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chNull}
140 #define UNICODE_LITERAL_16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
141 {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, \
142 xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chNull}
143 #define UNICODE_LITERAL_17(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) \
144 {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chLatin_##h, xercesc::chLatin_##i, \
145 xercesc::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chLatin_##q, xercesc::chNull}
146 #define UNICODE_LITERAL_18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) \
147 {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, \
148 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}
149 #define UNICODE_LITERAL_19(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) \
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::chNull}
153 #define UNICODE_LITERAL_20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) \
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::chNull}
157 #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) \
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::chNull}
161 #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) \
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::chNull}
165 #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) \
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::chNull}
169 #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) \
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::chNull}
173 #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) \
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::chNull}
177 #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) \
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, xercesc::chNull}
181 #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) \
182 {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, \
183 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, \
184 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
185 xercesc::chLatin_##aa, xercesc::chNull}
186 #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) \
187 {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, \
188 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, \
189 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
190 xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chNull}
191 #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) \
192 {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, \
193 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, \
194 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
195 xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chNull}
196 #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) \
197 {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, \
198 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, \
199 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
200 xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chNull}
201 #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) \
202 {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, \
203 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, \
204 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
205 xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chNull}
206 #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) \
207 {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, \
208 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, \
209 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
210 xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chNull}
211 #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) \
212 {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, \
213 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, \
214 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
215 xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chLatin_##gg, xercesc::chNull}
216 #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) \
217 {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, \
218 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, \
219 xercesc::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \
220 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}
221 #endif /* DOXYGEN_SKIP */
224 * Begins the declaration of an XMLObject specialization for an abstract element/type.
225 * Basic boilerplate includes a protected constructor, empty virtual destructor,
226 * and Unicode constants for the default associated element's name and prefix.
228 * @param linkage linkage specifier for the class
229 * @param cname the name of the class to declare
230 * @param base the base class to derive from using public virtual inheritance
231 * @param desc documentation comment for class
233 #define DECL_XMLOBJECT_ABSTRACT(linkage,cname,base,desc) \
234 XMLTOOLING_DOXYGEN(desc) \
235 class linkage cname : public virtual base { \
239 virtual ~cname() {} \
240 XMLTOOLING_DOXYGEN(Element local name) \
241 static const XMLCh LOCAL_NAME[]; \
245 * Begins the declaration of an XMLObject specialization.
246 * Basic boilerplate includes a protected constructor, empty virtual destructor,
247 * and Unicode constants for the default associated element's name and prefix.
249 * @param linkage linkage specifier for the class
250 * @param cname the name of the class to declare
251 * @param base the base class to derive from using public virtual inheritance
252 * @param desc documentation comment for class
254 #define BEGIN_XMLOBJECT(linkage,cname,base,desc) \
255 XMLTOOLING_DOXYGEN(desc) \
256 class linkage cname : public virtual base { \
260 virtual ~cname() {} \
261 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
262 virtual cname* clone##cname() const=0; \
263 XMLTOOLING_DOXYGEN(Element local name) \
264 static const XMLCh LOCAL_NAME[]
267 * Begins the declaration of an XMLObject specialization with two base classes.
268 * Basic boilerplate includes a protected constructor, empty virtual destructor,
269 * and Unicode constants for the default associated element's name and prefix.
271 * @param linkage linkage specifier for the class
272 * @param cname the name of the class to declare
273 * @param base the first base class to derive from using public virtual inheritance
274 * @param base2 the second base class to derive from using public virtual inheritance
275 * @param desc documentation comment for class
277 #define BEGIN_XMLOBJECT2(linkage,cname,base,base2,desc) \
278 XMLTOOLING_DOXYGEN(desc) \
279 class linkage cname : public virtual base, public virtual base2 { \
283 virtual ~cname() {} \
284 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
285 virtual cname* clone##cname() const=0; \
286 XMLTOOLING_DOXYGEN(Element local name) \
287 static const XMLCh LOCAL_NAME[]
290 * Begins the declaration of an XMLObject specialization with three base classes.
291 * Basic boilerplate includes a protected constructor, empty virtual destructor,
292 * and Unicode constants for the default associated element's name and prefix.
294 * @param linkage linkage specifier for the class
295 * @param cname the name of the class to declare
296 * @param base the first base class to derive from using public virtual inheritance
297 * @param base2 the second base class to derive from using public virtual inheritance
298 * @param base3 the third base class to derive from using public virtual inheritance
299 * @param desc documentation comment for class
301 #define BEGIN_XMLOBJECT3(linkage,cname,base,base2,base3,desc) \
302 XMLTOOLING_DOXYGEN(desc) \
303 class linkage cname : public virtual base, public virtual base2, public virtual base3 { \
307 virtual ~cname() {} \
308 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
309 virtual cname* clone##cname() const=0; \
310 XMLTOOLING_DOXYGEN(Element local name) \
311 static const XMLCh LOCAL_NAME[]
314 * Begins the declaration of an XMLObject specialization with four base classes.
315 * Basic boilerplate includes a protected constructor, empty virtual destructor,
316 * and Unicode constants for the default associated element's name and prefix.
318 * @param linkage linkage specifier for the class
319 * @param cname the name of the class to declare
320 * @param base the first base class to derive from using public virtual inheritance
321 * @param base2 the second base class to derive from using public virtual inheritance
322 * @param base3 the third base class to derive from using public virtual inheritance
323 * @param base4 the fourth base class to derive from using public virtual inheritance
324 * @param desc documentation comment for class
326 #define BEGIN_XMLOBJECT4(linkage,cname,base,base2,base3,base4,desc) \
327 XMLTOOLING_DOXYGEN(desc) \
328 class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4 { \
332 virtual ~cname() {} \
333 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
334 virtual cname* clone##cname() const=0; \
335 XMLTOOLING_DOXYGEN(Element local name) \
336 static const XMLCh LOCAL_NAME[]
339 * Begins the declaration of an XMLObject specialization with five base classes.
340 * Basic boilerplate includes a protected constructor, empty virtual destructor,
341 * and Unicode constants for the default associated element's name and prefix.
343 * @param linkage linkage specifier for the class
344 * @param cname the name of the class to declare
345 * @param base the first base class to derive from using public virtual inheritance
346 * @param base2 the second base class to derive from using public virtual inheritance
347 * @param base3 the third base class to derive from using public virtual inheritance
348 * @param base4 the fourth base class to derive from using public virtual inheritance
349 * @param base5 the fifth base class to derive from using public virtual inheritance
350 * @param desc documentation comment for class
352 #define BEGIN_XMLOBJECT5(linkage,cname,base,base2,base3,base4,base5,desc) \
353 XMLTOOLING_DOXYGEN(desc) \
354 class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4, public virtual base5 { \
358 virtual ~cname() {} \
359 XMLTOOLING_DOXYGEN(Type-specific clone method.) \
360 virtual cname* clone##cname() const=0; \
361 XMLTOOLING_DOXYGEN(Element local name) \
362 static const XMLCh LOCAL_NAME[]
365 * Ends the declaration of an XMLObject specialization.
367 #define END_XMLOBJECT }
370 * Declares a static variable holding the XMLObject's element QName.
372 #define DECL_ELEMENT_QNAME \
374 XMLTOOLING_DOXYGEN(Element QName) \
375 static xmltooling::QName ELEMENT_QNAME
378 * Declares a static variable holding the XMLObject's schema type QName.
380 #define DECL_TYPE_QNAME \
382 XMLTOOLING_DOXYGEN(Type QName) \
383 static xmltooling::QName TYPE_QNAME
386 * Implements a static variable holding an XMLObject's element QName.
388 * @param cname the name of the XMLObject specialization
389 * @param namespaceURI the XML namespace of the default associated element
390 * @param namespacePrefix the XML namespace prefix of the default associated element
392 #define IMPL_ELEMENT_QNAME(cname,namespaceURI,namespacePrefix) \
393 xmltooling::QName cname::ELEMENT_QNAME(namespaceURI,cname::LOCAL_NAME,namespacePrefix)
396 * Implements a static variable holding an XMLObject's schema type QName.
398 * @param cname the name of the XMLObject specialization
399 * @param namespaceURI the XML namespace of the default associated element
400 * @param namespacePrefix the XML namespace prefix of the default associated element
402 #define IMPL_TYPE_QNAME(cname,namespaceURI,namespacePrefix) \
403 xmltooling::QName cname::TYPE_QNAME(namespaceURI,cname::TYPE_NAME,namespacePrefix)
406 * Declares abstract set method for a typed XML attribute.
407 * The get method is omitted.
409 * @param proper the proper name of the attribute
410 * @param upcased the upcased name of the attribute
411 * @param type the attribute's data type
413 #define DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,type) \
415 XMLTOOLING_DOXYGEN(proper attribute name) \
416 static const XMLCh upcased##_ATTRIB_NAME[]; \
417 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
418 virtual void set##proper(const type* proper)=0
421 * Declares abstract get/set methods for a typed XML attribute.
423 * @param proper the proper name of the attribute
424 * @param upcased the upcased name of the attribute
425 * @param type the attribute's data type
427 #define DECL_XMLOBJECT_ATTRIB(proper,upcased,type) \
429 XMLTOOLING_DOXYGEN(proper attribute name) \
430 static const XMLCh upcased##_ATTRIB_NAME[]; \
431 XMLTOOLING_DOXYGEN(Returns the proper attribute.) \
432 virtual const type* get##proper() const=0; \
433 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
434 virtual void set##proper(const type* proper)=0
437 * Declares abstract set method for a string XML attribute.
438 * The get method is omitted.
440 * @param proper the proper name of the attribute
441 * @param upcased the upcased name of the attribute
443 #define DECL_INHERITED_STRING_ATTRIB(proper,upcased) \
444 DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,XMLCh)
447 * Declares abstract get/set methods for a string XML attribute.
449 * @param proper the proper name of the attribute
450 * @param upcased the upcased name of the attribute
452 #define DECL_STRING_ATTRIB(proper,upcased) \
453 DECL_XMLOBJECT_ATTRIB(proper,upcased,XMLCh)
456 * Declares abstract set method for a DateTime XML attribute.
457 * The get method is omitted.
459 * @param proper the proper name of the attribute
460 * @param upcased the upcased name of the attribute
462 #define DECL_INHERITED_DATETIME_ATTRIB(proper,upcased) \
463 DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
464 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
465 virtual void set##proper(time_t proper)=0; \
466 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
467 virtual void set##proper(const XMLCh* proper)=0
470 * Declares abstract get/set methods for a DateTime XML attribute.
472 * @param proper the proper name of the attribute
473 * @param upcased the upcased name of the attribute
475 #define DECL_DATETIME_ATTRIB(proper,upcased) \
476 DECL_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
477 XMLTOOLING_DOXYGEN(Returns the proper attribute in epoch form.) \
478 virtual time_t get##proper##Epoch() const=0; \
479 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
480 virtual void set##proper(time_t proper)=0; \
481 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
482 virtual void set##proper(const XMLCh* proper)=0
485 * Declares abstract set method for an integer XML attribute.
486 * The get method is omitted.
488 * @param proper the proper name of the attribute
489 * @param upcased the upcased name of the attribute
491 #define DECL_INHERITED_INTEGER_ATTRIB(proper,upcased) \
493 XMLTOOLING_DOXYGEN(proper attribute name) \
494 static const XMLCh upcased##_ATTRIB_NAME[]; \
495 XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \
496 virtual void set##proper(const XMLCh* proper)=0; \
497 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
498 virtual void set##proper(int proper)=0
501 * Declares abstract get/set methods for an integer XML attribute.
503 * @param proper the proper name of the attribute
504 * @param upcased the upcased name of the attribute
506 #define DECL_INTEGER_ATTRIB(proper,upcased) \
508 XMLTOOLING_DOXYGEN(proper attribute name) \
509 static const XMLCh upcased##_ATTRIB_NAME[]; \
510 XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \
511 virtual std::pair<bool,int> get##proper() const=0; \
512 XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \
513 virtual void set##proper(const XMLCh* proper)=0; \
514 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
515 virtual void set##proper(int proper)=0
518 * Declares abstract get/set methods for a boolean XML attribute.
520 * @param proper the proper name of the attribute
521 * @param upcased the upcased name of the attribute
522 * @param def the default/presumed value, if no explicit value has been set
524 #define DECL_BOOLEAN_ATTRIB(proper,upcased,def) \
526 XMLTOOLING_DOXYGEN(proper attribute name) \
527 static const XMLCh upcased##_ATTRIB_NAME[]; \
528 XMLTOOLING_DOXYGEN(Returns the proper attribute or def if not set.) \
529 bool proper() const { \
530 switch (get##proper()) { \
531 case xmlconstants::XML_BOOL_TRUE: \
532 case xmlconstants::XML_BOOL_ONE: \
534 case xmlconstants::XML_BOOL_FALSE: \
535 case xmlconstants::XML_BOOL_ZERO: \
541 XMLTOOLING_DOXYGEN(Returns the proper attribute as an explicit enumerated value.) \
542 virtual xmlconstants::xmltooling_bool_t get##proper() const=0; \
543 XMLTOOLING_DOXYGEN(Sets the proper attribute using an enumerated value.) \
544 virtual void proper(xmlconstants::xmltooling_bool_t value)=0; \
545 XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
546 void proper(bool value) { \
547 proper(value ? xmlconstants::XML_BOOL_ONE : xmlconstants::XML_BOOL_ZERO); \
549 XMLTOOLING_DOXYGEN(Sets the proper attribute using a string constant.) \
550 void set##proper(const XMLCh* value) { \
553 case xercesc::chLatin_t: \
554 proper(xmlconstants::XML_BOOL_TRUE); \
556 case xercesc::chLatin_f: \
557 proper(xmlconstants::XML_BOOL_FALSE); \
559 case xercesc::chDigit_1: \
560 proper(xmlconstants::XML_BOOL_ONE); \
562 case xercesc::chDigit_0: \
563 proper(xmlconstants::XML_BOOL_ZERO); \
566 proper(xmlconstants::XML_BOOL_NULL); \
570 proper(xmlconstants::XML_BOOL_NULL); \
574 * Implements get/set methods and a private member for a typed XML attribute.
576 * @param proper the proper name of the attribute
577 * @param type the attribute's data type
579 #define IMPL_XMLOBJECT_ATTRIB(proper,type) \
583 const type* get##proper() const { \
586 void set##proper(const type* proper) { \
587 m_##proper = prepareForAssignment(m_##proper,proper); \
591 * Implements get/set methods and a private member for a string XML attribute.
593 * @param proper the proper name of the attribute
595 #define IMPL_STRING_ATTRIB(proper) \
596 IMPL_XMLOBJECT_ATTRIB(proper,XMLCh)
599 * Implements get/set methods and a private member for a string XML attribute,
600 * plus a getXMLID override.
602 * @param proper the proper name of the attribute
604 #define IMPL_ID_ATTRIB(proper) \
605 IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) \
606 const XMLCh* getXMLID() const { \
611 * Implements get/set methods and a private member for a string XML attribute,
612 * plus a getXMLID override and attribute node clearance when DOM is dropped.
614 * @param proper the proper name of the attribute
615 * @param ucase the upcased name of the attribute
616 * @param namespaceURI the XML namespace of the attribute
618 #define IMPL_ID_ATTRIB_EX(proper, ucase, namespaceURI) \
619 IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) \
620 const XMLCh* getXMLID() const { \
623 void releaseDOM() const { \
625 getDOM()->removeAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \
626 AbstractDOMCachingXMLObject::releaseDOM(); \
630 * Implements get/set methods and a private member for a DateTime XML attribute.
632 * @param proper the proper name of the attribute
633 * @param fallback epoch to return when attribute is NULL
635 #define IMPL_DATETIME_ATTRIB(proper,fallback) \
636 IMPL_DATETIME_ATTRIB_EX(proper,fallback,false)
639 * Implements get/set methods and a private member for a duration-valued DateTime XML attribute.
641 * @param proper the proper name of the attribute
642 * @param fallback epoch to return when attribute is NULL
644 #define IMPL_DURATION_ATTRIB(proper,fallback) \
645 IMPL_DATETIME_ATTRIB_EX(proper,fallback,true)
648 * Implements get/set methods and a private member for a DateTime XML attribute.
650 * @param proper the proper name of the attribute
651 * @param fallback epoch to return when attribute is NULL
652 * @param duration true iff the attribute should be handled as a duration
654 #define IMPL_DATETIME_ATTRIB_EX(proper,fallback,duration) \
656 DateTime* m_##proper; \
657 time_t m_##proper##Epoch; \
659 const DateTime* get##proper() const { \
662 time_t get##proper##Epoch() const { \
663 return m_##proper ? m_##proper##Epoch : fallback; \
665 void set##proper(const DateTime* proper) { \
666 m_##proper = prepareForAssignment(m_##proper,proper); \
668 m_##proper##Epoch=m_##proper->getEpoch(duration); \
670 void set##proper(time_t proper) { \
671 m_##proper = prepareForAssignment(m_##proper,proper,duration); \
672 m_##proper##Epoch = proper; \
674 void set##proper(const XMLCh* proper) { \
675 m_##proper = prepareForAssignment(m_##proper,proper,duration); \
677 m_##proper##Epoch=m_##proper->getEpoch(duration); \
681 * Implements get/set methods and a private member for an integer XML attribute.
683 * @param proper the proper name of the attribute
685 #define IMPL_INTEGER_ATTRIB(proper) \
689 pair<bool,int> get##proper() const { \
690 return make_pair((m_##proper!=nullptr),(m_##proper!=nullptr ? xercesc::XMLString::parseInt(m_##proper): 0)); \
692 void set##proper(const XMLCh* proper) { \
693 m_##proper = prepareForAssignment(m_##proper,proper); \
695 void set##proper(int proper) { \
696 char buf##proper[64]; \
697 sprintf(buf##proper,"%d",proper); \
698 auto_ptr_XMLCh wide##proper(buf##proper); \
699 set##proper(wide##proper.get()); \
703 * Implements get/set methods and a private member for a boolean XML attribute.
705 * @param proper the proper name of the attribute
707 #define IMPL_BOOLEAN_ATTRIB(proper) \
709 xmlconstants::xmltooling_bool_t m_##proper; \
711 xmlconstants::xmltooling_bool_t get##proper() const { \
714 void proper(xmlconstants::xmltooling_bool_t value) { \
715 if (m_##proper != value) { \
716 releaseThisandParentDOM(); \
717 m_##proper = value; \
722 * Implements get/set methods and a private member for a typed, qualified XML attribute.
724 * @param proper the proper name of the attribute
725 * @param type the attribute's data type
727 #define IMPL_XMLOBJECT_FOREIGN_ATTRIB(proper,type) \
729 XMLCh* m_##proper##Prefix; \
732 const type* get##proper() const { \
735 void set##proper(const type* proper) { \
736 m_##proper = prepareForAssignment(m_##proper,proper); \
737 XMLString::release(&m_##proper##Prefix); \
738 m_##proper##Prefix = nullptr; \
742 * Declares abstract set method for a typed XML child object in a foreign namespace.
743 * The get method is omitted.
745 * @param proper the proper name of the child type
746 * @param ns the C++ namespace for the type
748 #define DECL_INHERITED_TYPED_FOREIGN_CHILD(proper,ns) \
750 XMLTOOLING_DOXYGEN(Sets the proper child.) \
751 virtual void set##proper(ns::proper* child)=0
754 * Declares abstract get/set methods for a typed XML child object in a foreign namespace.
756 * @param proper the proper name of the child type
757 * @param ns the C++ namespace for the type
759 #define DECL_TYPED_FOREIGN_CHILD(proper,ns) \
761 XMLTOOLING_DOXYGEN(Returns the proper child.) \
762 virtual ns::proper* get##proper() const=0; \
763 XMLTOOLING_DOXYGEN(Sets the proper child.) \
764 virtual void set##proper(ns::proper* child)=0
767 * Declares abstract set method for a typed XML child object.
768 * The get method is omitted.
770 * @param proper the proper name of the child type
772 #define DECL_INHERITED_TYPED_CHILD(proper) \
774 XMLTOOLING_DOXYGEN(Sets the proper child.) \
775 virtual void set##proper(proper* child)=0
778 * Declares abstract get/set methods for a typed XML child object.
780 * @param proper the proper name of the child type
782 #define DECL_TYPED_CHILD(proper) \
784 XMLTOOLING_DOXYGEN(Returns the proper child.) \
785 virtual proper* get##proper() const=0; \
786 XMLTOOLING_DOXYGEN(Sets the proper child.) \
787 virtual void set##proper(proper* child)=0
790 * Declares abstract get/set methods for a generic XML child object.
792 * @param proper the proper name of the child
794 #define DECL_XMLOBJECT_CHILD(proper) \
796 XMLTOOLING_DOXYGEN(Returns the proper child.) \
797 virtual xmltooling::XMLObject* get##proper() const=0; \
798 XMLTOOLING_DOXYGEN(Sets the proper child.) \
799 virtual void set##proper(xmltooling::XMLObject* child)=0
803 * Implements get/set methods and a private list iterator member for a typed XML child object.
805 * @param proper the proper name of the child type
807 #define IMPL_TYPED_CHILD(proper) \
809 proper* m_##proper; \
810 std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
812 proper* get##proper() const { \
815 void set##proper(proper* child) { \
816 prepareForAssignment(m_##proper,child); \
817 *m_pos_##proper = m_##proper = child; \
821 * Implements get/set methods and a private list iterator member for
822 * a typed XML child object in a foreign namespace
824 * @param proper the proper name of the child type
825 * @param ns the C++ namespace for the type
827 #define IMPL_TYPED_FOREIGN_CHILD(proper,ns) \
829 ns::proper* m_##proper; \
830 std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
832 ns::proper* get##proper() const { \
835 void set##proper(ns::proper* child) { \
836 prepareForAssignment(m_##proper,child); \
837 *m_pos_##proper = m_##proper = child; \
841 * Implements get/set methods and a private list iterator member for a generic XML child object.
843 * @param proper the proper name of the child
845 #define IMPL_XMLOBJECT_CHILD(proper) \
847 xmltooling::XMLObject* m_##proper; \
848 std::list<xmltooling::XMLObject*>::iterator m_pos_##proper; \
850 xmltooling::XMLObject* get##proper() const { \
853 void set##proper(xmltooling::XMLObject* child) { \
854 prepareForAssignment(m_##proper,child); \
855 *m_pos_##proper = m_##proper = child; \
859 * Declares abstract get/set methods for a typed XML child collection.
861 * @param proper the proper name of the child type
863 #define DECL_TYPED_CHILDREN(proper) \
865 XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
866 virtual VectorOf(proper) get##proper##s()=0; \
867 XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
868 virtual const std::vector<proper*>& get##proper##s() const=0
871 * Declares abstract get/set methods for a typed XML child collection in a foreign namespace.
873 * @param proper the proper name of the child type
874 * @param ns the C++ namespace for the type
876 #define DECL_TYPED_FOREIGN_CHILDREN(proper,ns) \
878 XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
879 virtual VectorOf(ns::proper) get##proper##s()=0; \
880 XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
881 virtual const std::vector<ns::proper*>& get##proper##s() const=0
884 * Declares abstract get/set methods for a generic XML child collection.
886 * @param proper the proper name of the child
888 #define DECL_XMLOBJECT_CHILDREN(proper) \
890 XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
891 virtual VectorOf(xmltooling::XMLObject) get##proper##s()=0; \
892 XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
893 virtual const std::vector<xmltooling::XMLObject*>& get##proper##s() const=0
896 * Implements get method and a private vector member for a typed XML child collection.
898 * @param proper the proper name of the child type
899 * @param fence insertion fence for new objects of the child collection in backing list
901 #define IMPL_TYPED_CHILDREN(proper,fence) \
903 std::vector<proper*> m_##proper##s; \
905 VectorOf(proper) get##proper##s() { \
906 return VectorOf(proper)(this, m_##proper##s, &m_children, fence); \
908 const std::vector<proper*>& get##proper##s() const { \
909 return m_##proper##s; \
913 * Implements get method and a private vector member for a typed XML child collection
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 fence insertion fence for new objects of the child collection in backing list
920 #define IMPL_TYPED_FOREIGN_CHILDREN(proper,ns,fence) \
922 std::vector<ns::proper*> m_##proper##s; \
924 VectorOf(ns::proper) get##proper##s() { \
925 return VectorOf(ns::proper)(this, m_##proper##s, &m_children, fence); \
927 const std::vector<ns::proper*>& get##proper##s() const { \
928 return m_##proper##s; \
932 * Implements get method and a private vector member for a generic XML child collection.
934 * @param proper the proper name of the child
935 * @param fence insertion fence for new objects of the child collection in backing list
937 #define IMPL_XMLOBJECT_CHILDREN(proper,fence) \
939 std::vector<xmltooling::XMLObject*> m_##proper##s; \
941 VectorOf(xmltooling::XMLObject) get##proper##s() { \
942 return VectorOf(xmltooling::XMLObject)(this, m_##proper##s, &m_children, fence); \
944 const std::vector<xmltooling::XMLObject*>& get##proper##s() const { \
945 return m_##proper##s; \
949 * Implements marshalling for a string attribute
951 * @param proper the proper name of the attribute
952 * @param ucase the upcased name of the attribute
953 * @param namespaceURI the XML namespace of the attribute
955 #define MARSHALL_STRING_ATTRIB(proper,ucase,namespaceURI) \
956 if (m_##proper && *m_##proper) { \
957 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
961 * Implements marshalling for a DateTime attribute
963 * @param proper the proper name of the attribute
964 * @param ucase the upcased name of the attribute
965 * @param namespaceURI the XML namespace of the attribute
967 #define MARSHALL_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
969 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper->getRawData()); \
973 * Implements marshalling for an integer attribute
975 * @param proper the proper name of the attribute
976 * @param ucase the upcased name of the attribute
977 * @param namespaceURI the XML namespace of the attribute
979 #define MARSHALL_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
980 if (m_##proper && *m_##proper) { \
981 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
985 * Implements marshalling for a boolean attribute
987 * @param proper the proper name of the attribute
988 * @param ucase the upcased name of the attribute
989 * @param namespaceURI the XML namespace of the attribute
991 #define MARSHALL_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
992 switch (m_##proper) { \
993 case xmlconstants::XML_BOOL_TRUE: \
994 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_TRUE); \
996 case xmlconstants::XML_BOOL_ONE: \
997 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ONE); \
999 case xmlconstants::XML_BOOL_FALSE: \
1000 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_FALSE); \
1002 case xmlconstants::XML_BOOL_ZERO: \
1003 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ZERO); \
1005 case xmlconstants::XML_BOOL_NULL: \
1010 * Implements marshalling for a QName attribute
1012 * @param proper the proper name of the attribute
1013 * @param ucase the upcased name of the attribute
1014 * @param namespaceURI the XML namespace of the attribute
1016 #define MARSHALL_QNAME_ATTRIB(proper,ucase,namespaceURI) \
1018 auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \
1019 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \
1022 #ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE
1024 * Implements marshalling for an ID attribute
1026 * @param proper the proper name of the attribute
1027 * @param ucase the upcased name of the attribute
1028 * @param namespaceURI the XML namespace of the attribute
1030 # define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \
1031 if (m_##proper && *m_##proper) { \
1032 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
1033 domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, true); \
1037 * Implements marshalling for an ID attribute
1039 * @param proper the proper name of the attribute
1040 * @param ucase the upcased name of the attribute
1041 * @param namespaceURI the XML namespace of the attribute
1043 # define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \
1044 if (m_##proper && *m_##proper) { \
1045 domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
1046 domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \
1051 * Implements unmarshalling process branch for a string attribute
1053 * @param proper the proper name of the attribute
1054 * @param ucase the upcased name of the attribute
1055 * @param namespaceURI the XML namespace of the attribute
1057 #define PROC_STRING_ATTRIB(proper,ucase,namespaceURI) \
1058 if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
1059 set##proper(attribute->getValue()); \
1063 #ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE
1065 * Implements unmarshalling process branch for an ID attribute
1067 * @param proper the proper name of the attribute
1068 * @param ucase the upcased name of the attribute
1069 * @param namespaceURI the XML namespace of the attribute
1071 # define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \
1072 if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
1073 set##proper(attribute->getValue()); \
1074 attribute->getOwnerElement()->setIdAttributeNode(attribute, true); \
1079 * Implements unmarshalling process branch for an ID attribute
1081 * @param proper the proper name of the attribute
1082 * @param ucase the upcased name of the attribute
1083 * @param namespaceURI the XML namespace of the attribute
1085 # define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \
1086 if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
1087 set##proper(attribute->getValue()); \
1088 attribute->getOwnerElement()->setIdAttributeNode(attribute); \
1094 * Implements unmarshalling process branch for a DateTime attribute
1096 * @param proper the proper name of the attribute
1097 * @param ucase the upcased name of the attribute
1098 * @param namespaceURI the XML namespace of the attribute
1100 #define PROC_DATETIME_ATTRIB(proper,ucase,namespaceURI) \
1101 PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
1104 * Implements unmarshalling process branch for a DateTime attribute
1106 * @param proper the proper name of the attribute
1107 * @param ucase the upcased name of the attribute
1108 * @param namespaceURI the XML namespace of the attribute
1110 #define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \
1111 if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
1112 set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \
1117 * Implements unmarshalling process branch for an integer attribute
1119 * @param proper the proper name of the attribute
1120 * @param ucase the upcased name of the attribute
1121 * @param namespaceURI the XML namespace of the attribute
1123 #define PROC_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
1124 PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
1127 * Implements unmarshalling process branch for a boolean attribute
1129 * @param proper the proper name of the attribute
1130 * @param ucase the upcased name of the attribute
1131 * @param namespaceURI the XML namespace of the attribute
1133 #define PROC_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
1134 PROC_STRING_ATTRIB(proper,ucase,namespaceURI)
1137 * Implements unmarshalling process branch for typed child collection element
1139 * @param proper the proper name of the child type
1140 * @param namespaceURI the XML namespace of the child element
1141 * @param force bypass use of hint and just cast down to check child
1143 #define PROC_TYPED_CHILDREN(proper,namespaceURI,force) \
1144 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1145 proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
1147 get##proper##s().push_back(typesafe); \
1153 * Implements unmarshalling process branch for typed child collection element
1154 * in a foreign namespace.
1156 * @param proper the proper name of the child type
1157 * @param ns the C++ namespace for the type
1158 * @param namespaceURI the XML namespace of the child element
1159 * @param force bypass use of hint and just cast down to check child
1161 #define PROC_TYPED_FOREIGN_CHILDREN(proper,ns,namespaceURI,force) \
1162 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
1163 ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
1165 get##proper##s().push_back(typesafe); \
1171 * Implements unmarshalling process branch for typed child singleton element
1173 * @param proper the proper name of the child type
1174 * @param namespaceURI the XML namespace of the child element
1175 * @param force bypass use of hint and just cast down to check child
1177 #define PROC_TYPED_CHILD(proper,namespaceURI,force) \
1178 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1179 proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
1180 if (typesafe && !m_##proper) { \
1181 typesafe->setParent(this); \
1182 *m_pos_##proper = m_##proper = typesafe; \
1188 * Implements unmarshalling process branch for typed child singleton element
1189 * in a foreign namespace.
1191 * @param proper the proper name of the child type
1192 * @param ns the C++ namespace for the type
1193 * @param namespaceURI the XML namespace of the child element
1194 * @param force bypass use of hint and just cast down to check child
1196 #define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \
1197 if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
1198 ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
1199 if (typesafe && !m_##proper) { \
1200 typesafe->setParent(this); \
1201 *m_pos_##proper = m_##proper = typesafe; \
1207 * Implements unmarshalling process branch for a generic child singleton element
1209 * @param proper the proper name of the child type
1210 * @param namespaceURI the XML namespace of the child element
1212 #define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
1213 if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
1214 if (!m_##proper) { \
1215 childXMLObject->setParent(this); \
1216 *m_pos_##proper = m_##proper = childXMLObject; \
1222 * Declares aliased get/set methods for named XML element simple content.
1224 * @param proper the proper name to label the element's content
1226 #define DECL_SIMPLE_CONTENT(proper) \
1227 XMLTOOLING_DOXYGEN(Returns proper.) \
1228 const XMLCh* get##proper() const { \
1229 return getTextContent(); \
1231 XMLTOOLING_DOXYGEN(Sets or clears proper.) \
1232 void set##proper(const XMLCh* proper) { \
1233 setTextContent(proper); \
1237 * Declares aliased get/set methods for named integer XML element content.
1239 * @param proper the proper name to label the element's content
1241 #define DECL_INTEGER_CONTENT(proper) \
1242 XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \
1243 std::pair<bool,int> get##proper() const { \
1244 return std::make_pair((getTextContent()!=nullptr), (getTextContent()!=nullptr ? xercesc::XMLString::parseInt(getTextContent()) : 0)); \
1246 XMLTOOLING_DOXYGEN(Sets proper.) \
1247 void set##proper(int proper) { \
1249 sprintf(buf,"%d",proper); \
1250 xmltooling::auto_ptr_XMLCh widebuf(buf); \
1251 setTextContent(widebuf.get()); \
1253 XMLTOOLING_DOXYGEN(Sets or clears proper.) \
1254 void set##proper(const XMLCh* proper) { \
1255 setTextContent(proper); \
1259 * Implements cloning methods for an XMLObject specialization implementation class.
1261 * @param cname the name of the XMLObject specialization
1263 #define IMPL_XMLOBJECT_CLONE(cname) \
1264 cname* clone##cname() const { \
1265 return dynamic_cast<cname*>(clone()); \
1267 xmltooling::XMLObject* clone() const { \
1268 std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
1269 cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
1271 domClone.release(); \
1274 return new cname##Impl(*this); \
1278 * Declares an XMLObject specialization with a simple content model and type,
1279 * handling it as string data.
1281 * @param linkage linkage specifier for the class
1282 * @param cname the name of the XMLObject specialization
1283 * @param proper the proper name to label the element's content
1284 * @param desc documentation for class
1286 #define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \
1287 BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \
1288 DECL_SIMPLE_CONTENT(proper); \
1292 * Declares and defines an implementation class for an XMLObject with
1293 * a simple content model and type, handling it as string data.
1295 * @param linkage linkage specifier for the class
1296 * @param cname the name of the XMLObject specialization
1298 #define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname) \
1299 class linkage cname##Impl \
1300 : public virtual cname, \
1301 public xmltooling::AbstractSimpleElement, \
1302 public xmltooling::AbstractDOMCachingXMLObject, \
1303 public xmltooling::AbstractXMLObjectMarshaller, \
1304 public xmltooling::AbstractXMLObjectUnmarshaller \
1307 virtual ~cname##Impl() {} \
1308 cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) \
1309 : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \
1311 cname##Impl(const cname##Impl& src) \
1312 : xmltooling::AbstractXMLObject(src), \
1313 xmltooling::AbstractSimpleElement(src), \
1314 xmltooling::AbstractDOMCachingXMLObject(src) {} \
1315 IMPL_XMLOBJECT_CLONE(cname) \
1318 #ifdef HAVE_COVARIANT_RETURNS
1321 * Begins the declaration of an XMLObjectBuilder specialization.
1322 * Basic boilerplate includes an empty virtual destructor, and
1323 * a default builder that defaults the element name.
1325 * @param linkage linkage specifier for the class
1326 * @param cname the name of the XMLObject specialization
1327 * @param namespaceURI the XML namespace of the default associated element
1328 * @param namespacePrefix the XML namespace prefix of the default associated element
1330 #define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1331 XMLTOOLING_DOXYGEN(Builder for cname objects.) \
1332 class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \
1334 virtual ~cname##Builder() {} \
1335 XMLTOOLING_DOXYGEN(Default builder.) \
1336 virtual cname* buildObject() const { \
1337 return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
1339 XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
1340 virtual cname* buildObject( \
1341 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr \
1345 * Ends the declaration of an XMLObjectBuilder specialization.
1347 #define END_XMLOBJECTBUILDER }
1350 * Declares a generic XMLObjectBuilder specialization.
1352 * @param linkage linkage specifier for the class
1353 * @param cname the name of the XMLObject specialization
1354 * @param namespaceURI the XML namespace of the default associated element
1355 * @param namespacePrefix the XML namespace prefix of the default associated element
1357 #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1358 BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
1359 XMLTOOLING_DOXYGEN(Singleton builder.) \
1360 static cname* build##cname() { \
1361 const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
1362 XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
1365 return b->buildObject(); \
1366 throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
1368 END_XMLOBJECTBUILDER
1371 * Implements the standard XMLObjectBuilder specialization function.
1373 * @param cname the name of the XMLObject specialization
1375 #define IMPL_XMLOBJECTBUILDER(cname) \
1376 cname* cname##Builder::buildObject( \
1377 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType \
1380 return new cname##Impl(nsURI,localName,prefix,schemaType); \
1383 #else /* !HAVE_COVARIANT_RETURNS */
1386 * Begins the declaration of an XMLObjectBuilder specialization.
1387 * Basic boilerplate includes an empty virtual destructor, and
1388 * a default builder that defaults the element name.
1390 * @param linkage linkage specifier for the class
1391 * @param cname the name of the XMLObject specialization
1392 * @param namespaceURI the XML namespace of the default associated element
1393 * @param namespacePrefix the XML namespace prefix of the default associated element
1395 #define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1396 XMLTOOLING_DOXYGEN(Builder for cname objects.) \
1397 class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \
1399 virtual ~cname##Builder() {} \
1400 XMLTOOLING_DOXYGEN(Default builder.) \
1401 virtual xmltooling::XMLObject* buildObject() const { \
1402 return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
1404 XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
1405 virtual xmltooling::XMLObject* buildObject( \
1406 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr \
1410 * Ends the declaration of an XMLObjectBuilder specialization.
1412 #define END_XMLOBJECTBUILDER }
1415 * Declares a generic XMLObjectBuilder specialization.
1417 * @param linkage linkage specifier for the class
1418 * @param cname the name of the XMLObject specialization
1419 * @param namespaceURI the XML namespace of the default associated element
1420 * @param namespacePrefix the XML namespace prefix of the default associated element
1422 #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
1423 BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
1424 XMLTOOLING_DOXYGEN(Singleton builder.) \
1425 static cname* build##cname() { \
1426 const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
1427 XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
1430 return dynamic_cast<cname*>(b->buildObject()); \
1431 throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
1433 END_XMLOBJECTBUILDER
1436 * Implements the standard XMLObjectBuilder specialization function.
1438 * @param cname the name of the XMLObject specialization
1440 #define IMPL_XMLOBJECTBUILDER(cname) \
1441 xmltooling::XMLObject* cname##Builder::buildObject( \
1442 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType \
1445 return new cname##Impl(nsURI,localName,prefix,schemaType); \
1448 #endif /* HAVE_COVARIANT_RETURNS */
1451 * Begins the declaration of a Schema Validator specialization.
1453 * @param linkage linkage specifier for the class
1454 * @param cname the base name of the Validator specialization
1456 #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \
1457 class linkage cname##SchemaValidator : public xmltooling::Validator \
1460 virtual ~cname##SchemaValidator() {} \
1461 virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1462 const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1464 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())); \
1465 if (ptr->nil() && (ptr->hasChildren() || ptr->getTextContent())) \
1466 throw xmltooling::ValidationException("Object has nil property but with children or content.")
1469 * Begins the declaration of a Schema Validator specialization subclass.
1471 * @param linkage linkage specifier for the class
1472 * @param cname the base name of the Validator specialization
1473 * @param base base class for the validator
1475 #define BEGIN_XMLOBJECTVALIDATOR_SUB(linkage,cname,base) \
1476 class linkage cname##SchemaValidator : public base##SchemaValidator \
1479 virtual ~cname##SchemaValidator() {} \
1480 virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
1481 const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1483 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()));
1486 * Ends the declaration of a Validator specialization.
1488 #define END_XMLOBJECTVALIDATOR } }
1491 * Validator code that checks the object type.
1493 * @param cname the name of the XMLObject specialization
1495 #define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \
1496 const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
1498 throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
1501 * Validator code that checks for a required attribute, content, or singleton.
1503 * @param cname the name of the XMLObject specialization
1504 * @param proper the proper name of the attribute, content, or singleton member
1506 #define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \
1507 if (!ptr->get##proper()) \
1508 throw xmltooling::ValidationException(#cname" must have "#proper".")
1511 * Validator code that checks for a required integer attribute
1513 * @param cname the name of the XMLObject specialization
1514 * @param proper the proper name of the attribute, content, or singleton member
1516 #define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \
1517 if (!ptr->get##proper().first) \
1518 throw xmltooling::ValidationException(#cname" must have "#proper".")
1521 * Validator code that checks for one of a pair of
1522 * required attributes, content, or singletons.
1524 * @param cname the name of the XMLObject specialization
1525 * @param proper1 the proper name of the first attribute, content, or singleton member
1526 * @param proper2 the proper name of the second attribute, content, or singleton member
1528 #define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \
1529 if (!ptr->get##proper1() && !ptr->get##proper2()) \
1530 throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2".")
1533 * Validator code that checks for one of a pair of
1534 * required attributes, content, or singletons, but disallows both.
1536 * @param cname the name of the XMLObject specialization
1537 * @param proper1 the proper name of the first attribute, content, or singleton member
1538 * @param proper2 the proper name of the second attribute, content, or singleton member
1540 #define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \
1541 if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \
1542 throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2" but not both.")
1545 * Validator code that checks for one of a set of three
1546 * required attributes, content, or singletons.
1548 * @param cname the name of the XMLObject specialization
1549 * @param proper1 the proper name of the first attribute, content, or singleton member
1550 * @param proper2 the proper name of the second attribute, content, or singleton member
1551 * @param proper3 the proper name of the third attribute, content, or singleton member
1553 #define XMLOBJECTVALIDATOR_ONEOF3(cname,proper1,proper2,proper3) \
1554 if (!ptr->get##proper1() && !ptr->get##proper2() && !ptr->get##proper3()) \
1555 throw xmltooling::ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".")
1558 * Validator code that checks for one of a set of three
1559 * required attributes, content, or singletons but disallows more than one.
1561 * @param cname the name of the XMLObject specialization
1562 * @param proper1 the proper name of the first attribute, content, or singleton member
1563 * @param proper2 the proper name of the second attribute, content, or singleton member
1564 * @param proper3 the proper name of the third attribute, content, or singleton member
1566 #define XMLOBJECTVALIDATOR_ONLYONEOF3(cname,proper1,proper2,proper3) \
1567 int c##proper1##proper2##proper3=0; \
1568 if (ptr->get##proper1()!=nullptr) \
1569 c##proper1##proper2##proper3++; \
1570 if (ptr->get##proper2()!=nullptr) \
1571 c##proper1##proper2##proper3++; \
1572 if (ptr->get##proper3()!=nullptr) \
1573 c##proper1##proper2##proper3++; \
1574 if (c##proper1##proper2##proper3 != 1) \
1575 throw xmltooling::ValidationException(#cname" must have only one of "#proper1", "#proper2", or "#proper3".")
1578 * Validator code that checks a co-constraint (if one present, the other must be)
1579 * between a pair of attributes, content, or singletons.
1581 * @param cname the name of the XMLObject specialization
1582 * @param proper1 the proper name of the first attribute, content, or singleton member
1583 * @param proper2 the proper name of the second attribute, content, or singleton member
1585 #define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \
1586 if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \
1587 throw xmltooling::ValidationException(#cname" cannot have "#proper1" without "#proper2".")
1590 * Validator code that checks for a non-empty collection.
1592 * @param cname the name of the XMLObject specialization
1593 * @param proper the proper name of the collection item
1595 #define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \
1596 if (ptr->get##proper##s().empty()) \
1597 throw xmltooling::ValidationException(#cname" must have at least one "#proper".")
1600 * Declares/defines a Validator specialization that checks object type and
1601 * a non-empty simple content model.
1603 * @param linkage linkage specifier for the class
1604 * @param cname the name of the XMLObject specialization
1606 #define XMLOBJECTVALIDATOR_SIMPLE(linkage,cname) \
1607 BEGIN_XMLOBJECTVALIDATOR(linkage,cname); \
1608 XMLOBJECTVALIDATOR_REQUIRE(cname,TextContent); \
1609 END_XMLOBJECTVALIDATOR
1614 * @namespace xmltooling
1615 * Public namespace of XML Tooling library
1617 namespace xmltooling {
1620 * Template function for cloning a sequence of XMLObjects.
1621 * Invokes the clone() member on each element of the input sequence and adds the copy to
1622 * the output sequence. Order is preserved.
1624 * @param in input sequence to clone
1625 * @param out output sequence to copy cloned pointers into
1627 template<class InputSequence,class OutputSequence> void clone(const InputSequence& in, OutputSequence& out) {
1628 for (typename InputSequence::const_iterator i=in.begin(); i!=in.end(); i++) {
1630 out.push_back((*i)->clone());
1637 * Functor for cleaning up heap objects in containers.
1639 template<class T> struct cleanup
1642 * Function operator to delete an object.
1644 * @param ptr object to delete
1646 void operator()(T* ptr) {delete ptr;}
1649 * Function operator to delete an object stored as const.
1651 * @param ptr object to delete after casting away const
1653 void operator()(const T* ptr) {delete const_cast<T*>(ptr);}
1657 * Functor for cleaning up heap objects in key/value containers.
1659 template<class A,class B> struct cleanup_pair
1662 * Function operator to delete an object.
1664 * @param p a pair in which the second component is the object to delete
1666 void operator()(const std::pair<const A,B*>& p) {delete p.second;}
1670 * Functor for cleaning up const heap objects in key/value containers.
1672 template<class A,class B> struct cleanup_const_pair
1675 * Function operator to delete an object stored as const
1677 * @param p a pair in which the second component is the const object to delete
1679 void operator()(const std::pair<const A,const B*>& p) {delete const_cast<B*>(p.second);}
1683 #endif /* __xmltooling_base_h__ */