https://issues.shibboleth.net/jira/browse/CPPXT-18
[shibboleth/cpp-xmltooling.git] / xmltooling / base.h
index 05128dd..85f2f54 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- *  Copyright 2001-2007 Internet2\r
+ *  Copyright 2001-2008 Internet2\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -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
         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
         }\r
 \r
 /**\r
+ * Implements get/set methods and a private member for a typed, qualified XML attribute.\r
+ *\r
+ * @param proper    the proper name of the attribute\r
+ * @param type      the attribute's data type\r
+ */\r
+#define IMPL_XMLOBJECT_FOREIGN_ATTRIB(proper,type) \\r
+    protected: \\r
+    XMLCh* m_##proper##Prefix; \\r
+        type* m_##proper; \\r
+    public: \\r
+        const type* get##proper() const { \\r
+            return m_##proper; \\r
+        } \\r
+        void set##proper(const type* proper) { \\r
+            m_##proper = prepareForAssignment(m_##proper,proper); \\r
+            XMLString::release(&m_##proper##Prefix); \\r
+            m_##proper##Prefix = NULL; \\r
+        }\r
+\r
+/**\r
  * Declares abstract set method for a typed XML child object in a foreign namespace.\r
  * The get method is omitted.\r
  *\r