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