Reducing header overuse, non-inlining selected methods (CPPOST-35).
[shibboleth/cpp-xmltooling.git] / xmltooling / impl / UnknownElement.cpp
index b1bc80f..9f68476 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright 2001-2007 Internet2
+*  Copyright 2001-2009 Internet2
  * 
 * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
 /**
  * UnknownElement.cpp
  * 
- * Basic implementation suitable for use as default for unrecognized content
+ * Basic implementation suitable for use as default for unrecognized content.
  */
 
 #include "internal.h"
@@ -39,6 +39,15 @@ using namespace std;
 using xmlsignature::Signature;
 #endif
 
+UnknownElementImpl::UnknownElementImpl(const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix)
+    : AbstractXMLObject(namespaceURI, elementLocalName, namespacePrefix)
+{
+}
+
+UnknownElementImpl::~UnknownElementImpl()
+{
+}
+
 void UnknownElementImpl::releaseDOM() const
 {
 #ifdef _DEBUG
@@ -68,6 +77,25 @@ XMLObject* UnknownElementImpl::clone() const
     return ret;
 }
 
+const XMLCh* UnknownElementImpl::getTextContent(unsigned int position) const
+{
+    throw XMLObjectException("Direct access to content is not permitted.");
+}
+
+void UnknownElementImpl::setTextContent(const XMLCh*, unsigned int position)
+{
+    throw XMLObjectException("Direct access to content is not permitted.");
+}
+
+void UnknownElementImpl::setDocumentElement(DOMDocument* document, DOMElement* element) const
+{
+    DOMElement* documentRoot = document->getDocumentElement();
+    if (documentRoot)
+        document->replaceChild(element, documentRoot);
+    else
+        document->appendChild(element);
+}
+
 void UnknownElementImpl::serialize(string& s) const
 {
     if (getDOM())
@@ -206,7 +234,8 @@ XMLObject* UnknownElementImpl::unmarshall(DOMElement* element, bool bindDocument
 
 XMLObject* UnknownElementBuilder::buildObject(
     const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType
-    ) const {
+    ) const
+{
     return new UnknownElementImpl(nsURI,localName,prefix);
 }