Tagging 1.1 release.
[shibboleth/xmltooling.git] / xmltooling / AbstractXMLObject.h
index 7767167..fc4c23b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *  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
@@ -16,7 +16,7 @@
 
 /**
  * @file xmltooling/AbstractXMLObject.h
- * 
+ *
  * An abstract implementation of XMLObject.
  */
 
@@ -44,11 +44,7 @@ namespace xmltooling {
     class XMLTOOL_API AbstractXMLObject : public virtual XMLObject
     {
     public:
-        virtual ~AbstractXMLObject() {
-            delete m_typeQname;
-            xercesc::XMLString::release(&m_schemaLocation);
-            xercesc::XMLString::release(&m_noNamespaceSchemaLocation);
-        }
+        virtual ~AbstractXMLObject();
 
         void detach();
 
@@ -59,7 +55,7 @@ namespace xmltooling {
         const std::set<Namespace>& getNamespaces() const {
             return m_namespaces;
         }
-    
+
         void addNamespace(const Namespace& ns) const {
             std::set<Namespace>::iterator i = m_namespaces.find(ns);
             if (i == m_namespaces.end())
@@ -67,23 +63,23 @@ namespace xmltooling {
             else if (ns.alwaysDeclare())
                 const_cast<Namespace&>(*i).setAlwaysDeclare(true);
         }
-    
+
         void removeNamespace(const Namespace& ns) {
             m_namespaces.erase(ns);
         }
-        
+
         const QName* getSchemaType() const {
             return m_typeQname;
         }
-        
+
         const XMLCh* getXMLID() const {
             return NULL;
         }
-        
+
         xmlconstants::xmltooling_bool_t getNil() const {
                return m_nil;
         }
-        
+
         void nil(xmlconstants::xmltooling_bool_t value) {
             if (m_nil != value) {
                releaseThisandParentDOM();
@@ -94,11 +90,11 @@ namespace xmltooling {
         bool hasParent() const {
             return m_parent != NULL;
         }
-     
+
         XMLObject* getParent() const {
             return m_parent;
         }
-    
+
         void setParent(XMLObject* parent) {
             m_parent = parent;
         }
@@ -106,7 +102,7 @@ namespace xmltooling {
      protected:
         /**
          * Constructor
-         * 
+         *
          * @param nsURI         the namespace of the element
          * @param localName     the local name of the XML element this Object represents
          * @param prefix        the namespace prefix to use
@@ -118,17 +114,17 @@ namespace xmltooling {
 
         /** Copy constructor. */
         AbstractXMLObject(const AbstractXMLObject& src);
-        
+
         /**
          * A helper function for derived classes, for assignment of strings.
          *
          * This 'normalizes' newString, and then if it is different from oldString,
          * it invalidates the DOM, frees the old string, and returns the new.
          * If not different, it frees the new string and just returns the old value.
-         * 
-         * @param oldValue the current value
-         * @param newValue the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value
+         *
          * @return the value that should be assigned
          */
         XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue);
@@ -137,10 +133,10 @@ namespace xmltooling {
          * A helper function for derived classes, for assignment of date/time data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue the current value
-         * @param newValue the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value
+         *
          * @return the value that should be assigned
          */
         DateTime* prepareForAssignment(DateTime* oldValue, const DateTime* newValue);
@@ -149,50 +145,52 @@ namespace xmltooling {
          * A helper function for derived classes, for assignment of date/time data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue - the current value
-         * @param newValue - the epoch to assign as the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the epoch to assign as the new value
+         * @param duration true iff the value is a duration rather than an absolute timestamp
+         *
          * @return the value that should be assigned
          */
-        DateTime* prepareForAssignment(DateTime* oldValue, time_t newValue);
+        DateTime* prepareForAssignment(DateTime* oldValue, time_t newValue, bool duration=false);
 
         /**
          * A helper function for derived classes, for assignment of date/time data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue - the current value
-         * @param newValue - the new value in string form
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value in string form
+         * @param duration true iff the value is a duration rather than an absolute timestamp
+         *
          * @return the value that should be assigned
          */
-        DateTime* prepareForAssignment(DateTime* oldValue, const XMLCh* newValue);
+        DateTime* prepareForAssignment(DateTime* oldValue, const XMLCh* newValue, bool duration=false);
 
         /**
          * A helper function for derived classes, for assignment of QName data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue the current value
-         * @param newValue the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value
+         *
          * @return the value that should be assigned
          */
         QName* prepareForAssignment(QName* oldValue, const QName* newValue);
 
         /**
          * A helper function for derived classes, for assignment of (singleton) XML objects.
-         * 
-         * It is indifferent to whether either the old or the new version of the value is null. 
+         *
+         * It is indifferent to whether either the old or the new version of the value is null.
          * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate.
          * Note that since the new value (even if NULL) is always returned, it may be more efficient
          * to discard the return value and just assign independently if a dynamic cast would be involved.
-         * 
-         * @param oldValue current value
-         * @param newValue proposed new value
-         * @return the new value 
-         * 
+         *
+         * @param oldValue current value
+         * @param newValue proposed new value
+         * @return the new value
+         *
          * @throws XMLObjectException if the new child already has a parent.
          */
         XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);
@@ -216,7 +214,7 @@ namespace xmltooling {
          * Stores off xsi:noNamespaceSchemaLocation attribute.
          */
         XMLCh* m_noNamespaceSchemaLocation;
-        
+
         /**
          * Stores off xsi:nil attribute.
          */