Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / io / AbstractXMLObjectUnmarshaller.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file xmltooling/io/AbstractXMLObjectUnmarshaller.h
23  * 
24  * A mix-in to implement object unmarshalling.
25  */
26
27 #ifndef __xmltooling_xmlunmarshaller_h__
28 #define __xmltooling_xmlunmarshaller_h__
29
30 #include <xmltooling/AbstractDOMCachingXMLObject.h>
31
32 #if defined (_MSC_VER)
33     #pragma warning( push )
34     #pragma warning( disable : 4250 4251 )
35 #endif
36
37 namespace xmltooling {
38
39     /**
40      * A mix-in to implement object unmarshalling.
41      */
42     class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual AbstractXMLObject
43     {
44     public:
45         virtual ~AbstractXMLObjectUnmarshaller();
46
47         XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false);
48             
49     protected:
50         AbstractXMLObjectUnmarshaller();
51
52         /**
53          * Unmarshalls the attributes from the given DOM Element into the XMLObject. If the attribute
54          * is an XML namespace declaration the namespace is added via XMLObject::addNamespace().
55          * If it is a schema type (xsi:type) the schema type is added via XMLObject::setSchemaType().
56          * All other attributes are passed to the processAttribute hook.
57          * 
58          * @param domElement the DOM Element whose attributes will be unmarshalled
59          * 
60          * @throws UnmarshallingException thrown if there is a problem unmarshalling an attribute
61          */
62         virtual void unmarshallAttributes(const xercesc::DOMElement* domElement);
63
64         /**
65          * Unmarshalls a given Element's child nodes. The resulting XMLObject children and content
66          * are passed to processChildElement() or processText() for further processing.
67          * 
68          * @param domElement the DOM Element whose children will be unmarshalled
69          * 
70          * @throws UnmarshallingException thrown if an error occurs unmarshalling the child elements
71          */
72         virtual void unmarshallContent(const xercesc::DOMElement* domElement);
73
74         /**
75          * Called after a child element has been unmarshalled so that it can be added to the parent XMLObject.
76          * 
77          * @param child     pointer to the child XMLObject
78          * @param childRoot root element of the child (must not be stored, just a hint)
79          * 
80          * @throws UnmarshallingException thrown if there is a problem adding the child to the parent
81          */
82         virtual void processChildElement(XMLObject* child, const xercesc::DOMElement* childRoot);
83     
84         /**
85          * Called after an attribute has been unmarshalled so that it can be added to the XMLObject.
86          * 
87          * @param attribute the attribute being unmarshalled
88          * 
89          * @throws UnmarshallingException thrown if there is a problem adding the attribute to the XMLObject
90          */
91         virtual void processAttribute(const xercesc::DOMAttr* attribute);
92     };
93     
94 };
95
96 #if defined (_MSC_VER)
97     #pragma warning( pop )
98 #endif
99
100 #endif /* __xmltooling_xmlunmarshaller_h__ */