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