Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / io / AbstractXMLObjectUnmarshaller.h
index acab0d2..8f3ee27 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
- * @file AbstractXMLObjectUnmarshaller.h\r
- * \r
- * A thread-safe abstract unmarshaller.\r
- */\r
-\r
-#if !defined(__xmltooling_xmlunmarshaller_h__)\r
-#define __xmltooling_xmlunmarshaller_h__\r
-\r
-#include <xmltooling/io/Unmarshaller.h>\r
-\r
-namespace xmltooling {\r
-\r
-    /**\r
-     * A thread-safe abstract unmarshaller.\r
-     */\r
-    class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual Unmarshaller\r
-    {\r
-    public:\r
-        virtual ~AbstractXMLObjectUnmarshaller() {}\r
-\r
-        /**\r
-         * @see Unmarshaller::unmarshall()\r
-         */\r
-        XMLObject* unmarshall(DOMElement* element, bool bindDocument=false) const;\r
-            \r
-    protected:\r
-        /**\r
-         * Constructor.\r
-         * \r
-         * @param targetNamespaceURI the namespace URI of either the schema type QName or element QName of the elements this\r
-         *            unmarshaller operates on\r
-         * @param targetLocalName the local name of either the schema type QName or element QName of the elements this\r
-         *            unmarshaller operates on\r
-         */\r
-        AbstractXMLObjectUnmarshaller(const XMLCh* targetNamespaceURI, const XMLCh* targetLocalName);\r
-\r
-        /**\r
-         * Constructs the XMLObject that the given DOM Element will be unmarshalled into. If the DOM element has an XML\r
-         * Schema type defined this method will attempt to retrieve an XMLObjectBuilder using the schema type. If no\r
-         * schema type is present or no builder is registered for the schema type, the element's QName is used. Once\r
-         * the builder is found the XMLObject is created by invoking XMLObjectBuilder::buildObject().\r
-         * Extending classes may wish to override this logic if more than just schema type or element name\r
-         * (e.g. element attributes or content) need to be used to determine how to create the XMLObject.\r
-         * \r
-         * @param domElement the DOM Element the created XMLObject will represent\r
-         * @return the empty XMLObject that DOM Element can be unmarshalled into\r
-         * \r
-         * @throws UnmarshallingException thrown if there is now XMLObjectBuilder registered for the given DOM Element\r
-         */\r
-        virtual XMLObject* buildXMLObject(const DOMElement* domElement) const;\r
-        \r
-        /**\r
-         * Unmarshalls the attributes from the given DOM Element into the given XMLObject. If the attribute is an XML\r
-         * namespace declaration the namespace is added to the given element via XMLObject::addNamespace().\r
-         * If it is a schema type (xsi:type) the schema type is added to the element via XMLObject::setSchemaType().\r
-         * All other attributes are passed to the processAttribute hook.\r
-         * \r
-         * @param domElement the DOM Element whose attributes will be unmarshalled\r
-         * @param xmlObject the XMLObject that will recieve information from the DOM attribute\r
-         * \r
-         * @throws UnmarshallingException thrown if there is a problem unmarshalling an attribute\r
-         */\r
-        virtual void unmarshallAttributes(const DOMElement* domElement, XMLObject& xmlObject) const;\r
-\r
-        /**\r
-         * Unmarshalls a given Element's children. For each child an unmarshaller is retrieved using\r
-         * getUnmarshaller(). The unmarshaller is then used to unmarshall the child element and the\r
-         * resulting XMLObject is passed to processChildElement() for further processing.\r
-         * \r
-         * @param domElement the DOM Element whose children will be unmarshalled\r
-         * @param xmlObject the parent object of the unmarshalled children\r
-         * \r
-         * @throws UnmarshallingException thrown if an error occurs unmarshalling the child elements\r
-         */\r
-        virtual void unmarshallChildElements(const DOMElement* domElement, XMLObject& xmlObject) const;\r
-\r
-        /**\r
-         * Called after a child element has been unmarshalled so that it can be added to the parent XMLObject.\r
-         * \r
-         * @param parent the parent XMLObject\r
-         * @param child pointer to the child XMLObject\r
-         * \r
-         * @throws UnmarshallingException thrown if there is a problem adding the child to the parent\r
-         */\r
-        virtual void processChildElement(XMLObject& parent, XMLObject* child) const=0;\r
-    \r
-        /**\r
-         * Called after an attribute has been unmarshalled so that it can be added to the XMLObject.\r
-         * \r
-         * @param xmlObject the XMLObject\r
-         * @param attribute the attribute being unmarshalled\r
-         * \r
-         * @throws UnmarshallingException thrown if there is a problem adding the attribute to the XMLObject\r
-         */\r
-        virtual void processAttribute(XMLObject& xmlObject, const DOMAttr* attribute) const=0;\r
-    \r
-        /**\r
-         * Called if the element being unmarshalled contained textual content so that it can be added to the XMLObject.\r
-         * \r
-         * @param xmlObject XMLObject the content will be given to\r
-         * @param elementContent the Element's text content\r
-         */\r
-        virtual void processElementContent(XMLObject& xmlObject, const XMLCh* elementContent) const=0;\r
-\r
-        void* m_log;\r
-    private:\r
-        QName m_targetQName;\r
-    };\r
-    \r
-};\r
-\r
-#endif /* __xmltooling_xmlunmarshaller_h__ */\r
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you 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.
+ */
+
+/**
+ * @file xmltooling/io/AbstractXMLObjectUnmarshaller.h
+ * 
+ * A mix-in to implement object unmarshalling.
+ */
+
+#ifndef __xmltooling_xmlunmarshaller_h__
+#define __xmltooling_xmlunmarshaller_h__
+
+#include <xmltooling/AbstractDOMCachingXMLObject.h>
+
+#if defined (_MSC_VER)
+    #pragma warning( push )
+    #pragma warning( disable : 4250 4251 )
+#endif
+
+namespace xmltooling {
+
+    /**
+     * A mix-in to implement object unmarshalling.
+     */
+    class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual AbstractXMLObject
+    {
+    public:
+        virtual ~AbstractXMLObjectUnmarshaller();
+
+        XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false);
+            
+    protected:
+        AbstractXMLObjectUnmarshaller();
+
+        /**
+         * Unmarshalls the attributes from the given DOM Element into the XMLObject. If the attribute
+         * is an XML namespace declaration the namespace is added via XMLObject::addNamespace().
+         * If it is a schema type (xsi:type) the schema type is added via XMLObject::setSchemaType().
+         * All other attributes are passed to the processAttribute hook.
+         * 
+         * @param domElement the DOM Element whose attributes will be unmarshalled
+         * 
+         * @throws UnmarshallingException thrown if there is a problem unmarshalling an attribute
+         */
+        virtual void unmarshallAttributes(const xercesc::DOMElement* domElement);
+
+        /**
+         * Unmarshalls a given Element's child nodes. The resulting XMLObject children and content
+         * are passed to processChildElement() or processText() for further processing.
+         * 
+         * @param domElement the DOM Element whose children will be unmarshalled
+         * 
+         * @throws UnmarshallingException thrown if an error occurs unmarshalling the child elements
+         */
+        virtual void unmarshallContent(const xercesc::DOMElement* domElement);
+
+        /**
+         * Called after a child element has been unmarshalled so that it can be added to the parent XMLObject.
+         * 
+         * @param child     pointer to the child XMLObject
+         * @param childRoot root element of the child (must not be stored, just a hint)
+         * 
+         * @throws UnmarshallingException thrown if there is a problem adding the child to the parent
+         */
+        virtual void processChildElement(XMLObject* child, const xercesc::DOMElement* childRoot);
+    
+        /**
+         * Called after an attribute has been unmarshalled so that it can be added to the XMLObject.
+         * 
+         * @param attribute the attribute being unmarshalled
+         * 
+         * @throws UnmarshallingException thrown if there is a problem adding the attribute to the XMLObject
+         */
+        virtual void processAttribute(const xercesc::DOMAttr* attribute);
+    };
+    
+};
+
+#if defined (_MSC_VER)
+    #pragma warning( pop )
+#endif
+
+#endif /* __xmltooling_xmlunmarshaller_h__ */