Attempt to handle xmlsec versions where xsecsize_t doesn't exist.
[shibboleth/cpp-xmltooling.git] / xmltooling / base.h
index 77754ff..2956172 100644 (file)
@@ -26,6 +26,9 @@
 \r
 #include <typeinfo>\r
 \r
+/* Required for sprintf, used by integer XML attribute macros. */\r
+#include <cstdio>\r
+\r
 #if defined (_MSC_VER) || defined(__BORLANDC__)\r
   #include <xmltooling/config_pub_win32.h>\r
 #else\r
 # define XMLTOOLING_NO_XMLSEC 1\r
 #endif\r
 \r
+#if defined(XMLTOOLING_NO_XMLSEC) || !defined(HAVE_XSECSIZE_T)\r
+# ifdef XMLTOOLING_XERCESC_64BITSAFE\r
+#   include <xercesc/util/XercesDefs.hpp>\r
+    typedef XMLSize_t xsecsize_t;\r
+# else\r
+    typedef unsigned int xsecsize_t;\r
+# endif\r
+#endif\r
+\r
 // Windows and GCC4 Symbol Visibility Macros\r
 #ifdef WIN32\r
   #define XMLTOOL_IMPORT __declspec(dllimport)\r
         void set##proper(const DateTime* proper) { \\r
             m_##proper = prepareForAssignment(m_##proper,proper); \\r
             if (m_##proper) \\r
-                m_##proper##Epoch=m_##proper->getEpoch(); \\r
+                m_##proper##Epoch=m_##proper->getEpoch(duration); \\r
         } \\r
         void set##proper(time_t proper) { \\r
             m_##proper = prepareForAssignment(m_##proper,proper,duration); \\r
         void set##proper(const XMLCh* proper) { \\r
             m_##proper = prepareForAssignment(m_##proper,proper,duration); \\r
             if (m_##proper) \\r
-                m_##proper##Epoch=m_##proper->getEpoch(); \\r
+                m_##proper##Epoch=m_##proper->getEpoch(duration); \\r
         }\r
 \r
 /**\r
         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \\r
     }\r
 \r
+#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE\r
+/**\r
+ * Implements marshalling for an ID attribute\r
+ *\r
+ * @param proper        the proper name of the attribute\r
+ * @param ucase         the upcased name of the attribute\r
+ * @param namespaceURI  the XML namespace of the attribute\r
+ */\r
+# define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \\r
+    if (m_##proper && *m_##proper) { \\r
+        domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \\r
+        domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, true); \\r
+    }\r
+#else\r
 /**\r
  * Implements marshalling for an ID attribute\r
  *\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
  */\r
-#define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \\r
+# define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \\r
     if (m_##proper && *m_##proper) { \\r
         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \\r
         domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \\r
     }\r
+#endif\r
 \r
 /**\r
  * Implements unmarshalling process branch for a string attribute\r
         return; \\r
     }\r
 \r
+#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE\r
+/**\r
+ * Implements unmarshalling process branch for an ID attribute\r
+ *\r
+ * @param proper        the proper name of the attribute\r
+ * @param ucase         the upcased name of the attribute\r
+ * @param namespaceURI  the XML namespace of the attribute\r
+ */\r
+# define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \\r
+    if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \\r
+        set##proper(attribute->getValue()); \\r
+        attribute->getOwnerElement()->setIdAttributeNode(attribute, true); \\r
+        return; \\r
+    }\r
+#else\r
 /**\r
  * Implements unmarshalling process branch for an ID attribute\r
  *\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
  */\r
-#define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \\r
+# define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \\r
     if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \\r
         set##proper(attribute->getValue()); \\r
         attribute->getOwnerElement()->setIdAttributeNode(attribute); \\r
         return; \\r
     }\r
+#endif\r
 \r
 /**\r
  * Implements unmarshalling process branch for a DateTime attribute\r
     { \\r
     public: \\r
         virtual ~cname##Impl() {} \\r
-        cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \\r
+        cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) \\r
             : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \\r
         } \\r
         cname##Impl(const cname##Impl& src) \\r
  */\r
 #define IMPL_XMLOBJECTBUILDER(cname) \\r
     cname* cname##Builder::buildObject( \\r
-        const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \\r
+        const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType \\r
         ) const \\r
     { \\r
         return new cname##Impl(nsURI,localName,prefix,schemaType); \\r
  */\r
 #define IMPL_XMLOBJECTBUILDER(cname) \\r
     xmltooling::XMLObject* cname##Builder::buildObject( \\r
-        const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \\r
+        const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::Name* schemaType \\r
         ) const \\r
     { \\r
         return new cname##Impl(nsURI,localName,prefix,schemaType); \\r