Reducing header overuse, non-inlining selected methods (CPPOST-35).
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractXMLObject.cpp
index 1a51a44..491aaa8 100644 (file)
  */
 
 #include "internal.h"
-#include "AbstractXMLObject.h"
 #include "exceptions.h"
+#include "AbstractXMLObject.h"
+#include "util/DateTime.h"
 
 #include <algorithm>
 
 using namespace xmltooling;
+using std::set;
 
 using xercesc::XMLString;
 
+XMLObject::XMLObject()
+{
+}
+
+XMLObject::~XMLObject()
+{
+}
+
+void XMLObject::releaseThisandParentDOM() const
+{
+    if (getDOM()) {
+        releaseDOM();
+        releaseParentDOM(true);
+    }
+}
+
+void XMLObject::releaseThisAndChildrenDOM() const
+{
+    if (getDOM()) {
+        releaseChildrenDOM(true);
+        releaseDOM();
+    }
+}
+
 AbstractXMLObject::AbstractXMLObject(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
     : m_log(logging::Category::getInstance(XMLTOOLING_LOGCAT".XMLObject")),
        m_schemaLocation(NULL), m_noNamespaceSchemaLocation(NULL), m_nil(xmlconstants::XML_BOOL_NULL),
@@ -58,6 +84,29 @@ AbstractXMLObject::~AbstractXMLObject()
     xercesc::XMLString::release(&m_noNamespaceSchemaLocation);
 }
 
+void AbstractXMLObject::detach()
+{
+    if (!getParent())
+        return;
+    else if (getParent()->hasParent())
+        throw XMLObjectException("Cannot detach an object whose parent is itself a child.");
+
+    // Pull ourselves out of the parent and then blast him.
+    getParent()->removeChild(this);
+    delete m_parent;
+    m_parent = NULL;
+}
+
+const QName& AbstractXMLObject::getElementQName() const
+{
+    return m_elementQname;
+}
+
+const set<Namespace>& AbstractXMLObject::getNamespaces() const
+{
+    return m_namespaces;
+}
+
 void XMLObject::setNil(const XMLCh* value)
 {
     if (value) {
@@ -92,6 +141,49 @@ void AbstractXMLObject::addNamespace(const Namespace& ns) const
         const_cast<Namespace&>(*i).setAlwaysDeclare(true);
 }
 
+void AbstractXMLObject::removeNamespace(const Namespace& ns)
+{
+    m_namespaces.erase(ns);
+}
+
+const QName* AbstractXMLObject::getSchemaType() const
+{
+    return m_typeQname;
+}
+
+const XMLCh* AbstractXMLObject::getXMLID() const
+{
+    return NULL;
+}
+
+xmlconstants::xmltooling_bool_t AbstractXMLObject::getNil() const
+{
+    return m_nil;
+}
+
+void AbstractXMLObject::nil(xmlconstants::xmltooling_bool_t value)
+{
+    if (m_nil != value) {
+        releaseThisandParentDOM();
+        m_nil = value;
+    }
+}
+
+bool AbstractXMLObject::hasParent() const
+{
+    return m_parent != NULL;
+}
+
+XMLObject* AbstractXMLObject::getParent() const
+{
+    return m_parent;
+}
+
+void AbstractXMLObject::setParent(XMLObject* parent)
+{
+    m_parent = parent;
+}
+
 XMLCh* AbstractXMLObject::prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue)
 {
     if (!XMLString::equals(oldValue,newValue)) {
@@ -186,16 +278,3 @@ XMLObject* AbstractXMLObject::prepareForAssignment(XMLObject* oldValue, XMLObjec
 
     return newValue;
 }
-
-void AbstractXMLObject::detach()
-{
-    if (!getParent())
-        return;
-    else if (getParent()->hasParent())
-        throw XMLObjectException("Cannot detach an object whose parent is itself a child.");
-
-    // Pull ourselves out of the parent and then blast him.
-    getParent()->removeChild(this);
-    delete m_parent;
-    m_parent = NULL;
-}