gcc const fix, converted linefeeds
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractAttributeExtensibleXMLObject.cpp
index 3ebf6c5..a445248 100644 (file)
-/*\r
- *  Copyright 2001-2006 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
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * AbstractAttributeExtensibleXMLObject.cpp\r
- * \r
- * Extension of AbstractDOMCachingXMLObject that implements an AttributeExtensibleXMLObject. \r
- */\r
-\r
-#include "internal.h"\r
-#include "AbstractAttributeExtensibleXMLObject.h"\r
-\r
-#include <algorithm>\r
-#include <functional>\r
-\r
-using namespace xmltooling;\r
-using namespace std;\r
-\r
-set<QName> AttributeExtensibleXMLObject::m_idAttributeSet;\r
-\r
-AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject()\r
-{\r
-    for (map<QName,XMLCh*>::iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++)\r
-        XMLString::release(&(i->second));\r
-}\r
-\r
-AbstractAttributeExtensibleXMLObject::AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src)\r
-    : AbstractXMLObject(src)\r
-{\r
-    m_idAttribute = m_attributeMap.end();\r
-    for (map<QName,XMLCh*>::const_iterator i=src.m_attributeMap.begin(); i!=src.m_attributeMap.end(); i++) {\r
-        m_attributeMap[i->first] = XMLString::replicate(i->second);\r
-    }\r
-    if (src.m_idAttribute != src.m_attributeMap.end()) {\r
-        m_idAttribute = m_attributeMap.find(src.m_idAttribute->first);\r
-    }\r
-}\r
-\r
-void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID)\r
-{\r
-    map<QName,XMLCh*>::iterator i=m_attributeMap.find(qualifiedName);\r
-    if (i!=m_attributeMap.end()) {\r
-        releaseThisandParentDOM();\r
-        XMLString::release(&(i->second));\r
-        if (value) {\r
-            i->second=XMLString::replicate(value);\r
-        }\r
-        else {\r
-            if (m_idAttribute==i)\r
-                m_idAttribute=m_attributeMap.end();\r
-            m_attributeMap.erase(i);\r
-        }\r
-        \r
-        if (ID) {\r
-            m_idAttribute=i;\r
-        }\r
-    }\r
-    else if (value) {\r
-        releaseThisandParentDOM();\r
-        m_attributeMap[qualifiedName]=XMLString::replicate(value);\r
-        if (ID) {\r
-            m_idAttribute = m_attributeMap.find(qualifiedName);\r
-        } \r
-    }\r
-}\r
-\r
-void AbstractAttributeExtensibleXMLObject::unmarshallExtensionAttribute(const DOMAttr* attribute)\r
-{\r
-    QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix());\r
-    bool ID = isRegisteredIDAttribute(q); \r
-    setAttribute(q,attribute->getNodeValue(),ID);\r
-    if (ID) {\r
-        attribute->getOwnerElement()->setIdAttributeNode(attribute);\r
-    }\r
-}\r
-\r
-void AbstractAttributeExtensibleXMLObject::marshallExtensionAttributes(DOMElement* domElement) const\r
-{\r
-    for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {\r
-        DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());\r
-        if (i->first.hasPrefix())\r
-            attr->setPrefix(i->first.getPrefix());\r
-        attr->setNodeValue(i->second);\r
-        domElement->setAttributeNode(attr);\r
-        if (m_idAttribute==i)\r
-            domElement->setIdAttributeNode(attr);\r
-    }\r
-}\r
+/*
+ *  Copyright 2001-2006 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * AbstractAttributeExtensibleXMLObject.cpp
+ * 
+ * Extension of AbstractDOMCachingXMLObject that implements an AttributeExtensibleXMLObject. 
+ */
+
+#include "internal.h"
+#include "AbstractAttributeExtensibleXMLObject.h"
+
+#include <algorithm>
+#include <functional>
+
+using namespace xmltooling;
+using namespace std;
+
+set<QName> AttributeExtensibleXMLObject::m_idAttributeSet;
+
+AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject()
+{
+    for (map<QName,XMLCh*>::iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++)
+        XMLString::release(&(i->second));
+}
+
+AbstractAttributeExtensibleXMLObject::AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src)
+    : AbstractXMLObject(src)
+{
+    m_idAttribute = m_attributeMap.end();
+    for (map<QName,XMLCh*>::const_iterator i=src.m_attributeMap.begin(); i!=src.m_attributeMap.end(); i++) {
+        m_attributeMap[i->first] = XMLString::replicate(i->second);
+    }
+    if (src.m_idAttribute != src.m_attributeMap.end()) {
+        m_idAttribute = m_attributeMap.find(src.m_idAttribute->first);
+    }
+}
+
+void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID)
+{
+    map<QName,XMLCh*>::iterator i=m_attributeMap.find(qualifiedName);
+    if (i!=m_attributeMap.end()) {
+        releaseThisandParentDOM();
+        XMLString::release(&(i->second));
+        if (value) {
+            i->second=XMLString::replicate(value);
+        }
+        else {
+            if (m_idAttribute==i)
+                m_idAttribute=m_attributeMap.end();
+            m_attributeMap.erase(i);
+        }
+        
+        if (ID) {
+            m_idAttribute=i;
+        }
+    }
+    else if (value) {
+        releaseThisandParentDOM();
+        m_attributeMap[qualifiedName]=XMLString::replicate(value);
+        if (ID) {
+            m_idAttribute = m_attributeMap.find(qualifiedName);
+        } 
+    }
+}
+
+void AbstractAttributeExtensibleXMLObject::unmarshallExtensionAttribute(const DOMAttr* attribute)
+{
+    QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix());
+    bool ID = isRegisteredIDAttribute(q); 
+    setAttribute(q,attribute->getNodeValue(),ID);
+    if (ID) {
+        attribute->getOwnerElement()->setIdAttributeNode(attribute);
+    }
+}
+
+void AbstractAttributeExtensibleXMLObject::marshallExtensionAttributes(DOMElement* domElement) const
+{
+    for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
+        DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
+        if (i->first.hasPrefix())
+            attr->setPrefix(i->first.getPrefix());
+        attr->setNodeValue(i->second);
+        domElement->setAttributeNode(attr);
+        if (m_idAttribute==i)
+            domElement->setIdAttributeNode(attr);
+    }
+}