From: cantor Date: Wed, 28 May 2008 03:16:37 +0000 (+0000) Subject: https://bugs.internet2.edu/jira/browse/CPPXT-10 X-Git-Tag: 1.4.1~334 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fxmltooling.git;a=commitdiff_plain;h=72a55862b96bfcf71ff9653c0ac842417633bb78 https://bugs.internet2.edu/jira/browse/CPPXT-10 git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1_0@495 de75baf8-a10c-0410-a50a-987c0e22f00f --- diff --git a/xmltooling/XMLObjectBuilder.h b/xmltooling/XMLObjectBuilder.h index 80fa690..ef54e17 100644 --- a/xmltooling/XMLObjectBuilder.h +++ b/xmltooling/XMLObjectBuilder.h @@ -1,206 +1,207 @@ -/* - * Copyright 2001-2007 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file xmltooling/XMLObjectBuilder.h - * - * Factory interface for XMLObjects. - */ - -#ifndef __xmltooling_xmlobjbuilder_h__ -#define __xmltooling_xmlobjbuilder_h__ - -#include -#include -#include -#include - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - -namespace xmltooling { - - /** - * A factory interface for obtaining XMLObjects. - * Subclasses MAY supply additional factory methods. - */ - class XMLTOOL_API XMLObjectBuilder - { - MAKE_NONCOPYABLE(XMLObjectBuilder); - public: - virtual ~XMLObjectBuilder() {} - - /** - * Creates an empty XMLObject with a particular element name. - *

The results are undefined if localName is NULL or empty. - * - * @param nsURI namespace URI for element - * @param localName local name of element - * @param prefix prefix of element name - * @param schemaType xsi:type of the object - * @return the empty XMLObject - */ - virtual XMLObject* buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL - ) const=0; - - /** - * Creates an empty XMLObject with a particular element name. - * - * @param q QName of element for object - * @return the empty XMLObject - */ - XMLObject* buildFromQName(const QName& q) const { - return buildObject(q.getNamespaceURI(),q.getLocalPart(),q.getPrefix()); - } - - /** - * Creates an unmarshalled XMLObject from a DOM Element. - * - * @param element the unmarshalling source - * @param bindDocument true iff the XMLObject should take ownership of the DOM Document - * @return the unmarshalled XMLObject - */ - XMLObject* buildFromElement(xercesc::DOMElement* element, bool bindDocument=false) const { - std::auto_ptr ret( - buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),XMLHelper::getXSIType(element)) - ); - ret->unmarshall(element,bindDocument); - return ret.release(); - } - - /** - * Creates an unmarshalled XMLObject from the root of a DOM Document. - * - * @param doc the unmarshalling source - * @param bindDocument true iff the XMLObject should take ownership of the DOM Document - * @return the unmarshalled XMLObject - */ - XMLObject* buildFromDocument(xercesc::DOMDocument* doc, bool bindDocument=true) const { - return buildFromElement(doc->getDocumentElement(),bindDocument); - } - - /** - * Creates an unmarshalled XMLObject using the default build method, if a builder can be found. - * - * @param element the unmarshalling source - * @param bindDocument true iff the new XMLObject should take ownership of the DOM Document - * @return the unmarshalled object or NULL if no builder is available - */ - static XMLObject* buildOneFromElement(xercesc::DOMElement* element, bool bindDocument=false) { - const XMLObjectBuilder* b=getBuilder(element); - return b ? b->buildFromElement(element,bindDocument) : NULL; - } - - /** - * Retrieves an XMLObjectBuilder using the key it was registered with. - * - * @param key the key used to register the builder - * @return the builder or NULL - */ - static const XMLObjectBuilder* getBuilder(const QName& key) { - std::map::const_iterator i=m_map.find(key); - return (i==m_map.end()) ? NULL : i->second; - } - - /** - * Retrieves an XMLObjectBuilder for a given DOM element. - * If no match is found, the default builder is returned, if any. - * - * @param element the element for which to locate a builder - * @return the builder or NULL - */ - static const XMLObjectBuilder* getBuilder(const xercesc::DOMElement* element); - - /** - * Retrieves the default XMLObjectBuilder for DOM elements - * - * @return the default builder or NULL - */ - static const XMLObjectBuilder* getDefaultBuilder() { - return m_default; - } - - /** - * Gets an immutable list of all the builders currently registered. - * - * @return list of all the builders currently registered - */ - static const std::map& getBuilders() { - return m_map; - } - - /** - * Registers a new builder for the given key. - * - * @param builderKey the key used to retrieve this builder later - * @param builder the builder - */ - static void registerBuilder(const QName& builderKey, XMLObjectBuilder* builder) { - deregisterBuilder(builderKey); - m_map[builderKey]=builder; - } - - /** - * Registers a default builder - * - * @param builder the default builder - */ - static void registerDefaultBuilder(XMLObjectBuilder* builder) { - deregisterDefaultBuilder(); - m_default=builder; - } - - /** - * Deregisters a builder. - * - * @param builderKey the key for the builder to be deregistered - */ - static void deregisterBuilder(const QName& builderKey) { - delete getBuilder(builderKey); - m_map.erase(builderKey); - } - - /** - * Deregisters default builder. - */ - static void deregisterDefaultBuilder() { - delete m_default; - m_default=NULL; - } - - /** - * Unregisters and destroys all registered builders. - */ - static void destroyBuilders(); - - protected: - XMLObjectBuilder() {} - - private: - static std::map m_map; - static XMLObjectBuilder* m_default; - }; - -}; - -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - -#endif /* __xmltooling_xmlobjbuilder_h__ */ +/* + * Copyright 2001-2007 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file xmltooling/XMLObjectBuilder.h + * + * Factory interface for XMLObjects. + */ + +#ifndef __xmltooling_xmlobjbuilder_h__ +#define __xmltooling_xmlobjbuilder_h__ + +#include +#include +#include +#include +#include + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4250 4251 ) +#endif + +namespace xmltooling { + + /** + * A factory interface for obtaining XMLObjects. + * Subclasses MAY supply additional factory methods. + */ + class XMLTOOL_API XMLObjectBuilder + { + MAKE_NONCOPYABLE(XMLObjectBuilder); + public: + virtual ~XMLObjectBuilder() {} + + /** + * Creates an empty XMLObject with a particular element name. + *

The results are undefined if localName is NULL or empty. + * + * @param nsURI namespace URI for element + * @param localName local name of element + * @param prefix prefix of element name + * @param schemaType xsi:type of the object + * @return the empty XMLObject + */ + virtual XMLObject* buildObject( + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL + ) const=0; + + /** + * Creates an empty XMLObject with a particular element name. + * + * @param q QName of element for object + * @return the empty XMLObject + */ + XMLObject* buildFromQName(const QName& q) const { + return buildObject(q.getNamespaceURI(),q.getLocalPart(),q.getPrefix()); + } + + /** + * Creates an unmarshalled XMLObject from a DOM Element. + * + * @param element the unmarshalling source + * @param bindDocument true iff the XMLObject should take ownership of the DOM Document + * @return the unmarshalled XMLObject + */ + XMLObject* buildFromElement(xercesc::DOMElement* element, bool bindDocument=false) const { + std::auto_ptr ret( + buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),XMLHelper::getXSIType(element)) + ); + ret->unmarshall(element,bindDocument); + return ret.release(); + } + + /** + * Creates an unmarshalled XMLObject from the root of a DOM Document. + * + * @param doc the unmarshalling source + * @param bindDocument true iff the XMLObject should take ownership of the DOM Document + * @return the unmarshalled XMLObject + */ + XMLObject* buildFromDocument(xercesc::DOMDocument* doc, bool bindDocument=true) const { + return buildFromElement(doc->getDocumentElement(),bindDocument); + } + + /** + * Creates an unmarshalled XMLObject using the default build method, if a builder can be found. + * + * @param element the unmarshalling source + * @param bindDocument true iff the new XMLObject should take ownership of the DOM Document + * @return the unmarshalled object or NULL if no builder is available + */ + static XMLObject* buildOneFromElement(xercesc::DOMElement* element, bool bindDocument=false) { + const XMLObjectBuilder* b=getBuilder(element); + return b ? b->buildFromElement(element,bindDocument) : NULL; + } + + /** + * Retrieves an XMLObjectBuilder using the key it was registered with. + * + * @param key the key used to register the builder + * @return the builder or NULL + */ + static const XMLObjectBuilder* getBuilder(const QName& key) { + std::map::const_iterator i=m_map.find(key); + return (i==m_map.end()) ? NULL : i->second; + } + + /** + * Retrieves an XMLObjectBuilder for a given DOM element. + * If no match is found, the default builder is returned, if any. + * + * @param element the element for which to locate a builder + * @return the builder or NULL + */ + static const XMLObjectBuilder* getBuilder(const xercesc::DOMElement* element); + + /** + * Retrieves the default XMLObjectBuilder for DOM elements + * + * @return the default builder or NULL + */ + static const XMLObjectBuilder* getDefaultBuilder() { + return m_default; + } + + /** + * Gets an immutable list of all the builders currently registered. + * + * @return list of all the builders currently registered + */ + static const std::map& getBuilders() { + return m_map; + } + + /** + * Registers a new builder for the given key. + * + * @param builderKey the key used to retrieve this builder later + * @param builder the builder + */ + static void registerBuilder(const QName& builderKey, XMLObjectBuilder* builder) { + deregisterBuilder(builderKey); + m_map[builderKey]=builder; + } + + /** + * Registers a default builder + * + * @param builder the default builder + */ + static void registerDefaultBuilder(XMLObjectBuilder* builder) { + deregisterDefaultBuilder(); + m_default=builder; + } + + /** + * Deregisters a builder. + * + * @param builderKey the key for the builder to be deregistered + */ + static void deregisterBuilder(const QName& builderKey) { + delete getBuilder(builderKey); + m_map.erase(builderKey); + } + + /** + * Deregisters default builder. + */ + static void deregisterDefaultBuilder() { + delete m_default; + m_default=NULL; + } + + /** + * Unregisters and destroys all registered builders. + */ + static void destroyBuilders(); + + protected: + XMLObjectBuilder() {} + + private: + static std::map m_map; + static XMLObjectBuilder* m_default; + }; + +}; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +#endif /* __xmltooling_xmlobjbuilder_h__ */ diff --git a/xmltooling/base.h b/xmltooling/base.h index b6d3ba3..450c37f 100644 --- a/xmltooling/base.h +++ b/xmltooling/base.h @@ -1,1576 +1,1578 @@ -/* - * Copyright 2001-2007 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file xmltooling/base.h - * - * Base header file definitions - * Must be included prior to including any other header - */ - -#ifndef __xmltooling_base_h__ -#define __xmltooling_base_h__ - -#if defined (_MSC_VER) || defined(__BORLANDC__) - #include -#else - #include -#endif - -#ifdef XMLTOOLING_LITE -# define XMLTOOLING_NO_XMLSEC 1 -#endif - -// Windows and GCC4 Symbol Visibility Macros -#ifdef WIN32 - #define XMLTOOL_IMPORT __declspec(dllimport) - #define XMLTOOL_EXPORT __declspec(dllexport) - #define XMLTOOL_DLLLOCAL - #define XMLTOOL_DLLPUBLIC -#else - #define XMLTOOL_IMPORT - #ifdef GCC_HASCLASSVISIBILITY - #define XMLTOOL_EXPORT __attribute__ ((visibility("default"))) - #define XMLTOOL_DLLLOCAL __attribute__ ((visibility("hidden"))) - #define XMLTOOL_DLLPUBLIC __attribute__ ((visibility("default"))) - #else - #define XMLTOOL_EXPORT - #define XMLTOOL_DLLLOCAL - #define XMLTOOL_DLLPUBLIC - #endif -#endif - -// Define XMLTOOL_API for DLL builds -#ifdef XMLTOOLING_EXPORTS - #define XMLTOOL_API XMLTOOL_EXPORT -#else - #define XMLTOOL_API XMLTOOL_IMPORT -#endif - -// Throwable classes must always be visible on GCC in all binaries -#ifdef WIN32 - #define XMLTOOL_EXCEPTIONAPI(api) api -#elif defined(GCC_HASCLASSVISIBILITY) - #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT -#else - #define XMLTOOL_EXCEPTIONAPI(api) -#endif - -#ifdef _MSC_VER - #define XMLTOOLING_DOXYGEN(desc) /##** desc */ -#else - #define XMLTOOLING_DOXYGEN(desc) -#endif - -/** - * Blocks copy c'tor and assignment operator for a class. - */ -#define MAKE_NONCOPYABLE(type) \ - private: \ - type(const type&); \ - type& operator=(const type&) - -#ifndef DOXYGEN_SKIP -#ifndef NULL -#define NULL 0 -#endif -#define UNICODE_LITERAL_1(a) {xercesc::chLatin_##a, xercesc::chNull} -#define UNICODE_LITERAL_2(a,b) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chNull} -#define UNICODE_LITERAL_3(a,b,c) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chNull} -#define UNICODE_LITERAL_4(a,b,c,d) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chNull} -#define UNICODE_LITERAL_5(a,b,c,d,e) \ - {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chNull} -#define UNICODE_LITERAL_6(a,b,c,d,e,f) \ - {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chNull} -#define UNICODE_LITERAL_7(a,b,c,d,e,f,g) \ - {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chNull} -#define UNICODE_LITERAL_8(a,b,c,d,e,f,g,h) \ - {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} -#define UNICODE_LITERAL_9(a,b,c,d,e,f,g,h,i) \ - {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} -#define UNICODE_LITERAL_10(a,b,c,d,e,f,g,h,i,j) \ - {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::chLatin_##j, xercesc::chNull} -#define UNICODE_LITERAL_11(a,b,c,d,e,f,g,h,i,j,k) \ - {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chNull} -#define UNICODE_LITERAL_12(a,b,c,d,e,f,g,h,i,j,k,l) \ - {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chNull} -#define UNICODE_LITERAL_13(a,b,c,d,e,f,g,h,i,j,k,l,m) \ - {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chNull} -#define UNICODE_LITERAL_14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) \ - {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chNull} -#define UNICODE_LITERAL_15(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \ - {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chNull} -#define UNICODE_LITERAL_16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \ - {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chNull} -#define UNICODE_LITERAL_17(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) \ - {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::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} -#define UNICODE_LITERAL_18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) \ - {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::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} -#define UNICODE_LITERAL_19(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) \ - {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::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::chLatin_##s, xercesc::chNull} -#define UNICODE_LITERAL_20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chNull} -#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) \ - {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::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::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} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - xercesc::chLatin_##aa, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chLatin_##gg, xercesc::chNull} -#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) \ - {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ - 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} -#endif /* DOXYGEN_SKIP */ - -/** - * Begins the declaration of an XMLObject specialization for an abstract element/type. - * Basic boilerplate includes a protected constructor, empty virtual destructor, - * and Unicode constants for the default associated element's name and prefix. - * - * @param linkage linkage specifier for the class - * @param cname the name of the class to declare - * @param base the base class to derive from using public virtual inheritance - * @param desc documentation comment for class - */ -#define DECL_XMLOBJECT_ABSTRACT(linkage,cname,base,desc) \ - XMLTOOLING_DOXYGEN(desc) \ - class linkage cname : public virtual base { \ - protected: \ - cname() {} \ - public: \ - virtual ~cname() {} \ - XMLTOOLING_DOXYGEN(Element local name) \ - static const XMLCh LOCAL_NAME[]; \ - } - -/** - * Begins the declaration of an XMLObject specialization. - * Basic boilerplate includes a protected constructor, empty virtual destructor, - * and Unicode constants for the default associated element's name and prefix. - * - * @param linkage linkage specifier for the class - * @param cname the name of the class to declare - * @param base the base class to derive from using public virtual inheritance - * @param desc documentation comment for class - */ -#define BEGIN_XMLOBJECT(linkage,cname,base,desc) \ - XMLTOOLING_DOXYGEN(desc) \ - class linkage cname : public virtual base { \ - protected: \ - cname() {} \ - public: \ - virtual ~cname() {} \ - XMLTOOLING_DOXYGEN(Type-specific clone method.) \ - virtual cname* clone##cname() const=0; \ - XMLTOOLING_DOXYGEN(Element local name) \ - static const XMLCh LOCAL_NAME[] - -/** - * Begins the declaration of an XMLObject specialization with two base classes. - * Basic boilerplate includes a protected constructor, empty virtual destructor, - * and Unicode constants for the default associated element's name and prefix. - * - * @param linkage linkage specifier for the class - * @param cname the name of the class to declare - * @param base the first base class to derive from using public virtual inheritance - * @param base2 the second base class to derive from using public virtual inheritance - * @param desc documentation comment for class - */ -#define BEGIN_XMLOBJECT2(linkage,cname,base,base2,desc) \ - XMLTOOLING_DOXYGEN(desc) \ - class linkage cname : public virtual base, public virtual base2 { \ - protected: \ - cname() {} \ - public: \ - virtual ~cname() {} \ - XMLTOOLING_DOXYGEN(Type-specific clone method.) \ - virtual cname* clone##cname() const=0; \ - XMLTOOLING_DOXYGEN(Element local name) \ - static const XMLCh LOCAL_NAME[] - -/** - * Begins the declaration of an XMLObject specialization with three base classes. - * Basic boilerplate includes a protected constructor, empty virtual destructor, - * and Unicode constants for the default associated element's name and prefix. - * - * @param linkage linkage specifier for the class - * @param cname the name of the class to declare - * @param base the first base class to derive from using public virtual inheritance - * @param base2 the second base class to derive from using public virtual inheritance - * @param base3 the third base class to derive from using public virtual inheritance - * @param desc documentation comment for class - */ -#define BEGIN_XMLOBJECT3(linkage,cname,base,base2,base3,desc) \ - XMLTOOLING_DOXYGEN(desc) \ - class linkage cname : public virtual base, public virtual base2, public virtual base3 { \ - protected: \ - cname() {} \ - public: \ - virtual ~cname() {} \ - XMLTOOLING_DOXYGEN(Type-specific clone method.) \ - virtual cname* clone##cname() const=0; \ - XMLTOOLING_DOXYGEN(Element local name) \ - static const XMLCh LOCAL_NAME[] - -/** - * Begins the declaration of an XMLObject specialization with four base classes. - * Basic boilerplate includes a protected constructor, empty virtual destructor, - * and Unicode constants for the default associated element's name and prefix. - * - * @param linkage linkage specifier for the class - * @param cname the name of the class to declare - * @param base the first base class to derive from using public virtual inheritance - * @param base2 the second base class to derive from using public virtual inheritance - * @param base3 the third base class to derive from using public virtual inheritance - * @param base4 the fourth base class to derive from using public virtual inheritance - * @param desc documentation comment for class - */ -#define BEGIN_XMLOBJECT4(linkage,cname,base,base2,base3,base4,desc) \ - XMLTOOLING_DOXYGEN(desc) \ - class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4 { \ - protected: \ - cname() {} \ - public: \ - virtual ~cname() {} \ - XMLTOOLING_DOXYGEN(Type-specific clone method.) \ - virtual cname* clone##cname() const=0; \ - XMLTOOLING_DOXYGEN(Element local name) \ - static const XMLCh LOCAL_NAME[] - -/** - * Begins the declaration of an XMLObject specialization with five base classes. - * Basic boilerplate includes a protected constructor, empty virtual destructor, - * and Unicode constants for the default associated element's name and prefix. - * - * @param linkage linkage specifier for the class - * @param cname the name of the class to declare - * @param base the first base class to derive from using public virtual inheritance - * @param base2 the second base class to derive from using public virtual inheritance - * @param base3 the third base class to derive from using public virtual inheritance - * @param base4 the fourth base class to derive from using public virtual inheritance - * @param base5 the fifth base class to derive from using public virtual inheritance - * @param desc documentation comment for class - */ -#define BEGIN_XMLOBJECT5(linkage,cname,base,base2,base3,base4,base5,desc) \ - XMLTOOLING_DOXYGEN(desc) \ - class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4, public virtual base5 { \ - protected: \ - cname() {} \ - public: \ - virtual ~cname() {} \ - XMLTOOLING_DOXYGEN(Type-specific clone method.) \ - virtual cname* clone##cname() const=0; \ - XMLTOOLING_DOXYGEN(Element local name) \ - static const XMLCh LOCAL_NAME[] - -/** - * Ends the declaration of an XMLObject specialization. - */ -#define END_XMLOBJECT } - -/** - * Declares a static variable holding the XMLObject's element QName. - */ -#define DECL_ELEMENT_QNAME \ - public: \ - XMLTOOLING_DOXYGEN(Element QName) \ - static xmltooling::QName ELEMENT_QNAME - -/** - * Declares a static variable holding the XMLObject's schema type QName. - */ -#define DECL_TYPE_QNAME \ - public: \ - XMLTOOLING_DOXYGEN(Type QName) \ - static xmltooling::QName TYPE_QNAME - -/** - * Implements a static variable holding an XMLObject's element QName. - * - * @param cname the name of the XMLObject specialization - * @param namespaceURI the XML namespace of the default associated element - * @param namespacePrefix the XML namespace prefix of the default associated element - */ -#define IMPL_ELEMENT_QNAME(cname,namespaceURI,namespacePrefix) \ - xmltooling::QName cname::ELEMENT_QNAME(namespaceURI,cname::LOCAL_NAME,namespacePrefix) - -/** - * Implements a static variable holding an XMLObject's schema type QName. - * - * @param cname the name of the XMLObject specialization - * @param namespaceURI the XML namespace of the default associated element - * @param namespacePrefix the XML namespace prefix of the default associated element - */ -#define IMPL_TYPE_QNAME(cname,namespaceURI,namespacePrefix) \ - xmltooling::QName cname::TYPE_QNAME(namespaceURI,cname::TYPE_NAME,namespacePrefix) - -/** - * Declares abstract set method for a typed XML attribute. - * The get method is omitted. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - * @param type the attribute's data type - */ -#define DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,type) \ - public: \ - XMLTOOLING_DOXYGEN(proper attribute name) \ - static const XMLCh upcased##_ATTRIB_NAME[]; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(const type* proper)=0 - -/** - * Declares abstract get/set methods for a typed XML attribute. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - * @param type the attribute's data type - */ -#define DECL_XMLOBJECT_ATTRIB(proper,upcased,type) \ - public: \ - XMLTOOLING_DOXYGEN(proper attribute name) \ - static const XMLCh upcased##_ATTRIB_NAME[]; \ - XMLTOOLING_DOXYGEN(Returns the proper attribute.) \ - virtual const type* get##proper() const=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(const type* proper)=0 - -/** - * Declares abstract set method for a string XML attribute. - * The get method is omitted. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - */ -#define DECL_INHERITED_STRING_ATTRIB(proper,upcased) \ - DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,XMLCh) - -/** - * Declares abstract get/set methods for a string XML attribute. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - */ -#define DECL_STRING_ATTRIB(proper,upcased) \ - DECL_XMLOBJECT_ATTRIB(proper,upcased,XMLCh) - -/** - * Declares abstract set method for a DateTime XML attribute. - * The get method is omitted. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - */ -#define DECL_INHERITED_DATETIME_ATTRIB(proper,upcased) \ - DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(time_t proper)=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(const XMLCh* proper)=0 - -/** - * Declares abstract get/set methods for a DateTime XML attribute. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - */ -#define DECL_DATETIME_ATTRIB(proper,upcased) \ - DECL_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \ - XMLTOOLING_DOXYGEN(Returns the proper attribute in epoch form.) \ - virtual time_t get##proper##Epoch() const=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(time_t proper)=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(const XMLCh* proper)=0 - -/** - * Declares abstract set method for an integer XML attribute. - * The get method is omitted. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - */ -#define DECL_INHERITED_INTEGER_ATTRIB(proper,upcased) \ - public: \ - XMLTOOLING_DOXYGEN(proper attribute name) \ - static const XMLCh upcased##_ATTRIB_NAME[]; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \ - virtual void set##proper(const XMLCh* proper)=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(int proper)=0 - -/** - * Declares abstract get/set methods for an integer XML attribute. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - */ -#define DECL_INTEGER_ATTRIB(proper,upcased) \ - public: \ - XMLTOOLING_DOXYGEN(proper attribute name) \ - static const XMLCh upcased##_ATTRIB_NAME[]; \ - XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \ - virtual std::pair get##proper() const=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \ - virtual void set##proper(const XMLCh* proper)=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - virtual void set##proper(int proper)=0 - -/** - * Declares abstract get/set methods for a boolean XML attribute. - * - * @param proper the proper name of the attribute - * @param upcased the upcased name of the attribute - * @param def the default/presumed value, if no explicit value has been set - */ -#define DECL_BOOLEAN_ATTRIB(proper,upcased,def) \ - public: \ - XMLTOOLING_DOXYGEN(proper attribute name) \ - static const XMLCh upcased##_ATTRIB_NAME[]; \ - XMLTOOLING_DOXYGEN(Returns the proper attribute or def if not set.) \ - bool proper() const { \ - switch (get##proper()) { \ - case xmlconstants::XML_BOOL_TRUE: \ - case xmlconstants::XML_BOOL_ONE: \ - return true; \ - case xmlconstants::XML_BOOL_FALSE: \ - case xmlconstants::XML_BOOL_ZERO: \ - return false; \ - default: \ - return def; \ - } \ - } \ - XMLTOOLING_DOXYGEN(Returns the proper attribute as an explicit enumerated value.) \ - virtual xmlconstants::xmltooling_bool_t get##proper() const=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute using an enumerated value.) \ - virtual void proper(xmlconstants::xmltooling_bool_t value)=0; \ - XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ - void proper(bool value) { \ - proper(value ? xmlconstants::XML_BOOL_ONE : xmlconstants::XML_BOOL_ZERO); \ - } \ - XMLTOOLING_DOXYGEN(Sets the proper attribute using a string constant.) \ - void set##proper(const XMLCh* value) { \ - if (value) { \ - switch (*value) { \ - case xercesc::chLatin_t: \ - proper(xmlconstants::XML_BOOL_TRUE); \ - break; \ - case xercesc::chLatin_f: \ - proper(xmlconstants::XML_BOOL_FALSE); \ - break; \ - case xercesc::chDigit_1: \ - proper(xmlconstants::XML_BOOL_ONE); \ - break; \ - case xercesc::chDigit_0: \ - proper(xmlconstants::XML_BOOL_ZERO); \ - break; \ - default: \ - proper(xmlconstants::XML_BOOL_NULL); \ - } \ - } \ - else \ - proper(xmlconstants::XML_BOOL_NULL); \ - } - -/** - * Implements get/set methods and a private member for a typed XML attribute. - * - * @param proper the proper name of the attribute - * @param type the attribute's data type - */ -#define IMPL_XMLOBJECT_ATTRIB(proper,type) \ - protected: \ - type* m_##proper; \ - public: \ - const type* get##proper() const { \ - return m_##proper; \ - } \ - void set##proper(const type* proper) { \ - m_##proper = prepareForAssignment(m_##proper,proper); \ - } - -/** - * Implements get/set methods and a private member for a string XML attribute. - * - * @param proper the proper name of the attribute - */ -#define IMPL_STRING_ATTRIB(proper) \ - IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) - -/** - * Implements get/set methods and a private member for a string XML attribute, - * plus a getXMLID override. - * - * @param proper the proper name of the attribute - */ -#define IMPL_ID_ATTRIB(proper) \ - IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) \ - const XMLCh* getXMLID() const { \ - return m_##proper; \ - } - -/** - * Implements get/set methods and a private member for a DateTime XML attribute. - * - * @param proper the proper name of the attribute - * @param fallback epoch to return when attribute is NULL - */ -#define IMPL_DATETIME_ATTRIB(proper,fallback) \ - protected: \ - DateTime* m_##proper; \ - time_t m_##proper##Epoch; \ - public: \ - const DateTime* get##proper() const { \ - return m_##proper; \ - } \ - time_t get##proper##Epoch() const { \ - return m_##proper ? m_##proper##Epoch : fallback; \ - } \ - void set##proper(const DateTime* proper) { \ - m_##proper = prepareForAssignment(m_##proper,proper); \ - if (m_##proper) \ - m_##proper##Epoch=m_##proper->getEpoch(); \ - } \ - void set##proper(time_t proper) { \ - m_##proper = prepareForAssignment(m_##proper,proper); \ - m_##proper##Epoch = proper; \ - } \ - void set##proper(const XMLCh* proper) { \ - m_##proper = prepareForAssignment(m_##proper,proper); \ - if (m_##proper) \ - m_##proper##Epoch=m_##proper->getEpoch(); \ - } - -/** - * Implements get/set methods and a private member for an integer XML attribute. - * - * @param proper the proper name of the attribute - */ -#define IMPL_INTEGER_ATTRIB(proper) \ - protected: \ - XMLCh* m_##proper; \ - public: \ - pair get##proper() const { \ - return make_pair((m_##proper!=NULL),(m_##proper!=NULL ? xercesc::XMLString::parseInt(m_##proper): 0)); \ - } \ - void set##proper(const XMLCh* proper) { \ - m_##proper = prepareForAssignment(m_##proper,proper); \ - } \ - void set##proper(int proper) { \ - char buf##proper[64]; \ - sprintf(buf##proper,"%d",proper); \ - auto_ptr_XMLCh wide##proper(buf##proper); \ - set##proper(wide##proper.get()); \ - } - -/** - * Implements get/set methods and a private member for a boolean XML attribute. - * - * @param proper the proper name of the attribute - */ -#define IMPL_BOOLEAN_ATTRIB(proper) \ - protected: \ - xmlconstants::xmltooling_bool_t m_##proper; \ - public: \ - xmlconstants::xmltooling_bool_t get##proper() const { \ - return m_##proper; \ - } \ - void proper(xmlconstants::xmltooling_bool_t value) { \ - if (m_##proper != value) { \ - releaseThisandParentDOM(); \ - m_##proper = value; \ - } \ - } - -/** - * Declares abstract set method for a typed XML child object in a foreign namespace. - * The get method is omitted. - * - * @param proper the proper name of the child type - * @param ns the C++ namespace for the type - */ -#define DECL_INHERITED_TYPED_FOREIGN_CHILD(proper,ns) \ - public: \ - XMLTOOLING_DOXYGEN(Sets the proper child.) \ - virtual void set##proper(ns::proper* child)=0 - -/** - * Declares abstract get/set methods for a typed XML child object in a foreign namespace. - * - * @param proper the proper name of the child type - * @param ns the C++ namespace for the type - */ -#define DECL_TYPED_FOREIGN_CHILD(proper,ns) \ - public: \ - XMLTOOLING_DOXYGEN(Returns the proper child.) \ - virtual ns::proper* get##proper() const=0; \ - XMLTOOLING_DOXYGEN(Sets the proper child.) \ - virtual void set##proper(ns::proper* child)=0 - -/** - * Declares abstract set method for a typed XML child object. - * The get method is omitted. - * - * @param proper the proper name of the child type - */ -#define DECL_INHERITED_TYPED_CHILD(proper) \ - public: \ - XMLTOOLING_DOXYGEN(Sets the proper child.) \ - virtual void set##proper(proper* child)=0 - -/** - * Declares abstract get/set methods for a typed XML child object. - * - * @param proper the proper name of the child type - */ -#define DECL_TYPED_CHILD(proper) \ - public: \ - XMLTOOLING_DOXYGEN(Returns the proper child.) \ - virtual proper* get##proper() const=0; \ - XMLTOOLING_DOXYGEN(Sets the proper child.) \ - virtual void set##proper(proper* child)=0 - -/** - * Declares abstract get/set methods for a generic XML child object. - * - * @param proper the proper name of the child - */ -#define DECL_XMLOBJECT_CHILD(proper) \ - public: \ - XMLTOOLING_DOXYGEN(Returns the proper child.) \ - virtual xmltooling::XMLObject* get##proper() const=0; \ - XMLTOOLING_DOXYGEN(Sets the proper child.) \ - virtual void set##proper(xmltooling::XMLObject* child)=0 - - -/** - * Implements get/set methods and a private list iterator member for a typed XML child object. - * - * @param proper the proper name of the child type - */ -#define IMPL_TYPED_CHILD(proper) \ - protected: \ - proper* m_##proper; \ - std::list::iterator m_pos_##proper; \ - public: \ - proper* get##proper() const { \ - return m_##proper; \ - } \ - void set##proper(proper* child) { \ - prepareForAssignment(m_##proper,child); \ - *m_pos_##proper = m_##proper = child; \ - } - -/** - * Implements get/set methods and a private list iterator member for - * a typed XML child object in a foreign namespace - * - * @param proper the proper name of the child type - * @param ns the C++ namespace for the type - */ -#define IMPL_TYPED_FOREIGN_CHILD(proper,ns) \ - protected: \ - ns::proper* m_##proper; \ - std::list::iterator m_pos_##proper; \ - public: \ - ns::proper* get##proper() const { \ - return m_##proper; \ - } \ - void set##proper(ns::proper* child) { \ - prepareForAssignment(m_##proper,child); \ - *m_pos_##proper = m_##proper = child; \ - } - -/** - * Implements get/set methods and a private list iterator member for a generic XML child object. - * - * @param proper the proper name of the child - */ -#define IMPL_XMLOBJECT_CHILD(proper) \ - protected: \ - xmltooling::XMLObject* m_##proper; \ - std::list::iterator m_pos_##proper; \ - public: \ - xmltooling::XMLObject* get##proper() const { \ - return m_##proper; \ - } \ - void set##proper(xmltooling::XMLObject* child) { \ - prepareForAssignment(m_##proper,child); \ - *m_pos_##proper = m_##proper = child; \ - } - -/** - * Declares abstract get/set methods for a typed XML child collection. - * - * @param proper the proper name of the child type - */ -#define DECL_TYPED_CHILDREN(proper) \ - public: \ - XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \ - virtual VectorOf(proper) get##proper##s()=0; \ - XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \ - virtual const std::vector& get##proper##s() const=0 - -/** - * Declares abstract get/set methods for a typed XML child collection in a foreign namespace. - * - * @param proper the proper name of the child type - * @param ns the C++ namespace for the type - */ -#define DECL_TYPED_FOREIGN_CHILDREN(proper,ns) \ - public: \ - XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \ - virtual VectorOf(ns::proper) get##proper##s()=0; \ - XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \ - virtual const std::vector& get##proper##s() const=0 - -/** - * Declares abstract get/set methods for a generic XML child collection. - * - * @param proper the proper name of the child - */ -#define DECL_XMLOBJECT_CHILDREN(proper) \ - public: \ - XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \ - virtual VectorOf(xmltooling::XMLObject) get##proper##s()=0; \ - XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \ - virtual const std::vector& get##proper##s() const=0 - -/** - * Implements get method and a private vector member for a typed XML child collection. - * - * @param proper the proper name of the child type - * @param fence insertion fence for new objects of the child collection in backing list - */ -#define IMPL_TYPED_CHILDREN(proper,fence) \ - protected: \ - std::vector m_##proper##s; \ - public: \ - VectorOf(proper) get##proper##s() { \ - return VectorOf(proper)(this, m_##proper##s, &m_children, fence); \ - } \ - const std::vector& get##proper##s() const { \ - return m_##proper##s; \ - } - -/** - * Implements get method and a private vector member for a typed XML child collection - * in a foreign namespace. - * - * @param proper the proper name of the child type - * @param ns the C++ namespace for the type - * @param fence insertion fence for new objects of the child collection in backing list - */ -#define IMPL_TYPED_FOREIGN_CHILDREN(proper,ns,fence) \ - protected: \ - std::vector m_##proper##s; \ - public: \ - VectorOf(ns::proper) get##proper##s() { \ - return VectorOf(ns::proper)(this, m_##proper##s, &m_children, fence); \ - } \ - const std::vector& get##proper##s() const { \ - return m_##proper##s; \ - } - -/** - * Implements get method and a private vector member for a generic XML child collection. - * - * @param proper the proper name of the child - * @param fence insertion fence for new objects of the child collection in backing list - */ -#define IMPL_XMLOBJECT_CHILDREN(proper,fence) \ - protected: \ - std::vector m_##proper##s; \ - public: \ - VectorOf(xmltooling::XMLObject) get##proper##s() { \ - return VectorOf(xmltooling::XMLObject)(this, m_##proper##s, &m_children, fence); \ - } \ - const std::vector& get##proper##s() const { \ - return m_##proper##s; \ - } - -/** - * Implements marshalling for a string attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define MARSHALL_STRING_ATTRIB(proper,ucase,namespaceURI) \ - if (m_##proper && *m_##proper) { \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ - } - -/** - * Implements marshalling for a DateTime attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define MARSHALL_DATETIME_ATTRIB(proper,ucase,namespaceURI) \ - if (m_##proper) { \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper->getRawData()); \ - } - -/** - * Implements marshalling for an integer attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define MARSHALL_INTEGER_ATTRIB(proper,ucase,namespaceURI) \ - if (m_##proper && *m_##proper) { \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ - } - -/** - * Implements marshalling for a boolean attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define MARSHALL_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \ - switch (m_##proper) { \ - case xmlconstants::XML_BOOL_TRUE: \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_TRUE); \ - break; \ - case xmlconstants::XML_BOOL_ONE: \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ONE); \ - break; \ - case xmlconstants::XML_BOOL_FALSE: \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_FALSE); \ - break; \ - case xmlconstants::XML_BOOL_ZERO: \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ZERO); \ - break; \ - case xmlconstants::XML_BOOL_NULL: \ - break; \ - } - -/** - * Implements marshalling for a QName attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define MARSHALL_QNAME_ATTRIB(proper,ucase,namespaceURI) \ - if (m_##proper) { \ - auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \ - } - -/** - * Implements marshalling for an ID attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \ - if (m_##proper && *m_##proper) { \ - domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ - domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \ - } - -/** - * Implements unmarshalling process branch for a string attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define PROC_STRING_ATTRIB(proper,ucase,namespaceURI) \ - if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ - set##proper(attribute->getValue()); \ - return; \ - } - -/** - * Implements unmarshalling process branch for an ID attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \ - if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ - set##proper(attribute->getValue()); \ - attribute->getOwnerElement()->setIdAttributeNode(attribute); \ - return; \ - } - -/** - * Implements unmarshalling process branch for a DateTime attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define PROC_DATETIME_ATTRIB(proper,ucase,namespaceURI) \ - PROC_STRING_ATTRIB(proper,ucase,namespaceURI) - -/** - * Implements unmarshalling process branch for a DateTime attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \ - if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ - set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \ - return; \ - } - -/** - * Implements unmarshalling process branch for an integer attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define PROC_INTEGER_ATTRIB(proper,ucase,namespaceURI) \ - PROC_STRING_ATTRIB(proper,ucase,namespaceURI) - -/** - * Implements unmarshalling process branch for a boolean attribute - * - * @param proper the proper name of the attribute - * @param ucase the upcased name of the attribute - * @param namespaceURI the XML namespace of the attribute - */ -#define PROC_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \ - PROC_STRING_ATTRIB(proper,ucase,namespaceURI) - -/** - * Implements unmarshalling process branch for typed child collection element - * - * @param proper the proper name of the child type - * @param namespaceURI the XML namespace of the child element - * @param force bypass use of hint and just cast down to check child - */ -#define PROC_TYPED_CHILDREN(proper,namespaceURI,force) \ - if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \ - proper* typesafe=dynamic_cast(childXMLObject); \ - if (typesafe) { \ - get##proper##s().push_back(typesafe); \ - return; \ - } \ - } - -/** - * Implements unmarshalling process branch for typed child collection element - * in a foreign namespace. - * - * @param proper the proper name of the child type - * @param ns the C++ namespace for the type - * @param namespaceURI the XML namespace of the child element - * @param force bypass use of hint and just cast down to check child - */ -#define PROC_TYPED_FOREIGN_CHILDREN(proper,ns,namespaceURI,force) \ - if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \ - ns::proper* typesafe=dynamic_cast(childXMLObject); \ - if (typesafe) { \ - get##proper##s().push_back(typesafe); \ - return; \ - } \ - } - -/** - * Implements unmarshalling process branch for typed child singleton element - * - * @param proper the proper name of the child type - * @param namespaceURI the XML namespace of the child element - * @param force bypass use of hint and just cast down to check child - */ -#define PROC_TYPED_CHILD(proper,namespaceURI,force) \ - if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \ - proper* typesafe=dynamic_cast(childXMLObject); \ - if (typesafe && !m_##proper) { \ - typesafe->setParent(this); \ - *m_pos_##proper = m_##proper = typesafe; \ - return; \ - } \ - } - -/** - * Implements unmarshalling process branch for typed child singleton element - * in a foreign namespace. - * - * @param proper the proper name of the child type - * @param ns the C++ namespace for the type - * @param namespaceURI the XML namespace of the child element - * @param force bypass use of hint and just cast down to check child - */ -#define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \ - if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \ - ns::proper* typesafe=dynamic_cast(childXMLObject); \ - if (typesafe && !m_##proper) { \ - typesafe->setParent(this); \ - *m_pos_##proper = m_##proper = typesafe; \ - return; \ - } \ - } - -/** - * Implements unmarshalling process branch for a generic child singleton element - * - * @param proper the proper name of the child type - * @param namespaceURI the XML namespace of the child element - */ -#define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \ - if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \ - if (!m_##proper) { \ - childXMLObject->setParent(this); \ - *m_pos_##proper = m_##proper = childXMLObject; \ - return; \ - } \ - } - -/** - * Declares aliased get/set methods for named XML element simple content. - * - * @param proper the proper name to label the element's content - */ -#define DECL_SIMPLE_CONTENT(proper) \ - XMLTOOLING_DOXYGEN(Returns proper.) \ - const XMLCh* get##proper() const { \ - return getTextContent(); \ - } \ - XMLTOOLING_DOXYGEN(Sets or clears proper.) \ - void set##proper(const XMLCh* proper) { \ - setTextContent(proper); \ - } - -/** - * Declares aliased get/set methods for named integer XML element content. - * - * @param proper the proper name to label the element's content - */ -#define DECL_INTEGER_CONTENT(proper) \ - XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \ - std::pair get##proper() const { \ - return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? xercesc::XMLString::parseInt(getTextContent()) : 0)); \ - } \ - XMLTOOLING_DOXYGEN(Sets proper.) \ - void set##proper(int proper) { \ - char buf[64]; \ - sprintf(buf,"%d",proper); \ - xmltooling::auto_ptr_XMLCh widebuf(buf); \ - setTextContent(widebuf.get()); \ - } \ - XMLTOOLING_DOXYGEN(Sets or clears proper.) \ - void set##proper(const XMLCh* proper) { \ - setTextContent(proper); \ - } - -/** - * Implements cloning methods for an XMLObject specialization implementation class. - * - * @param cname the name of the XMLObject specialization - */ -#define IMPL_XMLOBJECT_CLONE(cname) \ - cname* clone##cname() const { \ - return dynamic_cast(clone()); \ - } \ - xmltooling::XMLObject* clone() const { \ - std::auto_ptr domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \ - cname##Impl* ret=dynamic_cast(domClone.get()); \ - if (ret) { \ - domClone.release(); \ - return ret; \ - } \ - return new cname##Impl(*this); \ - } - -/** - * Declares an XMLObject specialization with a simple content model and type, - * handling it as string data. - * - * @param linkage linkage specifier for the class - * @param cname the name of the XMLObject specialization - * @param proper the proper name to label the element's content - * @param desc documentation for class - */ -#define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \ - BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \ - DECL_SIMPLE_CONTENT(proper); \ - END_XMLOBJECT - -/** - * Declares and defines an implementation class for an XMLObject with - * a simple content model and type, handling it as string data. - * - * @param linkage linkage specifier for the class - * @param cname the name of the XMLObject specialization - */ -#define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname) \ - class linkage cname##Impl \ - : public virtual cname, \ - public xmltooling::AbstractSimpleElement, \ - public xmltooling::AbstractDOMCachingXMLObject, \ - public xmltooling::AbstractXMLObjectMarshaller, \ - public xmltooling::AbstractXMLObjectUnmarshaller \ - { \ - public: \ - virtual ~cname##Impl() {} \ - cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \ - : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \ - } \ - cname##Impl(const cname##Impl& src) \ - : xmltooling::AbstractXMLObject(src), \ - xmltooling::AbstractSimpleElement(src), \ - xmltooling::AbstractDOMCachingXMLObject(src) {} \ - IMPL_XMLOBJECT_CLONE(cname) \ - } - -#ifdef HAVE_COVARIANT_RETURNS - -/** - * Begins the declaration of an XMLObjectBuilder specialization. - * Basic boilerplate includes an empty virtual destructor, and - * a default builder that defaults the element name. - * - * @param linkage linkage specifier for the class - * @param cname the name of the XMLObject specialization - * @param namespaceURI the XML namespace of the default associated element - * @param namespacePrefix the XML namespace prefix of the default associated element - */ -#define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ - XMLTOOLING_DOXYGEN(Builder for cname objects.) \ - class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \ - public: \ - virtual ~cname##Builder() {} \ - XMLTOOLING_DOXYGEN(Default builder.) \ - virtual cname* buildObject() const { \ - return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \ - } \ - XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \ - virtual cname* buildObject( \ - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \ - ) const - -/** - * Ends the declaration of an XMLObjectBuilder specialization. - */ -#define END_XMLOBJECTBUILDER } - -/** - * Declares a generic XMLObjectBuilder specialization. - * - * @param linkage linkage specifier for the class - * @param cname the name of the XMLObject specialization - * @param namespaceURI the XML namespace of the default associated element - * @param namespacePrefix the XML namespace prefix of the default associated element - */ - #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ - BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \ - XMLTOOLING_DOXYGEN(Singleton builder.) \ - static cname* build##cname() { \ - const cname##Builder* b = dynamic_cast( \ - XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \ - ); \ - if (b) \ - return b->buildObject(); \ - throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \ - } \ - END_XMLOBJECTBUILDER - -/** - * Implements the standard XMLObjectBuilder specialization function. - * - * @param cname the name of the XMLObject specialization - */ -#define IMPL_XMLOBJECTBUILDER(cname) \ - cname* cname##Builder::buildObject( \ - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \ - ) const \ - { \ - return new cname##Impl(nsURI,localName,prefix,schemaType); \ - } - -#else /* !HAVE_COVARIANT_RETURNS */ - -/** - * Begins the declaration of an XMLObjectBuilder specialization. - * Basic boilerplate includes an empty virtual destructor, and - * a default builder that defaults the element name. - * - * @param linkage linkage specifier for the class - * @param cname the name of the XMLObject specialization - * @param namespaceURI the XML namespace of the default associated element - * @param namespacePrefix the XML namespace prefix of the default associated element - */ -#define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ - XMLTOOLING_DOXYGEN(Builder for cname objects.) \ - class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \ - public: \ - virtual ~cname##Builder() {} \ - XMLTOOLING_DOXYGEN(Default builder.) \ - virtual xmltooling::XMLObject* buildObject() const { \ - return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \ - } \ - XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \ - virtual xmltooling::XMLObject* buildObject( \ - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \ - ) const - -/** - * Ends the declaration of an XMLObjectBuilder specialization. - */ -#define END_XMLOBJECTBUILDER } - -/** - * Declares a generic XMLObjectBuilder specialization. - * - * @param linkage linkage specifier for the class - * @param cname the name of the XMLObject specialization - * @param namespaceURI the XML namespace of the default associated element - * @param namespacePrefix the XML namespace prefix of the default associated element - */ - #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ - BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \ - XMLTOOLING_DOXYGEN(Singleton builder.) \ - static cname* build##cname() { \ - const cname##Builder* b = dynamic_cast( \ - XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \ - ); \ - if (b) \ - return dynamic_cast(b->buildObject()); \ - throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \ - } \ - END_XMLOBJECTBUILDER - -/** - * Implements the standard XMLObjectBuilder specialization function. - * - * @param cname the name of the XMLObject specialization - */ -#define IMPL_XMLOBJECTBUILDER(cname) \ - xmltooling::XMLObject* cname##Builder::buildObject( \ - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \ - ) const \ - { \ - return new cname##Impl(nsURI,localName,prefix,schemaType); \ - } - -#endif /* HAVE_COVARIANT_RETURNS */ - -/** - * Begins the declaration of a Schema Validator specialization. - * - * @param linkage linkage specifier for the class - * @param cname the base name of the Validator specialization - */ - #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \ - class linkage cname##SchemaValidator : public xmltooling::Validator \ - { \ - public: \ - virtual ~cname##SchemaValidator() {} \ - virtual void validate(const xmltooling::XMLObject* xmlObject) const { \ - const cname* ptr=dynamic_cast(xmlObject); \ - if (!ptr) \ - throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())); \ - if (ptr->nil() && (ptr->hasChildren() || ptr->getTextContent())) \ - throw xmltooling::ValidationException("Object has nil property but with children or content.") - -/** - * Begins the declaration of a Schema Validator specialization subclass. - * - * @param linkage linkage specifier for the class - * @param cname the base name of the Validator specialization - * @param base base class for the validator - */ - #define BEGIN_XMLOBJECTVALIDATOR_SUB(linkage,cname,base) \ - class linkage cname##SchemaValidator : public base##SchemaValidator \ - { \ - public: \ - virtual ~cname##SchemaValidator() {} \ - virtual void validate(const xmltooling::XMLObject* xmlObject) const { \ - const cname* ptr=dynamic_cast(xmlObject); \ - if (!ptr) \ - throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())); - -/** - * Ends the declaration of a Validator specialization. - */ -#define END_XMLOBJECTVALIDATOR } } - -/** - * Validator code that checks the object type. - * - * @param cname the name of the XMLObject specialization - */ -#define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \ - const cname* ptr=dynamic_cast(xmlObject); \ - if (!ptr) \ - throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())) - -/** - * Validator code that checks for a required attribute, content, or singleton. - * - * @param cname the name of the XMLObject specialization - * @param proper the proper name of the attribute, content, or singleton member - */ -#define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \ - if (!ptr->get##proper()) \ - throw xmltooling::ValidationException(#cname" must have "#proper".") - -/** - * Validator code that checks for a required integer attribute - * - * @param cname the name of the XMLObject specialization - * @param proper the proper name of the attribute, content, or singleton member - */ -#define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \ - if (!ptr->get##proper().first) \ - throw xmltooling::ValidationException(#cname" must have "#proper".") - -/** - * Validator code that checks for one of a pair of - * required attributes, content, or singletons. - * - * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member - */ -#define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \ - if (!ptr->get##proper1() && !ptr->get##proper2()) \ - throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2".") - -/** - * Validator code that checks for one of a pair of - * required attributes, content, or singletons, but disallows both. - * - * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member - */ -#define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \ - if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \ - throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2" but not both.") - -/** - * Validator code that checks for one of a set of three - * required attributes, content, or singletons. - * - * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member - * @param proper3 the proper name of the third attribute, content, or singleton member - */ -#define XMLOBJECTVALIDATOR_ONEOF3(cname,proper1,proper2,proper3) \ - if (!ptr->get##proper1() && !ptr->get##proper2() && !ptr->get##proper3()) \ - throw xmltooling::ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".") - -/** - * Validator code that checks for one of a set of three - * required attributes, content, or singletons but disallows more than one. - * - * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member - * @param proper3 the proper name of the third attribute, content, or singleton member - */ -#define XMLOBJECTVALIDATOR_ONLYONEOF3(cname,proper1,proper2,proper3) \ - int c##proper1##proper2##proper3=0; \ - if (ptr->get##proper1()!=NULL) \ - c##proper1##proper2##proper3++; \ - if (ptr->get##proper2()!=NULL) \ - c##proper1##proper2##proper3++; \ - if (ptr->get##proper3()!=NULL) \ - c##proper1##proper2##proper3++; \ - if (c##proper1##proper2##proper3 != 1) \ - throw xmltooling::ValidationException(#cname" must have only one of "#proper1", "#proper2", or "#proper3".") - -/** - * Validator code that checks a co-constraint (if one present, the other must be) - * between a pair of attributes, content, or singletons. - * - * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member - */ -#define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \ - if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \ - throw xmltooling::ValidationException(#cname" cannot have "#proper1" without "#proper2".") - -/** - * Validator code that checks for a non-empty collection. - * - * @param cname the name of the XMLObject specialization - * @param proper the proper name of the collection item - */ -#define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \ - if (ptr->get##proper##s().empty()) \ - throw xmltooling::ValidationException(#cname" must have at least one "#proper".") - -/** - * Declares/defines a Validator specialization that checks object type and - * a non-empty simple content model. - * - * @param linkage linkage specifier for the class - * @param cname the name of the XMLObject specialization - */ -#define XMLOBJECTVALIDATOR_SIMPLE(linkage,cname) \ - BEGIN_XMLOBJECTVALIDATOR(linkage,cname); \ - XMLOBJECTVALIDATOR_REQUIRE(cname,TextContent); \ - END_XMLOBJECTVALIDATOR - -#include - -/** - * @namespace xmltooling - * Public namespace of XML Tooling library - */ -namespace xmltooling { - - /** - * Template function for cloning a sequence of XMLObjects. - * Invokes the clone() member on each element of the input sequence and adds the copy to - * the output sequence. Order is preserved. - * - * @param in input sequence to clone - * @param out output sequence to copy cloned pointers into - */ - template void clone(const InputSequence& in, OutputSequence& out) { - for (typename InputSequence::const_iterator i=in.begin(); i!=in.end(); i++) { - if (*i) - out.push_back((*i)->clone()); - else - out.push_back(*i); - } - } - - /** - * Functor for cleaning up heap objects in containers. - */ - template struct cleanup - { - /** - * Function operator to delete an object. - * - * @param ptr object to delete - */ - void operator()(T* ptr) {delete ptr;} - - /** - * Function operator to delete an object stored as const. - * - * @param ptr object to delete after casting away const - */ - void operator()(const T* ptr) {delete const_cast(ptr);} - }; - - /** - * Functor for cleaning up heap objects in key/value containers. - */ - template struct cleanup_pair - { - /** - * Function operator to delete an object. - * - * @param p a pair in which the second component is the object to delete - */ - void operator()(const std::pair& p) {delete p.second;} - }; - - /** - * Functor for cleaning up const heap objects in key/value containers. - */ - template struct cleanup_const_pair - { - /** - * Function operator to delete an object stored as const - * - * @param p a pair in which the second component is the const object to delete - */ - void operator()(const std::pair& p) {delete const_cast(p.second);} - }; -}; - -#endif /* __xmltooling_base_h__ */ +/* + * Copyright 2001-2007 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file xmltooling/base.h + * + * Base header file definitions + * Must be included prior to including any other header + */ + +#ifndef __xmltooling_base_h__ +#define __xmltooling_base_h__ + +#include + +#if defined (_MSC_VER) || defined(__BORLANDC__) + #include +#else + #include +#endif + +#ifdef XMLTOOLING_LITE +# define XMLTOOLING_NO_XMLSEC 1 +#endif + +// Windows and GCC4 Symbol Visibility Macros +#ifdef WIN32 + #define XMLTOOL_IMPORT __declspec(dllimport) + #define XMLTOOL_EXPORT __declspec(dllexport) + #define XMLTOOL_DLLLOCAL + #define XMLTOOL_DLLPUBLIC +#else + #define XMLTOOL_IMPORT + #ifdef GCC_HASCLASSVISIBILITY + #define XMLTOOL_EXPORT __attribute__ ((visibility("default"))) + #define XMLTOOL_DLLLOCAL __attribute__ ((visibility("hidden"))) + #define XMLTOOL_DLLPUBLIC __attribute__ ((visibility("default"))) + #else + #define XMLTOOL_EXPORT + #define XMLTOOL_DLLLOCAL + #define XMLTOOL_DLLPUBLIC + #endif +#endif + +// Define XMLTOOL_API for DLL builds +#ifdef XMLTOOLING_EXPORTS + #define XMLTOOL_API XMLTOOL_EXPORT +#else + #define XMLTOOL_API XMLTOOL_IMPORT +#endif + +// Throwable classes must always be visible on GCC in all binaries +#ifdef WIN32 + #define XMLTOOL_EXCEPTIONAPI(api) api +#elif defined(GCC_HASCLASSVISIBILITY) + #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT +#else + #define XMLTOOL_EXCEPTIONAPI(api) +#endif + +#ifdef _MSC_VER + #define XMLTOOLING_DOXYGEN(desc) /##** desc */ +#else + #define XMLTOOLING_DOXYGEN(desc) +#endif + +/** + * Blocks copy c'tor and assignment operator for a class. + */ +#define MAKE_NONCOPYABLE(type) \ + private: \ + type(const type&); \ + type& operator=(const type&) + +#ifndef DOXYGEN_SKIP +#ifndef NULL +#define NULL 0 +#endif +#define UNICODE_LITERAL_1(a) {xercesc::chLatin_##a, xercesc::chNull} +#define UNICODE_LITERAL_2(a,b) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chNull} +#define UNICODE_LITERAL_3(a,b,c) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chNull} +#define UNICODE_LITERAL_4(a,b,c,d) {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chNull} +#define UNICODE_LITERAL_5(a,b,c,d,e) \ + {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chNull} +#define UNICODE_LITERAL_6(a,b,c,d,e,f) \ + {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chNull} +#define UNICODE_LITERAL_7(a,b,c,d,e,f,g) \ + {xercesc::chLatin_##a, xercesc::chLatin_##b, xercesc::chLatin_##c, xercesc::chLatin_##d, xercesc::chLatin_##e, xercesc::chLatin_##f, xercesc::chLatin_##g, xercesc::chNull} +#define UNICODE_LITERAL_8(a,b,c,d,e,f,g,h) \ + {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} +#define UNICODE_LITERAL_9(a,b,c,d,e,f,g,h,i) \ + {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} +#define UNICODE_LITERAL_10(a,b,c,d,e,f,g,h,i,j) \ + {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::chLatin_##j, xercesc::chNull} +#define UNICODE_LITERAL_11(a,b,c,d,e,f,g,h,i,j,k) \ + {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chNull} +#define UNICODE_LITERAL_12(a,b,c,d,e,f,g,h,i,j,k,l) \ + {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chNull} +#define UNICODE_LITERAL_13(a,b,c,d,e,f,g,h,i,j,k,l,m) \ + {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chNull} +#define UNICODE_LITERAL_14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) \ + {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chNull} +#define UNICODE_LITERAL_15(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \ + {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chNull} +#define UNICODE_LITERAL_16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \ + {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::chLatin_##j, xercesc::chLatin_##k, xercesc::chLatin_##l, xercesc::chLatin_##m, xercesc::chLatin_##n, xercesc::chLatin_##o, xercesc::chLatin_##p, xercesc::chNull} +#define UNICODE_LITERAL_17(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) \ + {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::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} +#define UNICODE_LITERAL_18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) \ + {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::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} +#define UNICODE_LITERAL_19(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) \ + {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::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::chLatin_##s, xercesc::chNull} +#define UNICODE_LITERAL_20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chNull} +#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) \ + {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::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::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} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + xercesc::chLatin_##aa, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + xercesc::chLatin_##aa, xercesc::chLatin_##bb, xercesc::chLatin_##cc, xercesc::chLatin_##dd, xercesc::chLatin_##ee, xercesc::chLatin_##ff, xercesc::chLatin_##gg, xercesc::chNull} +#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) \ + {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::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::chLatin_##s, xercesc::chLatin_##t, xercesc::chLatin_##u, xercesc::chLatin_##v, xercesc::chLatin_##w, xercesc::chLatin_##x, xercesc::chLatin_##y, xercesc::chLatin_##z, \ + 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} +#endif /* DOXYGEN_SKIP */ + +/** + * Begins the declaration of an XMLObject specialization for an abstract element/type. + * Basic boilerplate includes a protected constructor, empty virtual destructor, + * and Unicode constants for the default associated element's name and prefix. + * + * @param linkage linkage specifier for the class + * @param cname the name of the class to declare + * @param base the base class to derive from using public virtual inheritance + * @param desc documentation comment for class + */ +#define DECL_XMLOBJECT_ABSTRACT(linkage,cname,base,desc) \ + XMLTOOLING_DOXYGEN(desc) \ + class linkage cname : public virtual base { \ + protected: \ + cname() {} \ + public: \ + virtual ~cname() {} \ + XMLTOOLING_DOXYGEN(Element local name) \ + static const XMLCh LOCAL_NAME[]; \ + } + +/** + * Begins the declaration of an XMLObject specialization. + * Basic boilerplate includes a protected constructor, empty virtual destructor, + * and Unicode constants for the default associated element's name and prefix. + * + * @param linkage linkage specifier for the class + * @param cname the name of the class to declare + * @param base the base class to derive from using public virtual inheritance + * @param desc documentation comment for class + */ +#define BEGIN_XMLOBJECT(linkage,cname,base,desc) \ + XMLTOOLING_DOXYGEN(desc) \ + class linkage cname : public virtual base { \ + protected: \ + cname() {} \ + public: \ + virtual ~cname() {} \ + XMLTOOLING_DOXYGEN(Type-specific clone method.) \ + virtual cname* clone##cname() const=0; \ + XMLTOOLING_DOXYGEN(Element local name) \ + static const XMLCh LOCAL_NAME[] + +/** + * Begins the declaration of an XMLObject specialization with two base classes. + * Basic boilerplate includes a protected constructor, empty virtual destructor, + * and Unicode constants for the default associated element's name and prefix. + * + * @param linkage linkage specifier for the class + * @param cname the name of the class to declare + * @param base the first base class to derive from using public virtual inheritance + * @param base2 the second base class to derive from using public virtual inheritance + * @param desc documentation comment for class + */ +#define BEGIN_XMLOBJECT2(linkage,cname,base,base2,desc) \ + XMLTOOLING_DOXYGEN(desc) \ + class linkage cname : public virtual base, public virtual base2 { \ + protected: \ + cname() {} \ + public: \ + virtual ~cname() {} \ + XMLTOOLING_DOXYGEN(Type-specific clone method.) \ + virtual cname* clone##cname() const=0; \ + XMLTOOLING_DOXYGEN(Element local name) \ + static const XMLCh LOCAL_NAME[] + +/** + * Begins the declaration of an XMLObject specialization with three base classes. + * Basic boilerplate includes a protected constructor, empty virtual destructor, + * and Unicode constants for the default associated element's name and prefix. + * + * @param linkage linkage specifier for the class + * @param cname the name of the class to declare + * @param base the first base class to derive from using public virtual inheritance + * @param base2 the second base class to derive from using public virtual inheritance + * @param base3 the third base class to derive from using public virtual inheritance + * @param desc documentation comment for class + */ +#define BEGIN_XMLOBJECT3(linkage,cname,base,base2,base3,desc) \ + XMLTOOLING_DOXYGEN(desc) \ + class linkage cname : public virtual base, public virtual base2, public virtual base3 { \ + protected: \ + cname() {} \ + public: \ + virtual ~cname() {} \ + XMLTOOLING_DOXYGEN(Type-specific clone method.) \ + virtual cname* clone##cname() const=0; \ + XMLTOOLING_DOXYGEN(Element local name) \ + static const XMLCh LOCAL_NAME[] + +/** + * Begins the declaration of an XMLObject specialization with four base classes. + * Basic boilerplate includes a protected constructor, empty virtual destructor, + * and Unicode constants for the default associated element's name and prefix. + * + * @param linkage linkage specifier for the class + * @param cname the name of the class to declare + * @param base the first base class to derive from using public virtual inheritance + * @param base2 the second base class to derive from using public virtual inheritance + * @param base3 the third base class to derive from using public virtual inheritance + * @param base4 the fourth base class to derive from using public virtual inheritance + * @param desc documentation comment for class + */ +#define BEGIN_XMLOBJECT4(linkage,cname,base,base2,base3,base4,desc) \ + XMLTOOLING_DOXYGEN(desc) \ + class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4 { \ + protected: \ + cname() {} \ + public: \ + virtual ~cname() {} \ + XMLTOOLING_DOXYGEN(Type-specific clone method.) \ + virtual cname* clone##cname() const=0; \ + XMLTOOLING_DOXYGEN(Element local name) \ + static const XMLCh LOCAL_NAME[] + +/** + * Begins the declaration of an XMLObject specialization with five base classes. + * Basic boilerplate includes a protected constructor, empty virtual destructor, + * and Unicode constants for the default associated element's name and prefix. + * + * @param linkage linkage specifier for the class + * @param cname the name of the class to declare + * @param base the first base class to derive from using public virtual inheritance + * @param base2 the second base class to derive from using public virtual inheritance + * @param base3 the third base class to derive from using public virtual inheritance + * @param base4 the fourth base class to derive from using public virtual inheritance + * @param base5 the fifth base class to derive from using public virtual inheritance + * @param desc documentation comment for class + */ +#define BEGIN_XMLOBJECT5(linkage,cname,base,base2,base3,base4,base5,desc) \ + XMLTOOLING_DOXYGEN(desc) \ + class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4, public virtual base5 { \ + protected: \ + cname() {} \ + public: \ + virtual ~cname() {} \ + XMLTOOLING_DOXYGEN(Type-specific clone method.) \ + virtual cname* clone##cname() const=0; \ + XMLTOOLING_DOXYGEN(Element local name) \ + static const XMLCh LOCAL_NAME[] + +/** + * Ends the declaration of an XMLObject specialization. + */ +#define END_XMLOBJECT } + +/** + * Declares a static variable holding the XMLObject's element QName. + */ +#define DECL_ELEMENT_QNAME \ + public: \ + XMLTOOLING_DOXYGEN(Element QName) \ + static xmltooling::QName ELEMENT_QNAME + +/** + * Declares a static variable holding the XMLObject's schema type QName. + */ +#define DECL_TYPE_QNAME \ + public: \ + XMLTOOLING_DOXYGEN(Type QName) \ + static xmltooling::QName TYPE_QNAME + +/** + * Implements a static variable holding an XMLObject's element QName. + * + * @param cname the name of the XMLObject specialization + * @param namespaceURI the XML namespace of the default associated element + * @param namespacePrefix the XML namespace prefix of the default associated element + */ +#define IMPL_ELEMENT_QNAME(cname,namespaceURI,namespacePrefix) \ + xmltooling::QName cname::ELEMENT_QNAME(namespaceURI,cname::LOCAL_NAME,namespacePrefix) + +/** + * Implements a static variable holding an XMLObject's schema type QName. + * + * @param cname the name of the XMLObject specialization + * @param namespaceURI the XML namespace of the default associated element + * @param namespacePrefix the XML namespace prefix of the default associated element + */ +#define IMPL_TYPE_QNAME(cname,namespaceURI,namespacePrefix) \ + xmltooling::QName cname::TYPE_QNAME(namespaceURI,cname::TYPE_NAME,namespacePrefix) + +/** + * Declares abstract set method for a typed XML attribute. + * The get method is omitted. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + * @param type the attribute's data type + */ +#define DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,type) \ + public: \ + XMLTOOLING_DOXYGEN(proper attribute name) \ + static const XMLCh upcased##_ATTRIB_NAME[]; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(const type* proper)=0 + +/** + * Declares abstract get/set methods for a typed XML attribute. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + * @param type the attribute's data type + */ +#define DECL_XMLOBJECT_ATTRIB(proper,upcased,type) \ + public: \ + XMLTOOLING_DOXYGEN(proper attribute name) \ + static const XMLCh upcased##_ATTRIB_NAME[]; \ + XMLTOOLING_DOXYGEN(Returns the proper attribute.) \ + virtual const type* get##proper() const=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(const type* proper)=0 + +/** + * Declares abstract set method for a string XML attribute. + * The get method is omitted. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + */ +#define DECL_INHERITED_STRING_ATTRIB(proper,upcased) \ + DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,XMLCh) + +/** + * Declares abstract get/set methods for a string XML attribute. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + */ +#define DECL_STRING_ATTRIB(proper,upcased) \ + DECL_XMLOBJECT_ATTRIB(proper,upcased,XMLCh) + +/** + * Declares abstract set method for a DateTime XML attribute. + * The get method is omitted. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + */ +#define DECL_INHERITED_DATETIME_ATTRIB(proper,upcased) \ + DECL_INHERITED_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(time_t proper)=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(const XMLCh* proper)=0 + +/** + * Declares abstract get/set methods for a DateTime XML attribute. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + */ +#define DECL_DATETIME_ATTRIB(proper,upcased) \ + DECL_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \ + XMLTOOLING_DOXYGEN(Returns the proper attribute in epoch form.) \ + virtual time_t get##proper##Epoch() const=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(time_t proper)=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(const XMLCh* proper)=0 + +/** + * Declares abstract set method for an integer XML attribute. + * The get method is omitted. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + */ +#define DECL_INHERITED_INTEGER_ATTRIB(proper,upcased) \ + public: \ + XMLTOOLING_DOXYGEN(proper attribute name) \ + static const XMLCh upcased##_ATTRIB_NAME[]; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \ + virtual void set##proper(const XMLCh* proper)=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(int proper)=0 + +/** + * Declares abstract get/set methods for an integer XML attribute. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + */ +#define DECL_INTEGER_ATTRIB(proper,upcased) \ + public: \ + XMLTOOLING_DOXYGEN(proper attribute name) \ + static const XMLCh upcased##_ATTRIB_NAME[]; \ + XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \ + virtual std::pair get##proper() const=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute using a string value.) \ + virtual void set##proper(const XMLCh* proper)=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + virtual void set##proper(int proper)=0 + +/** + * Declares abstract get/set methods for a boolean XML attribute. + * + * @param proper the proper name of the attribute + * @param upcased the upcased name of the attribute + * @param def the default/presumed value, if no explicit value has been set + */ +#define DECL_BOOLEAN_ATTRIB(proper,upcased,def) \ + public: \ + XMLTOOLING_DOXYGEN(proper attribute name) \ + static const XMLCh upcased##_ATTRIB_NAME[]; \ + XMLTOOLING_DOXYGEN(Returns the proper attribute or def if not set.) \ + bool proper() const { \ + switch (get##proper()) { \ + case xmlconstants::XML_BOOL_TRUE: \ + case xmlconstants::XML_BOOL_ONE: \ + return true; \ + case xmlconstants::XML_BOOL_FALSE: \ + case xmlconstants::XML_BOOL_ZERO: \ + return false; \ + default: \ + return def; \ + } \ + } \ + XMLTOOLING_DOXYGEN(Returns the proper attribute as an explicit enumerated value.) \ + virtual xmlconstants::xmltooling_bool_t get##proper() const=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute using an enumerated value.) \ + virtual void proper(xmlconstants::xmltooling_bool_t value)=0; \ + XMLTOOLING_DOXYGEN(Sets the proper attribute.) \ + void proper(bool value) { \ + proper(value ? xmlconstants::XML_BOOL_ONE : xmlconstants::XML_BOOL_ZERO); \ + } \ + XMLTOOLING_DOXYGEN(Sets the proper attribute using a string constant.) \ + void set##proper(const XMLCh* value) { \ + if (value) { \ + switch (*value) { \ + case xercesc::chLatin_t: \ + proper(xmlconstants::XML_BOOL_TRUE); \ + break; \ + case xercesc::chLatin_f: \ + proper(xmlconstants::XML_BOOL_FALSE); \ + break; \ + case xercesc::chDigit_1: \ + proper(xmlconstants::XML_BOOL_ONE); \ + break; \ + case xercesc::chDigit_0: \ + proper(xmlconstants::XML_BOOL_ZERO); \ + break; \ + default: \ + proper(xmlconstants::XML_BOOL_NULL); \ + } \ + } \ + else \ + proper(xmlconstants::XML_BOOL_NULL); \ + } + +/** + * Implements get/set methods and a private member for a typed XML attribute. + * + * @param proper the proper name of the attribute + * @param type the attribute's data type + */ +#define IMPL_XMLOBJECT_ATTRIB(proper,type) \ + protected: \ + type* m_##proper; \ + public: \ + const type* get##proper() const { \ + return m_##proper; \ + } \ + void set##proper(const type* proper) { \ + m_##proper = prepareForAssignment(m_##proper,proper); \ + } + +/** + * Implements get/set methods and a private member for a string XML attribute. + * + * @param proper the proper name of the attribute + */ +#define IMPL_STRING_ATTRIB(proper) \ + IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) + +/** + * Implements get/set methods and a private member for a string XML attribute, + * plus a getXMLID override. + * + * @param proper the proper name of the attribute + */ +#define IMPL_ID_ATTRIB(proper) \ + IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) \ + const XMLCh* getXMLID() const { \ + return m_##proper; \ + } + +/** + * Implements get/set methods and a private member for a DateTime XML attribute. + * + * @param proper the proper name of the attribute + * @param fallback epoch to return when attribute is NULL + */ +#define IMPL_DATETIME_ATTRIB(proper,fallback) \ + protected: \ + DateTime* m_##proper; \ + time_t m_##proper##Epoch; \ + public: \ + const DateTime* get##proper() const { \ + return m_##proper; \ + } \ + time_t get##proper##Epoch() const { \ + return m_##proper ? m_##proper##Epoch : fallback; \ + } \ + void set##proper(const DateTime* proper) { \ + m_##proper = prepareForAssignment(m_##proper,proper); \ + if (m_##proper) \ + m_##proper##Epoch=m_##proper->getEpoch(); \ + } \ + void set##proper(time_t proper) { \ + m_##proper = prepareForAssignment(m_##proper,proper); \ + m_##proper##Epoch = proper; \ + } \ + void set##proper(const XMLCh* proper) { \ + m_##proper = prepareForAssignment(m_##proper,proper); \ + if (m_##proper) \ + m_##proper##Epoch=m_##proper->getEpoch(); \ + } + +/** + * Implements get/set methods and a private member for an integer XML attribute. + * + * @param proper the proper name of the attribute + */ +#define IMPL_INTEGER_ATTRIB(proper) \ + protected: \ + XMLCh* m_##proper; \ + public: \ + pair get##proper() const { \ + return make_pair((m_##proper!=NULL),(m_##proper!=NULL ? xercesc::XMLString::parseInt(m_##proper): 0)); \ + } \ + void set##proper(const XMLCh* proper) { \ + m_##proper = prepareForAssignment(m_##proper,proper); \ + } \ + void set##proper(int proper) { \ + char buf##proper[64]; \ + sprintf(buf##proper,"%d",proper); \ + auto_ptr_XMLCh wide##proper(buf##proper); \ + set##proper(wide##proper.get()); \ + } + +/** + * Implements get/set methods and a private member for a boolean XML attribute. + * + * @param proper the proper name of the attribute + */ +#define IMPL_BOOLEAN_ATTRIB(proper) \ + protected: \ + xmlconstants::xmltooling_bool_t m_##proper; \ + public: \ + xmlconstants::xmltooling_bool_t get##proper() const { \ + return m_##proper; \ + } \ + void proper(xmlconstants::xmltooling_bool_t value) { \ + if (m_##proper != value) { \ + releaseThisandParentDOM(); \ + m_##proper = value; \ + } \ + } + +/** + * Declares abstract set method for a typed XML child object in a foreign namespace. + * The get method is omitted. + * + * @param proper the proper name of the child type + * @param ns the C++ namespace for the type + */ +#define DECL_INHERITED_TYPED_FOREIGN_CHILD(proper,ns) \ + public: \ + XMLTOOLING_DOXYGEN(Sets the proper child.) \ + virtual void set##proper(ns::proper* child)=0 + +/** + * Declares abstract get/set methods for a typed XML child object in a foreign namespace. + * + * @param proper the proper name of the child type + * @param ns the C++ namespace for the type + */ +#define DECL_TYPED_FOREIGN_CHILD(proper,ns) \ + public: \ + XMLTOOLING_DOXYGEN(Returns the proper child.) \ + virtual ns::proper* get##proper() const=0; \ + XMLTOOLING_DOXYGEN(Sets the proper child.) \ + virtual void set##proper(ns::proper* child)=0 + +/** + * Declares abstract set method for a typed XML child object. + * The get method is omitted. + * + * @param proper the proper name of the child type + */ +#define DECL_INHERITED_TYPED_CHILD(proper) \ + public: \ + XMLTOOLING_DOXYGEN(Sets the proper child.) \ + virtual void set##proper(proper* child)=0 + +/** + * Declares abstract get/set methods for a typed XML child object. + * + * @param proper the proper name of the child type + */ +#define DECL_TYPED_CHILD(proper) \ + public: \ + XMLTOOLING_DOXYGEN(Returns the proper child.) \ + virtual proper* get##proper() const=0; \ + XMLTOOLING_DOXYGEN(Sets the proper child.) \ + virtual void set##proper(proper* child)=0 + +/** + * Declares abstract get/set methods for a generic XML child object. + * + * @param proper the proper name of the child + */ +#define DECL_XMLOBJECT_CHILD(proper) \ + public: \ + XMLTOOLING_DOXYGEN(Returns the proper child.) \ + virtual xmltooling::XMLObject* get##proper() const=0; \ + XMLTOOLING_DOXYGEN(Sets the proper child.) \ + virtual void set##proper(xmltooling::XMLObject* child)=0 + + +/** + * Implements get/set methods and a private list iterator member for a typed XML child object. + * + * @param proper the proper name of the child type + */ +#define IMPL_TYPED_CHILD(proper) \ + protected: \ + proper* m_##proper; \ + std::list::iterator m_pos_##proper; \ + public: \ + proper* get##proper() const { \ + return m_##proper; \ + } \ + void set##proper(proper* child) { \ + prepareForAssignment(m_##proper,child); \ + *m_pos_##proper = m_##proper = child; \ + } + +/** + * Implements get/set methods and a private list iterator member for + * a typed XML child object in a foreign namespace + * + * @param proper the proper name of the child type + * @param ns the C++ namespace for the type + */ +#define IMPL_TYPED_FOREIGN_CHILD(proper,ns) \ + protected: \ + ns::proper* m_##proper; \ + std::list::iterator m_pos_##proper; \ + public: \ + ns::proper* get##proper() const { \ + return m_##proper; \ + } \ + void set##proper(ns::proper* child) { \ + prepareForAssignment(m_##proper,child); \ + *m_pos_##proper = m_##proper = child; \ + } + +/** + * Implements get/set methods and a private list iterator member for a generic XML child object. + * + * @param proper the proper name of the child + */ +#define IMPL_XMLOBJECT_CHILD(proper) \ + protected: \ + xmltooling::XMLObject* m_##proper; \ + std::list::iterator m_pos_##proper; \ + public: \ + xmltooling::XMLObject* get##proper() const { \ + return m_##proper; \ + } \ + void set##proper(xmltooling::XMLObject* child) { \ + prepareForAssignment(m_##proper,child); \ + *m_pos_##proper = m_##proper = child; \ + } + +/** + * Declares abstract get/set methods for a typed XML child collection. + * + * @param proper the proper name of the child type + */ +#define DECL_TYPED_CHILDREN(proper) \ + public: \ + XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \ + virtual VectorOf(proper) get##proper##s()=0; \ + XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \ + virtual const std::vector& get##proper##s() const=0 + +/** + * Declares abstract get/set methods for a typed XML child collection in a foreign namespace. + * + * @param proper the proper name of the child type + * @param ns the C++ namespace for the type + */ +#define DECL_TYPED_FOREIGN_CHILDREN(proper,ns) \ + public: \ + XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \ + virtual VectorOf(ns::proper) get##proper##s()=0; \ + XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \ + virtual const std::vector& get##proper##s() const=0 + +/** + * Declares abstract get/set methods for a generic XML child collection. + * + * @param proper the proper name of the child + */ +#define DECL_XMLOBJECT_CHILDREN(proper) \ + public: \ + XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \ + virtual VectorOf(xmltooling::XMLObject) get##proper##s()=0; \ + XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \ + virtual const std::vector& get##proper##s() const=0 + +/** + * Implements get method and a private vector member for a typed XML child collection. + * + * @param proper the proper name of the child type + * @param fence insertion fence for new objects of the child collection in backing list + */ +#define IMPL_TYPED_CHILDREN(proper,fence) \ + protected: \ + std::vector m_##proper##s; \ + public: \ + VectorOf(proper) get##proper##s() { \ + return VectorOf(proper)(this, m_##proper##s, &m_children, fence); \ + } \ + const std::vector& get##proper##s() const { \ + return m_##proper##s; \ + } + +/** + * Implements get method and a private vector member for a typed XML child collection + * in a foreign namespace. + * + * @param proper the proper name of the child type + * @param ns the C++ namespace for the type + * @param fence insertion fence for new objects of the child collection in backing list + */ +#define IMPL_TYPED_FOREIGN_CHILDREN(proper,ns,fence) \ + protected: \ + std::vector m_##proper##s; \ + public: \ + VectorOf(ns::proper) get##proper##s() { \ + return VectorOf(ns::proper)(this, m_##proper##s, &m_children, fence); \ + } \ + const std::vector& get##proper##s() const { \ + return m_##proper##s; \ + } + +/** + * Implements get method and a private vector member for a generic XML child collection. + * + * @param proper the proper name of the child + * @param fence insertion fence for new objects of the child collection in backing list + */ +#define IMPL_XMLOBJECT_CHILDREN(proper,fence) \ + protected: \ + std::vector m_##proper##s; \ + public: \ + VectorOf(xmltooling::XMLObject) get##proper##s() { \ + return VectorOf(xmltooling::XMLObject)(this, m_##proper##s, &m_children, fence); \ + } \ + const std::vector& get##proper##s() const { \ + return m_##proper##s; \ + } + +/** + * Implements marshalling for a string attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define MARSHALL_STRING_ATTRIB(proper,ucase,namespaceURI) \ + if (m_##proper && *m_##proper) { \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ + } + +/** + * Implements marshalling for a DateTime attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define MARSHALL_DATETIME_ATTRIB(proper,ucase,namespaceURI) \ + if (m_##proper) { \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper->getRawData()); \ + } + +/** + * Implements marshalling for an integer attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define MARSHALL_INTEGER_ATTRIB(proper,ucase,namespaceURI) \ + if (m_##proper && *m_##proper) { \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ + } + +/** + * Implements marshalling for a boolean attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define MARSHALL_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \ + switch (m_##proper) { \ + case xmlconstants::XML_BOOL_TRUE: \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_TRUE); \ + break; \ + case xmlconstants::XML_BOOL_ONE: \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ONE); \ + break; \ + case xmlconstants::XML_BOOL_FALSE: \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_FALSE); \ + break; \ + case xmlconstants::XML_BOOL_ZERO: \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, xmlconstants::XML_ZERO); \ + break; \ + case xmlconstants::XML_BOOL_NULL: \ + break; \ + } + +/** + * Implements marshalling for a QName attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define MARSHALL_QNAME_ATTRIB(proper,ucase,namespaceURI) \ + if (m_##proper) { \ + auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \ + } + +/** + * Implements marshalling for an ID attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \ + if (m_##proper && *m_##proper) { \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ + domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \ + } + +/** + * Implements unmarshalling process branch for a string attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define PROC_STRING_ATTRIB(proper,ucase,namespaceURI) \ + if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ + set##proper(attribute->getValue()); \ + return; \ + } + +/** + * Implements unmarshalling process branch for an ID attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \ + if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ + set##proper(attribute->getValue()); \ + attribute->getOwnerElement()->setIdAttributeNode(attribute); \ + return; \ + } + +/** + * Implements unmarshalling process branch for a DateTime attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define PROC_DATETIME_ATTRIB(proper,ucase,namespaceURI) \ + PROC_STRING_ATTRIB(proper,ucase,namespaceURI) + +/** + * Implements unmarshalling process branch for a DateTime attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \ + if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ + set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \ + return; \ + } + +/** + * Implements unmarshalling process branch for an integer attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define PROC_INTEGER_ATTRIB(proper,ucase,namespaceURI) \ + PROC_STRING_ATTRIB(proper,ucase,namespaceURI) + +/** + * Implements unmarshalling process branch for a boolean attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +#define PROC_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \ + PROC_STRING_ATTRIB(proper,ucase,namespaceURI) + +/** + * Implements unmarshalling process branch for typed child collection element + * + * @param proper the proper name of the child type + * @param namespaceURI the XML namespace of the child element + * @param force bypass use of hint and just cast down to check child + */ +#define PROC_TYPED_CHILDREN(proper,namespaceURI,force) \ + if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \ + proper* typesafe=dynamic_cast(childXMLObject); \ + if (typesafe) { \ + get##proper##s().push_back(typesafe); \ + return; \ + } \ + } + +/** + * Implements unmarshalling process branch for typed child collection element + * in a foreign namespace. + * + * @param proper the proper name of the child type + * @param ns the C++ namespace for the type + * @param namespaceURI the XML namespace of the child element + * @param force bypass use of hint and just cast down to check child + */ +#define PROC_TYPED_FOREIGN_CHILDREN(proper,ns,namespaceURI,force) \ + if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \ + ns::proper* typesafe=dynamic_cast(childXMLObject); \ + if (typesafe) { \ + get##proper##s().push_back(typesafe); \ + return; \ + } \ + } + +/** + * Implements unmarshalling process branch for typed child singleton element + * + * @param proper the proper name of the child type + * @param namespaceURI the XML namespace of the child element + * @param force bypass use of hint and just cast down to check child + */ +#define PROC_TYPED_CHILD(proper,namespaceURI,force) \ + if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \ + proper* typesafe=dynamic_cast(childXMLObject); \ + if (typesafe && !m_##proper) { \ + typesafe->setParent(this); \ + *m_pos_##proper = m_##proper = typesafe; \ + return; \ + } \ + } + +/** + * Implements unmarshalling process branch for typed child singleton element + * in a foreign namespace. + * + * @param proper the proper name of the child type + * @param ns the C++ namespace for the type + * @param namespaceURI the XML namespace of the child element + * @param force bypass use of hint and just cast down to check child + */ +#define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \ + if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \ + ns::proper* typesafe=dynamic_cast(childXMLObject); \ + if (typesafe && !m_##proper) { \ + typesafe->setParent(this); \ + *m_pos_##proper = m_##proper = typesafe; \ + return; \ + } \ + } + +/** + * Implements unmarshalling process branch for a generic child singleton element + * + * @param proper the proper name of the child type + * @param namespaceURI the XML namespace of the child element + */ +#define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \ + if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \ + if (!m_##proper) { \ + childXMLObject->setParent(this); \ + *m_pos_##proper = m_##proper = childXMLObject; \ + return; \ + } \ + } + +/** + * Declares aliased get/set methods for named XML element simple content. + * + * @param proper the proper name to label the element's content + */ +#define DECL_SIMPLE_CONTENT(proper) \ + XMLTOOLING_DOXYGEN(Returns proper.) \ + const XMLCh* get##proper() const { \ + return getTextContent(); \ + } \ + XMLTOOLING_DOXYGEN(Sets or clears proper.) \ + void set##proper(const XMLCh* proper) { \ + setTextContent(proper); \ + } + +/** + * Declares aliased get/set methods for named integer XML element content. + * + * @param proper the proper name to label the element's content + */ +#define DECL_INTEGER_CONTENT(proper) \ + XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \ + std::pair get##proper() const { \ + return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? xercesc::XMLString::parseInt(getTextContent()) : 0)); \ + } \ + XMLTOOLING_DOXYGEN(Sets proper.) \ + void set##proper(int proper) { \ + char buf[64]; \ + sprintf(buf,"%d",proper); \ + xmltooling::auto_ptr_XMLCh widebuf(buf); \ + setTextContent(widebuf.get()); \ + } \ + XMLTOOLING_DOXYGEN(Sets or clears proper.) \ + void set##proper(const XMLCh* proper) { \ + setTextContent(proper); \ + } + +/** + * Implements cloning methods for an XMLObject specialization implementation class. + * + * @param cname the name of the XMLObject specialization + */ +#define IMPL_XMLOBJECT_CLONE(cname) \ + cname* clone##cname() const { \ + return dynamic_cast(clone()); \ + } \ + xmltooling::XMLObject* clone() const { \ + std::auto_ptr domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \ + cname##Impl* ret=dynamic_cast(domClone.get()); \ + if (ret) { \ + domClone.release(); \ + return ret; \ + } \ + return new cname##Impl(*this); \ + } + +/** + * Declares an XMLObject specialization with a simple content model and type, + * handling it as string data. + * + * @param linkage linkage specifier for the class + * @param cname the name of the XMLObject specialization + * @param proper the proper name to label the element's content + * @param desc documentation for class + */ +#define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \ + BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \ + DECL_SIMPLE_CONTENT(proper); \ + END_XMLOBJECT + +/** + * Declares and defines an implementation class for an XMLObject with + * a simple content model and type, handling it as string data. + * + * @param linkage linkage specifier for the class + * @param cname the name of the XMLObject specialization + */ +#define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname) \ + class linkage cname##Impl \ + : public virtual cname, \ + public xmltooling::AbstractSimpleElement, \ + public xmltooling::AbstractDOMCachingXMLObject, \ + public xmltooling::AbstractXMLObjectMarshaller, \ + public xmltooling::AbstractXMLObjectUnmarshaller \ + { \ + public: \ + virtual ~cname##Impl() {} \ + cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \ + : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \ + } \ + cname##Impl(const cname##Impl& src) \ + : xmltooling::AbstractXMLObject(src), \ + xmltooling::AbstractSimpleElement(src), \ + xmltooling::AbstractDOMCachingXMLObject(src) {} \ + IMPL_XMLOBJECT_CLONE(cname) \ + } + +#ifdef HAVE_COVARIANT_RETURNS + +/** + * Begins the declaration of an XMLObjectBuilder specialization. + * Basic boilerplate includes an empty virtual destructor, and + * a default builder that defaults the element name. + * + * @param linkage linkage specifier for the class + * @param cname the name of the XMLObject specialization + * @param namespaceURI the XML namespace of the default associated element + * @param namespacePrefix the XML namespace prefix of the default associated element + */ +#define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ + XMLTOOLING_DOXYGEN(Builder for cname objects.) \ + class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \ + public: \ + virtual ~cname##Builder() {} \ + XMLTOOLING_DOXYGEN(Default builder.) \ + virtual cname* buildObject() const { \ + return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \ + } \ + XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \ + virtual cname* buildObject( \ + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \ + ) const + +/** + * Ends the declaration of an XMLObjectBuilder specialization. + */ +#define END_XMLOBJECTBUILDER } + +/** + * Declares a generic XMLObjectBuilder specialization. + * + * @param linkage linkage specifier for the class + * @param cname the name of the XMLObject specialization + * @param namespaceURI the XML namespace of the default associated element + * @param namespacePrefix the XML namespace prefix of the default associated element + */ + #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ + BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \ + XMLTOOLING_DOXYGEN(Singleton builder.) \ + static cname* build##cname() { \ + const cname##Builder* b = dynamic_cast( \ + XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \ + ); \ + if (b) \ + return b->buildObject(); \ + throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \ + } \ + END_XMLOBJECTBUILDER + +/** + * Implements the standard XMLObjectBuilder specialization function. + * + * @param cname the name of the XMLObject specialization + */ +#define IMPL_XMLOBJECTBUILDER(cname) \ + cname* cname##Builder::buildObject( \ + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \ + ) const \ + { \ + return new cname##Impl(nsURI,localName,prefix,schemaType); \ + } + +#else /* !HAVE_COVARIANT_RETURNS */ + +/** + * Begins the declaration of an XMLObjectBuilder specialization. + * Basic boilerplate includes an empty virtual destructor, and + * a default builder that defaults the element name. + * + * @param linkage linkage specifier for the class + * @param cname the name of the XMLObject specialization + * @param namespaceURI the XML namespace of the default associated element + * @param namespacePrefix the XML namespace prefix of the default associated element + */ +#define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ + XMLTOOLING_DOXYGEN(Builder for cname objects.) \ + class linkage cname##Builder : public xmltooling::ConcreteXMLObjectBuilder { \ + public: \ + virtual ~cname##Builder() {} \ + XMLTOOLING_DOXYGEN(Default builder.) \ + virtual xmltooling::XMLObject* buildObject() const { \ + return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \ + } \ + XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \ + virtual xmltooling::XMLObject* buildObject( \ + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \ + ) const + +/** + * Ends the declaration of an XMLObjectBuilder specialization. + */ +#define END_XMLOBJECTBUILDER } + +/** + * Declares a generic XMLObjectBuilder specialization. + * + * @param linkage linkage specifier for the class + * @param cname the name of the XMLObject specialization + * @param namespaceURI the XML namespace of the default associated element + * @param namespacePrefix the XML namespace prefix of the default associated element + */ + #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \ + BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \ + XMLTOOLING_DOXYGEN(Singleton builder.) \ + static cname* build##cname() { \ + const cname##Builder* b = dynamic_cast( \ + XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \ + ); \ + if (b) \ + return dynamic_cast(b->buildObject()); \ + throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \ + } \ + END_XMLOBJECTBUILDER + +/** + * Implements the standard XMLObjectBuilder specialization function. + * + * @param cname the name of the XMLObject specialization + */ +#define IMPL_XMLOBJECTBUILDER(cname) \ + xmltooling::XMLObject* cname##Builder::buildObject( \ + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \ + ) const \ + { \ + return new cname##Impl(nsURI,localName,prefix,schemaType); \ + } + +#endif /* HAVE_COVARIANT_RETURNS */ + +/** + * Begins the declaration of a Schema Validator specialization. + * + * @param linkage linkage specifier for the class + * @param cname the base name of the Validator specialization + */ + #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \ + class linkage cname##SchemaValidator : public xmltooling::Validator \ + { \ + public: \ + virtual ~cname##SchemaValidator() {} \ + virtual void validate(const xmltooling::XMLObject* xmlObject) const { \ + const cname* ptr=dynamic_cast(xmlObject); \ + if (!ptr) \ + throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())); \ + if (ptr->nil() && (ptr->hasChildren() || ptr->getTextContent())) \ + throw xmltooling::ValidationException("Object has nil property but with children or content.") + +/** + * Begins the declaration of a Schema Validator specialization subclass. + * + * @param linkage linkage specifier for the class + * @param cname the base name of the Validator specialization + * @param base base class for the validator + */ + #define BEGIN_XMLOBJECTVALIDATOR_SUB(linkage,cname,base) \ + class linkage cname##SchemaValidator : public base##SchemaValidator \ + { \ + public: \ + virtual ~cname##SchemaValidator() {} \ + virtual void validate(const xmltooling::XMLObject* xmlObject) const { \ + const cname* ptr=dynamic_cast(xmlObject); \ + if (!ptr) \ + throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())); + +/** + * Ends the declaration of a Validator specialization. + */ +#define END_XMLOBJECTVALIDATOR } } + +/** + * Validator code that checks the object type. + * + * @param cname the name of the XMLObject specialization + */ +#define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \ + const cname* ptr=dynamic_cast(xmlObject); \ + if (!ptr) \ + throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name())) + +/** + * Validator code that checks for a required attribute, content, or singleton. + * + * @param cname the name of the XMLObject specialization + * @param proper the proper name of the attribute, content, or singleton member + */ +#define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \ + if (!ptr->get##proper()) \ + throw xmltooling::ValidationException(#cname" must have "#proper".") + +/** + * Validator code that checks for a required integer attribute + * + * @param cname the name of the XMLObject specialization + * @param proper the proper name of the attribute, content, or singleton member + */ +#define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \ + if (!ptr->get##proper().first) \ + throw xmltooling::ValidationException(#cname" must have "#proper".") + +/** + * Validator code that checks for one of a pair of + * required attributes, content, or singletons. + * + * @param cname the name of the XMLObject specialization + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member + */ +#define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \ + if (!ptr->get##proper1() && !ptr->get##proper2()) \ + throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2".") + +/** + * Validator code that checks for one of a pair of + * required attributes, content, or singletons, but disallows both. + * + * @param cname the name of the XMLObject specialization + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member + */ +#define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \ + if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \ + throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2" but not both.") + +/** + * Validator code that checks for one of a set of three + * required attributes, content, or singletons. + * + * @param cname the name of the XMLObject specialization + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member + * @param proper3 the proper name of the third attribute, content, or singleton member + */ +#define XMLOBJECTVALIDATOR_ONEOF3(cname,proper1,proper2,proper3) \ + if (!ptr->get##proper1() && !ptr->get##proper2() && !ptr->get##proper3()) \ + throw xmltooling::ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".") + +/** + * Validator code that checks for one of a set of three + * required attributes, content, or singletons but disallows more than one. + * + * @param cname the name of the XMLObject specialization + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member + * @param proper3 the proper name of the third attribute, content, or singleton member + */ +#define XMLOBJECTVALIDATOR_ONLYONEOF3(cname,proper1,proper2,proper3) \ + int c##proper1##proper2##proper3=0; \ + if (ptr->get##proper1()!=NULL) \ + c##proper1##proper2##proper3++; \ + if (ptr->get##proper2()!=NULL) \ + c##proper1##proper2##proper3++; \ + if (ptr->get##proper3()!=NULL) \ + c##proper1##proper2##proper3++; \ + if (c##proper1##proper2##proper3 != 1) \ + throw xmltooling::ValidationException(#cname" must have only one of "#proper1", "#proper2", or "#proper3".") + +/** + * Validator code that checks a co-constraint (if one present, the other must be) + * between a pair of attributes, content, or singletons. + * + * @param cname the name of the XMLObject specialization + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member + */ +#define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \ + if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \ + throw xmltooling::ValidationException(#cname" cannot have "#proper1" without "#proper2".") + +/** + * Validator code that checks for a non-empty collection. + * + * @param cname the name of the XMLObject specialization + * @param proper the proper name of the collection item + */ +#define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \ + if (ptr->get##proper##s().empty()) \ + throw xmltooling::ValidationException(#cname" must have at least one "#proper".") + +/** + * Declares/defines a Validator specialization that checks object type and + * a non-empty simple content model. + * + * @param linkage linkage specifier for the class + * @param cname the name of the XMLObject specialization + */ +#define XMLOBJECTVALIDATOR_SIMPLE(linkage,cname) \ + BEGIN_XMLOBJECTVALIDATOR(linkage,cname); \ + XMLOBJECTVALIDATOR_REQUIRE(cname,TextContent); \ + END_XMLOBJECTVALIDATOR + +#include + +/** + * @namespace xmltooling + * Public namespace of XML Tooling library + */ +namespace xmltooling { + + /** + * Template function for cloning a sequence of XMLObjects. + * Invokes the clone() member on each element of the input sequence and adds the copy to + * the output sequence. Order is preserved. + * + * @param in input sequence to clone + * @param out output sequence to copy cloned pointers into + */ + template void clone(const InputSequence& in, OutputSequence& out) { + for (typename InputSequence::const_iterator i=in.begin(); i!=in.end(); i++) { + if (*i) + out.push_back((*i)->clone()); + else + out.push_back(*i); + } + } + + /** + * Functor for cleaning up heap objects in containers. + */ + template struct cleanup + { + /** + * Function operator to delete an object. + * + * @param ptr object to delete + */ + void operator()(T* ptr) {delete ptr;} + + /** + * Function operator to delete an object stored as const. + * + * @param ptr object to delete after casting away const + */ + void operator()(const T* ptr) {delete const_cast(ptr);} + }; + + /** + * Functor for cleaning up heap objects in key/value containers. + */ + template struct cleanup_pair + { + /** + * Function operator to delete an object. + * + * @param p a pair in which the second component is the object to delete + */ + void operator()(const std::pair& p) {delete p.second;} + }; + + /** + * Functor for cleaning up const heap objects in key/value containers. + */ + template struct cleanup_const_pair + { + /** + * Function operator to delete an object stored as const + * + * @param p a pair in which the second component is the const object to delete + */ + void operator()(const std::pair& p) {delete const_cast(p.second);} + }; +}; + +#endif /* __xmltooling_base_h__ */ diff --git a/xmltooling/exceptions.cpp b/xmltooling/exceptions.cpp index 4b15451..1d0e883 100644 --- a/xmltooling/exceptions.cpp +++ b/xmltooling/exceptions.cpp @@ -1,314 +1,315 @@ -/* - * Copyright 2001-2007 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * exceptions.cpp - * - * Exception classes - */ - -#include "internal.h" -#include "exceptions.h" -#include "XMLToolingConfig.h" -#include "util/URLEncoder.h" -#include "util/XMLConstants.h" -#include "util/XMLHelper.h" - -#include -#include -#include - -using namespace xmltooling; -using namespace std; -using xmlconstants::XMLTOOLING_NS; - -params::params(int count,...) -{ - va_list args; - va_start(args,count); - while (count--) - v.push_back(va_arg(args,char*)); - va_end(args); -} - -namedparams::namedparams(int count,...) -{ - count*=2; - va_list args; - va_start(args,count); - while (count--) - v.push_back(va_arg(args,char*)); - va_end(args); -} - -XMLToolingException::ExceptionFactoryMap XMLToolingException::m_factoryMap; - -XMLToolingException* XMLToolingException::getInstance(const char* exceptionClass) -{ - if (exceptionClass) { - ExceptionFactoryMap::const_iterator i=m_factoryMap.find(exceptionClass); - if (i!=m_factoryMap.end()) - return (i->second)(); - } - return new XMLToolingException(); -} - -XMLToolingException::XMLToolingException(const char* msg, const params& p) -{ - if (msg) - m_msg=msg; - addProperties(p); -} - -XMLToolingException::XMLToolingException(const char* msg, const namedparams& p) -{ - if (msg) - m_msg=msg; - addProperties(p); -} - -XMLToolingException::XMLToolingException(const std::string& msg, const params& p) : m_msg(msg) -{ - addProperties(p); -} - -XMLToolingException::XMLToolingException(const std::string& msg, const namedparams& p) : m_msg(msg) -{ - addProperties(p); -} - -void XMLToolingException::setMessage(const char* msg) -{ - if (msg) - m_msg=msg; - else - m_msg.erase(); - m_processedmsg.erase(); -} - -inline const char* get_digit_character() -{ - static const char s_characters[19] = - { - '9' - , '8' - , '7' - , '6' - , '5' - , '4' - , '3' - , '2' - , '1' - , '0' - , '1' - , '2' - , '3' - , '4' - , '5' - , '6' - , '7' - , '8' - , '9' - }; - static const char *s_mid = s_characters + 9; - - return s_mid; -} - -inline const char* unsigned_integer_to_string(char* buf, size_t cchBuf, int i) -{ - char* psz=buf + cchBuf - 1; // Set psz to last char - *psz = 0; // Set terminating null - - do { - unsigned int lsd = i % 10; // Get least significant - // digit - - i /= 10; // Prepare for next most - // significant digit - - --psz; // Move back - - *psz = get_digit_character()[lsd]; // Place the digit - - } while(i!=0 && psz>buf); - - return psz; -} - -void XMLToolingException::addProperties(const params& p) -{ - m_processedmsg.erase(); - int i=m_params.size()+1; - char buf[20]; - const vector& v=p.get(); - for (vector::const_iterator ci=v.begin(); ci!=v.end(); ci++) { - m_params[unsigned_integer_to_string(buf,sizeof(buf),i++)] = *ci; - } -} - -void XMLToolingException::addProperties(const namedparams& p) -{ - m_processedmsg.erase(); - const vector& v=p.get(); - for (vector::const_iterator ci=v.begin(); ci!=v.end(); ci++) { - m_params.erase(*ci); - m_params[*ci] = *(ci+1); - ci++; // advance past name to value, then loop will advance it again - } -} - -const char* XMLToolingException::getProperty(unsigned int index) const -{ - char buf[20]; - map::const_iterator i=m_params.find(unsigned_integer_to_string(buf,sizeof(buf),index)); - return (i==m_params.end()) ? NULL : i->second.c_str(); -} - -const char* XMLToolingException::getProperty(const char* name) const -{ - map::const_iterator i=m_params.find(name); - return (i==m_params.end()) ? NULL : i->second.c_str(); -} - -const char* XMLToolingException::getMessage() const -{ - if (!m_processedmsg.empty()) - return m_processedmsg.c_str(); - else if (m_params.empty()) - return m_msg.c_str(); - - static const char* legal="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_"; - - // Replace any parameters in the message. - string::size_type i=0,start=0; - while (start!=string::npos && startstart) - m_processedmsg += m_msg.substr(start,i-start); // append everything in between - start=i+1; // move start to the beginning of the token name - i=m_msg.find_first_not_of(legal,start); // find token delimiter - if (i==start) { // append a non legal character - m_processedmsg+=m_msg[start++]; - continue; - } - - // search for token in map - map::const_iterator param=m_params.find(m_msg.substr(start,(i==string::npos) ? i : i-start)); - if (param!=m_params.end()) { - m_processedmsg+=param->second; - start=i; - } - } - if (start!=string::npos && start&"); - if (pos > 0) { - s.append(start, pos); - start += pos; - } - else { - switch (*start) { - case '\'': s += "'"; break; - case '<': s += "<"; break; - case '>': s += ">"; break; - case '&': s += "&"; break; - default: s += *start; - } - start++; - } - } - s += post; -} - -string XMLToolingException::toString() const -{ - string xml=string(""; - const char* msg=getMessage(); - if (msg) - xml_encode(xml, "", msg, ""); - for (map::const_iterator i=m_params.begin(); i!=m_params.end(); i++) { - xml_encode(xml, "", i->second.c_str(), ""); - } - xml+=""; - return xml; -} - -string XMLToolingException::toQueryString() const -{ - string q; - const URLEncoder* enc = XMLToolingConfig::getConfig().getURLEncoder(); - for (map::const_iterator i=m_params.begin(); i!=m_params.end(); i++) { - if (!q.empty()) - q += '&'; - q = q + i->first + '=' + enc->encode(i->second.c_str()); - } - return q; -} - -XMLToolingException* XMLToolingException::fromStream(std::istream& in) -{ - static const XMLCh exception[] = UNICODE_LITERAL_9(e,x,c,e,p,t,i,o,n); - static const XMLCh message[] = UNICODE_LITERAL_7(m,e,s,s,a,g,e); - static const XMLCh name[] = UNICODE_LITERAL_4(n,a,m,e); - static const XMLCh param[] = UNICODE_LITERAL_5(p,a,r,a,m); - static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); - - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - - // Check root element. - const DOMElement* root=doc->getDocumentElement(); - if (!XMLHelper::isNodeNamed(root,XMLTOOLING_NS,exception)) { - doc->release(); - throw XMLToolingException("Invalid root element on serialized exception."); - } - - auto_ptr_char classname(root->getAttributeNS(NULL,type)); - auto_ptr excep(XMLToolingException::getInstance(classname.get())); - - DOMElement* child=XMLHelper::getFirstChildElement(root,XMLTOOLING_NS,message); - if (child && child->hasChildNodes()) { - auto_ptr_char m(child->getFirstChild()->getNodeValue()); - excep->setMessage(m.get()); - } - - child=XMLHelper::getFirstChildElement(root,XMLTOOLING_NS,param); - while (child && child->hasChildNodes()) { - auto_ptr_char n(child->getAttributeNS(NULL,name)); - char* v=toUTF8(child->getFirstChild()->getNodeValue()); - if (n.get() && v) - excep->addProperty(n.get(), v); - delete[] v; - child=XMLHelper::getNextSiblingElement(child,XMLTOOLING_NS,param); - } - - doc->release(); - return excep.release(); -} - -XMLToolingException* XMLToolingException::fromString(const char* s) -{ - istringstream in(s); - return fromStream(in); -} +/* + * Copyright 2001-2007 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * exceptions.cpp + * + * Exception classes + */ + +#include "internal.h" +#include "exceptions.h" +#include "XMLToolingConfig.h" +#include "util/URLEncoder.h" +#include "util/XMLConstants.h" +#include "util/XMLHelper.h" + +#include +#include +#include +#include + +using namespace xmltooling; +using namespace std; +using xmlconstants::XMLTOOLING_NS; + +params::params(int count,...) +{ + va_list args; + va_start(args,count); + while (count--) + v.push_back(va_arg(args,char*)); + va_end(args); +} + +namedparams::namedparams(int count,...) +{ + count*=2; + va_list args; + va_start(args,count); + while (count--) + v.push_back(va_arg(args,char*)); + va_end(args); +} + +XMLToolingException::ExceptionFactoryMap XMLToolingException::m_factoryMap; + +XMLToolingException* XMLToolingException::getInstance(const char* exceptionClass) +{ + if (exceptionClass) { + ExceptionFactoryMap::const_iterator i=m_factoryMap.find(exceptionClass); + if (i!=m_factoryMap.end()) + return (i->second)(); + } + return new XMLToolingException(); +} + +XMLToolingException::XMLToolingException(const char* msg, const params& p) +{ + if (msg) + m_msg=msg; + addProperties(p); +} + +XMLToolingException::XMLToolingException(const char* msg, const namedparams& p) +{ + if (msg) + m_msg=msg; + addProperties(p); +} + +XMLToolingException::XMLToolingException(const std::string& msg, const params& p) : m_msg(msg) +{ + addProperties(p); +} + +XMLToolingException::XMLToolingException(const std::string& msg, const namedparams& p) : m_msg(msg) +{ + addProperties(p); +} + +void XMLToolingException::setMessage(const char* msg) +{ + if (msg) + m_msg=msg; + else + m_msg.erase(); + m_processedmsg.erase(); +} + +inline const char* get_digit_character() +{ + static const char s_characters[19] = + { + '9' + , '8' + , '7' + , '6' + , '5' + , '4' + , '3' + , '2' + , '1' + , '0' + , '1' + , '2' + , '3' + , '4' + , '5' + , '6' + , '7' + , '8' + , '9' + }; + static const char *s_mid = s_characters + 9; + + return s_mid; +} + +inline const char* unsigned_integer_to_string(char* buf, size_t cchBuf, int i) +{ + char* psz=buf + cchBuf - 1; // Set psz to last char + *psz = 0; // Set terminating null + + do { + unsigned int lsd = i % 10; // Get least significant + // digit + + i /= 10; // Prepare for next most + // significant digit + + --psz; // Move back + + *psz = get_digit_character()[lsd]; // Place the digit + + } while(i!=0 && psz>buf); + + return psz; +} + +void XMLToolingException::addProperties(const params& p) +{ + m_processedmsg.erase(); + int i=m_params.size()+1; + char buf[20]; + const vector& v=p.get(); + for (vector::const_iterator ci=v.begin(); ci!=v.end(); ci++) { + m_params[unsigned_integer_to_string(buf,sizeof(buf),i++)] = *ci; + } +} + +void XMLToolingException::addProperties(const namedparams& p) +{ + m_processedmsg.erase(); + const vector& v=p.get(); + for (vector::const_iterator ci=v.begin(); ci!=v.end(); ci++) { + m_params.erase(*ci); + m_params[*ci] = *(ci+1); + ci++; // advance past name to value, then loop will advance it again + } +} + +const char* XMLToolingException::getProperty(unsigned int index) const +{ + char buf[20]; + map::const_iterator i=m_params.find(unsigned_integer_to_string(buf,sizeof(buf),index)); + return (i==m_params.end()) ? NULL : i->second.c_str(); +} + +const char* XMLToolingException::getProperty(const char* name) const +{ + map::const_iterator i=m_params.find(name); + return (i==m_params.end()) ? NULL : i->second.c_str(); +} + +const char* XMLToolingException::getMessage() const +{ + if (!m_processedmsg.empty()) + return m_processedmsg.c_str(); + else if (m_params.empty()) + return m_msg.c_str(); + + static const char* legal="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_"; + + // Replace any parameters in the message. + string::size_type i=0,start=0; + while (start!=string::npos && startstart) + m_processedmsg += m_msg.substr(start,i-start); // append everything in between + start=i+1; // move start to the beginning of the token name + i=m_msg.find_first_not_of(legal,start); // find token delimiter + if (i==start) { // append a non legal character + m_processedmsg+=m_msg[start++]; + continue; + } + + // search for token in map + map::const_iterator param=m_params.find(m_msg.substr(start,(i==string::npos) ? i : i-start)); + if (param!=m_params.end()) { + m_processedmsg+=param->second; + start=i; + } + } + if (start!=string::npos && start&"); + if (pos > 0) { + s.append(start, pos); + start += pos; + } + else { + switch (*start) { + case '\'': s += "'"; break; + case '<': s += "<"; break; + case '>': s += ">"; break; + case '&': s += "&"; break; + default: s += *start; + } + start++; + } + } + s += post; +} + +string XMLToolingException::toString() const +{ + string xml=string(""; + const char* msg=getMessage(); + if (msg) + xml_encode(xml, "", msg, ""); + for (map::const_iterator i=m_params.begin(); i!=m_params.end(); i++) { + xml_encode(xml, "", i->second.c_str(), ""); + } + xml+=""; + return xml; +} + +string XMLToolingException::toQueryString() const +{ + string q; + const URLEncoder* enc = XMLToolingConfig::getConfig().getURLEncoder(); + for (map::const_iterator i=m_params.begin(); i!=m_params.end(); i++) { + if (!q.empty()) + q += '&'; + q = q + i->first + '=' + enc->encode(i->second.c_str()); + } + return q; +} + +XMLToolingException* XMLToolingException::fromStream(std::istream& in) +{ + static const XMLCh exception[] = UNICODE_LITERAL_9(e,x,c,e,p,t,i,o,n); + static const XMLCh message[] = UNICODE_LITERAL_7(m,e,s,s,a,g,e); + static const XMLCh name[] = UNICODE_LITERAL_4(n,a,m,e); + static const XMLCh param[] = UNICODE_LITERAL_5(p,a,r,a,m); + static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); + + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + + // Check root element. + const DOMElement* root=doc->getDocumentElement(); + if (!XMLHelper::isNodeNamed(root,XMLTOOLING_NS,exception)) { + doc->release(); + throw XMLToolingException("Invalid root element on serialized exception."); + } + + auto_ptr_char classname(root->getAttributeNS(NULL,type)); + auto_ptr excep(XMLToolingException::getInstance(classname.get())); + + DOMElement* child=XMLHelper::getFirstChildElement(root,XMLTOOLING_NS,message); + if (child && child->hasChildNodes()) { + auto_ptr_char m(child->getFirstChild()->getNodeValue()); + excep->setMessage(m.get()); + } + + child=XMLHelper::getFirstChildElement(root,XMLTOOLING_NS,param); + while (child && child->hasChildNodes()) { + auto_ptr_char n(child->getAttributeNS(NULL,name)); + char* v=toUTF8(child->getFirstChild()->getNodeValue()); + if (n.get() && v) + excep->addProperty(n.get(), v); + delete[] v; + child=XMLHelper::getNextSiblingElement(child,XMLTOOLING_NS,param); + } + + doc->release(); + return excep.release(); +} + +XMLToolingException* XMLToolingException::fromString(const char* s) +{ + istringstream in(s); + return fromStream(in); +} diff --git a/xmltooling/impl/MemoryStorageService.cpp b/xmltooling/impl/MemoryStorageService.cpp index af0fd71..b297d65 100644 --- a/xmltooling/impl/MemoryStorageService.cpp +++ b/xmltooling/impl/MemoryStorageService.cpp @@ -1,318 +1,319 @@ -/* - * Copyright 2001-2007 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * MemoryStorageService.cpp - * - * In-memory "persistent" storage, suitable for simple applications. - */ - -#include "internal.h" -#include "logging.h" -#include "util/NDC.h" -#include "util/StorageService.h" -#include "util/Threads.h" -#include "util/XMLHelper.h" - -#include - -using namespace xmltooling::logging; -using namespace xmltooling; -using namespace std; - -namespace xmltooling { - class XMLTOOL_DLLLOCAL MemoryStorageService : public StorageService - { - public: - MemoryStorageService(const DOMElement* e); - virtual ~MemoryStorageService(); - - bool createString(const char* context, const char* key, const char* value, time_t expiration); - int readString(const char* context, const char* key, string* pvalue=NULL, time_t* pexpiration=NULL, int version=0); - int updateString(const char* context, const char* key, const char* value=NULL, time_t expiration=0, int version=0); - bool deleteString(const char* context, const char* key); - - bool createText(const char* context, const char* key, const char* value, time_t expiration) { - return createString(context, key, value, expiration); - } - int readText(const char* context, const char* key, string* pvalue=NULL, time_t* pexpiration=NULL, int version=0) { - return readString(context, key, pvalue, pexpiration, version); - } - int updateText(const char* context, const char* key, const char* value=NULL, time_t expiration=0, int version=0) { - return updateString(context, key, value, expiration, version); - } - bool deleteText(const char* context, const char* key) { - return deleteString(context, key); - } - - void reap(const char* context); - void updateContext(const char* context, time_t expiration); - void deleteContext(const char* context) { - m_lock->wrlock(); - m_contextMap.erase(context); - m_lock->unlock(); - } - - private: - void cleanup(); - - struct XMLTOOL_DLLLOCAL Record { - Record() : expiration(0), version(1) {} - Record(const string& s, time_t t) : data(s), expiration(t), version(1) {} - string data; - time_t expiration; - int version; - }; - - struct XMLTOOL_DLLLOCAL Context { - Context() {} - Context(const Context& src) { - m_dataMap = src.m_dataMap; - } - map m_dataMap; - unsigned long reap(time_t exp); - }; - - Context& readContext(const char* context) { - m_lock->rdlock(); - map::iterator i = m_contextMap.find(context); - if (i != m_contextMap.end()) - return i->second; - m_lock->unlock(); - m_lock->wrlock(); - return m_contextMap[context]; - } - - Context& writeContext(const char* context) { - m_lock->wrlock(); - return m_contextMap[context]; - } - - map m_contextMap; - RWLock* m_lock; - CondWait* shutdown_wait; - Thread* cleanup_thread; - static void* cleanup_fn(void*); - bool shutdown; - int m_cleanupInterval; - Category& m_log; - }; - - StorageService* XMLTOOL_DLLLOCAL MemoryStorageServiceFactory(const DOMElement* const & e) - { - return new MemoryStorageService(e); - } -}; - -static const XMLCh cleanupInterval[] = UNICODE_LITERAL_15(c,l,e,a,n,u,p,I,n,t,e,r,v,a,l); - -MemoryStorageService::MemoryStorageService(const DOMElement* e) - : m_lock(NULL), shutdown_wait(NULL), cleanup_thread(NULL), shutdown(false), m_cleanupInterval(0), - m_log(Category::getInstance(XMLTOOLING_LOGCAT".StorageService")) -{ - const XMLCh* tag=e ? e->getAttributeNS(NULL,cleanupInterval) : NULL; - if (tag && *tag) { - m_cleanupInterval = XMLString::parseInt(tag); - } - if (!m_cleanupInterval) - m_cleanupInterval=900; - - m_lock = RWLock::create(); - shutdown_wait = CondWait::create(); - cleanup_thread = Thread::create(&cleanup_fn, (void*)this); -} - -MemoryStorageService::~MemoryStorageService() -{ - // Shut down the cleanup thread and let it know... - shutdown = true; - shutdown_wait->signal(); - cleanup_thread->join(NULL); - - delete shutdown_wait; - delete m_lock; -} - -void* MemoryStorageService::cleanup_fn(void* cache_p) -{ - MemoryStorageService* cache = reinterpret_cast(cache_p); - -#ifndef WIN32 - // First, let's block all signals - Thread::mask_all_signals(); -#endif - - // Now run the cleanup process. - cache->cleanup(); - return NULL; -} - -void MemoryStorageService::cleanup() -{ -#ifdef _DEBUG - NDC ndc("cleanup"); -#endif - - auto_ptr mutex(Mutex::create()); - mutex->lock(); - - m_log.info("cleanup thread started...running every %d seconds", m_cleanupInterval); - - while (!shutdown) { - shutdown_wait->timedwait(mutex.get(), m_cleanupInterval); - if (shutdown) - break; - - unsigned long count=0; - time_t now = time(NULL); - m_lock->wrlock(); - SharedLock locker(m_lock, false); - for (map::iterator i=m_contextMap.begin(); i!=m_contextMap.end(); ++i) - count += i->second.reap(now); - - if (count) - m_log.info("purged %d expired record(s) from storage", count); - } - - m_log.info("cleanup thread finished"); - - mutex->unlock(); - Thread::exit(NULL); -} - -void MemoryStorageService::reap(const char* context) -{ - Context& ctx = writeContext(context); - SharedLock locker(m_lock, false); - ctx.reap(time(NULL)); -} - -unsigned long MemoryStorageService::Context::reap(time_t exp) -{ - // Garbage collect any expired entries. - unsigned long count=0; - map::iterator cur = m_dataMap.begin(); - map::iterator stop = m_dataMap.end(); - while (cur != stop) { - if (cur->second.expiration <= exp) { - map::iterator tmp = cur++; - m_dataMap.erase(tmp); - ++count; - } - else { - cur++; - } - } - return count; -} - -bool MemoryStorageService::createString(const char* context, const char* key, const char* value, time_t expiration) -{ - Context& ctx = writeContext(context); - SharedLock locker(m_lock, false); - - // Check for a duplicate. - map::iterator i=ctx.m_dataMap.find(key); - if (i!=ctx.m_dataMap.end()) { - // Not yet expired? - if (time(NULL) < i->second.expiration) - return false; - // It's dead, so we can just remove it now and create the new record. - ctx.m_dataMap.erase(i); - } - - ctx.m_dataMap[key]=Record(value,expiration); - - m_log.debug("inserted record (%s) in context (%s)", key, context); - return true; -} - -int MemoryStorageService::readString(const char* context, const char* key, string* pvalue, time_t* pexpiration, int version) -{ - Context& ctx = readContext(context); - SharedLock locker(m_lock, false); - - map::iterator i=ctx.m_dataMap.find(key); - if (i==ctx.m_dataMap.end()) - return 0; - else if (time(NULL) >= i->second.expiration) - return 0; - if (pexpiration) - *pexpiration = i->second.expiration; - if (i->second.version == version) - return version; // nothing's changed, so just echo back the version - if (pvalue) - *pvalue = i->second.data; - return i->second.version; -} - -int MemoryStorageService::updateString(const char* context, const char* key, const char* value, time_t expiration, int version) -{ - Context& ctx = writeContext(context); - SharedLock locker(m_lock, false); - - map::iterator i=ctx.m_dataMap.find(key); - if (i==ctx.m_dataMap.end()) - return 0; - else if (time(NULL) >= i->second.expiration) - return 0; - - if (version > 0 && version != i->second.version) - return -1; // caller's out of sync - - if (value) { - i->second.data = value; - ++(i->second.version); - } - - if (expiration && expiration != i->second.expiration) - i->second.expiration = expiration; - - m_log.debug("updated record (%s) in context (%s)", key, context); - return i->second.version; -} - -bool MemoryStorageService::deleteString(const char* context, const char* key) -{ - Context& ctx = writeContext(context); - SharedLock locker(m_lock, false); - - // Find the record. - map::iterator i=ctx.m_dataMap.find(key); - if (i!=ctx.m_dataMap.end()) { - ctx.m_dataMap.erase(i); - m_log.debug("deleted record (%s) in context (%s)", key, context); - return true; - } - - m_log.debug("deleting record (%s) in context (%s)....not found", key, context); - return false; -} - -void MemoryStorageService::updateContext(const char* context, time_t expiration) -{ - Context& ctx = writeContext(context); - SharedLock locker(m_lock, false); - - time_t now = time(NULL); - map::iterator stop=ctx.m_dataMap.end(); - for (map::iterator i = ctx.m_dataMap.begin(); i!=stop; ++i) { - if (now < i->second.expiration) - i->second.expiration = expiration; - } - - m_log.debug("updated expiration of valid records in context (%s)", context); -} +/* + * Copyright 2001-2007 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * MemoryStorageService.cpp + * + * In-memory "persistent" storage, suitable for simple applications. + */ + +#include "internal.h" +#include "logging.h" +#include "util/NDC.h" +#include "util/StorageService.h" +#include "util/Threads.h" +#include "util/XMLHelper.h" + +#include +#include + +using namespace xmltooling::logging; +using namespace xmltooling; +using namespace std; + +namespace xmltooling { + class XMLTOOL_DLLLOCAL MemoryStorageService : public StorageService + { + public: + MemoryStorageService(const DOMElement* e); + virtual ~MemoryStorageService(); + + bool createString(const char* context, const char* key, const char* value, time_t expiration); + int readString(const char* context, const char* key, string* pvalue=NULL, time_t* pexpiration=NULL, int version=0); + int updateString(const char* context, const char* key, const char* value=NULL, time_t expiration=0, int version=0); + bool deleteString(const char* context, const char* key); + + bool createText(const char* context, const char* key, const char* value, time_t expiration) { + return createString(context, key, value, expiration); + } + int readText(const char* context, const char* key, string* pvalue=NULL, time_t* pexpiration=NULL, int version=0) { + return readString(context, key, pvalue, pexpiration, version); + } + int updateText(const char* context, const char* key, const char* value=NULL, time_t expiration=0, int version=0) { + return updateString(context, key, value, expiration, version); + } + bool deleteText(const char* context, const char* key) { + return deleteString(context, key); + } + + void reap(const char* context); + void updateContext(const char* context, time_t expiration); + void deleteContext(const char* context) { + m_lock->wrlock(); + m_contextMap.erase(context); + m_lock->unlock(); + } + + private: + void cleanup(); + + struct XMLTOOL_DLLLOCAL Record { + Record() : expiration(0), version(1) {} + Record(const string& s, time_t t) : data(s), expiration(t), version(1) {} + string data; + time_t expiration; + int version; + }; + + struct XMLTOOL_DLLLOCAL Context { + Context() {} + Context(const Context& src) { + m_dataMap = src.m_dataMap; + } + map m_dataMap; + unsigned long reap(time_t exp); + }; + + Context& readContext(const char* context) { + m_lock->rdlock(); + map::iterator i = m_contextMap.find(context); + if (i != m_contextMap.end()) + return i->second; + m_lock->unlock(); + m_lock->wrlock(); + return m_contextMap[context]; + } + + Context& writeContext(const char* context) { + m_lock->wrlock(); + return m_contextMap[context]; + } + + map m_contextMap; + RWLock* m_lock; + CondWait* shutdown_wait; + Thread* cleanup_thread; + static void* cleanup_fn(void*); + bool shutdown; + int m_cleanupInterval; + Category& m_log; + }; + + StorageService* XMLTOOL_DLLLOCAL MemoryStorageServiceFactory(const DOMElement* const & e) + { + return new MemoryStorageService(e); + } +}; + +static const XMLCh cleanupInterval[] = UNICODE_LITERAL_15(c,l,e,a,n,u,p,I,n,t,e,r,v,a,l); + +MemoryStorageService::MemoryStorageService(const DOMElement* e) + : m_lock(NULL), shutdown_wait(NULL), cleanup_thread(NULL), shutdown(false), m_cleanupInterval(0), + m_log(Category::getInstance(XMLTOOLING_LOGCAT".StorageService")) +{ + const XMLCh* tag=e ? e->getAttributeNS(NULL,cleanupInterval) : NULL; + if (tag && *tag) { + m_cleanupInterval = XMLString::parseInt(tag); + } + if (!m_cleanupInterval) + m_cleanupInterval=900; + + m_lock = RWLock::create(); + shutdown_wait = CondWait::create(); + cleanup_thread = Thread::create(&cleanup_fn, (void*)this); +} + +MemoryStorageService::~MemoryStorageService() +{ + // Shut down the cleanup thread and let it know... + shutdown = true; + shutdown_wait->signal(); + cleanup_thread->join(NULL); + + delete shutdown_wait; + delete m_lock; +} + +void* MemoryStorageService::cleanup_fn(void* cache_p) +{ + MemoryStorageService* cache = reinterpret_cast(cache_p); + +#ifndef WIN32 + // First, let's block all signals + Thread::mask_all_signals(); +#endif + + // Now run the cleanup process. + cache->cleanup(); + return NULL; +} + +void MemoryStorageService::cleanup() +{ +#ifdef _DEBUG + NDC ndc("cleanup"); +#endif + + auto_ptr mutex(Mutex::create()); + mutex->lock(); + + m_log.info("cleanup thread started...running every %d seconds", m_cleanupInterval); + + while (!shutdown) { + shutdown_wait->timedwait(mutex.get(), m_cleanupInterval); + if (shutdown) + break; + + unsigned long count=0; + time_t now = time(NULL); + m_lock->wrlock(); + SharedLock locker(m_lock, false); + for (map::iterator i=m_contextMap.begin(); i!=m_contextMap.end(); ++i) + count += i->second.reap(now); + + if (count) + m_log.info("purged %d expired record(s) from storage", count); + } + + m_log.info("cleanup thread finished"); + + mutex->unlock(); + Thread::exit(NULL); +} + +void MemoryStorageService::reap(const char* context) +{ + Context& ctx = writeContext(context); + SharedLock locker(m_lock, false); + ctx.reap(time(NULL)); +} + +unsigned long MemoryStorageService::Context::reap(time_t exp) +{ + // Garbage collect any expired entries. + unsigned long count=0; + map::iterator cur = m_dataMap.begin(); + map::iterator stop = m_dataMap.end(); + while (cur != stop) { + if (cur->second.expiration <= exp) { + map::iterator tmp = cur++; + m_dataMap.erase(tmp); + ++count; + } + else { + cur++; + } + } + return count; +} + +bool MemoryStorageService::createString(const char* context, const char* key, const char* value, time_t expiration) +{ + Context& ctx = writeContext(context); + SharedLock locker(m_lock, false); + + // Check for a duplicate. + map::iterator i=ctx.m_dataMap.find(key); + if (i!=ctx.m_dataMap.end()) { + // Not yet expired? + if (time(NULL) < i->second.expiration) + return false; + // It's dead, so we can just remove it now and create the new record. + ctx.m_dataMap.erase(i); + } + + ctx.m_dataMap[key]=Record(value,expiration); + + m_log.debug("inserted record (%s) in context (%s)", key, context); + return true; +} + +int MemoryStorageService::readString(const char* context, const char* key, string* pvalue, time_t* pexpiration, int version) +{ + Context& ctx = readContext(context); + SharedLock locker(m_lock, false); + + map::iterator i=ctx.m_dataMap.find(key); + if (i==ctx.m_dataMap.end()) + return 0; + else if (time(NULL) >= i->second.expiration) + return 0; + if (pexpiration) + *pexpiration = i->second.expiration; + if (i->second.version == version) + return version; // nothing's changed, so just echo back the version + if (pvalue) + *pvalue = i->second.data; + return i->second.version; +} + +int MemoryStorageService::updateString(const char* context, const char* key, const char* value, time_t expiration, int version) +{ + Context& ctx = writeContext(context); + SharedLock locker(m_lock, false); + + map::iterator i=ctx.m_dataMap.find(key); + if (i==ctx.m_dataMap.end()) + return 0; + else if (time(NULL) >= i->second.expiration) + return 0; + + if (version > 0 && version != i->second.version) + return -1; // caller's out of sync + + if (value) { + i->second.data = value; + ++(i->second.version); + } + + if (expiration && expiration != i->second.expiration) + i->second.expiration = expiration; + + m_log.debug("updated record (%s) in context (%s)", key, context); + return i->second.version; +} + +bool MemoryStorageService::deleteString(const char* context, const char* key) +{ + Context& ctx = writeContext(context); + SharedLock locker(m_lock, false); + + // Find the record. + map::iterator i=ctx.m_dataMap.find(key); + if (i!=ctx.m_dataMap.end()) { + ctx.m_dataMap.erase(i); + m_log.debug("deleted record (%s) in context (%s)", key, context); + return true; + } + + m_log.debug("deleting record (%s) in context (%s)....not found", key, context); + return false; +} + +void MemoryStorageService::updateContext(const char* context, time_t expiration) +{ + Context& ctx = writeContext(context); + SharedLock locker(m_lock, false); + + time_t now = time(NULL); + map::iterator stop=ctx.m_dataMap.end(); + for (map::iterator i = ctx.m_dataMap.begin(); i!=stop; ++i) { + if (now < i->second.expiration) + i->second.expiration = expiration; + } + + m_log.debug("updated expiration of valid records in context (%s)", context); +}