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