0418beb0b58dd2eb487cb8c32aec8df592bf8815
[shibboleth/cpp-xmltooling.git] / xmltooling / impl / AnyElement.h
1 /*
2  *  Copyright 2001-2006 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 AnyElement.h
19  * 
20  * Advanced anyType implementation suitable for deep processing of unknown content.
21  */
22
23 #if !defined(__xmltooling_anyelement_h__)
24 #define __xmltooling_anyelement_h__
25
26 #include <xmltooling/AbstractAttributeExtensibleXMLObject.h>
27 #include <xmltooling/AbstractElementProxy.h>
28 #include <xmltooling/XMLObjectBuilder.h>
29 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
30 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.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      * Implements a smart wrapper around unknown or arbitrary DOM content.
41      */
42     class XMLTOOL_API AnyElementImpl : public AbstractDOMCachingXMLObject,
43         public AbstractElementProxy,
44         public AbstractAttributeExtensibleXMLObject,
45         public AbstractXMLObjectMarshaller,
46         public AbstractXMLObjectUnmarshaller
47     {
48     public:
49         virtual ~AnyElementImpl() {}
50
51         AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL)
52             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
53         
54         XMLObject* clone() const;
55         
56     protected:
57         AnyElementImpl() {}
58         AnyElementImpl(const AnyElementImpl& src);   
59         
60         void marshallAttributes(DOMElement* domElement) const;
61         void marshallElementContent(DOMElement* domElement) const;
62         void processChildElement(XMLObject* childXMLObject, const DOMElement* root);
63         void processAttribute(const DOMAttr* attribute);
64         void processElementContent(const XMLCh* elementContent);
65     };
66
67     /**
68      * Builder for AnyElementImpl objects.
69      * Use as the default builder when you want to wrap each unknown element and
70      * process the DOM content through xmltooling interfaces. 
71      */
72     class XMLTOOL_API AnyElementBuilder : public XMLObjectBuilder
73     {
74     public:
75         XMLObject* buildObject(
76             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL
77             ) const;
78     };
79
80 };
81
82 #if defined (_MSC_VER)
83     #pragma warning( pop )
84 #endif
85
86 #endif /* __xmltooling_anyelement_h__ */