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