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