0dc1c786b6ebdc4b1043a15abf3dca32cbf7546a
[shibboleth/cpp-xmltooling.git] / xmltooling / impl / AnyElement.h
1 /*
2  *  Copyright 2001-2010 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=nullptr, const QName* schemaType=nullptr);
55         
56         XMLObject* clone() const;
57         
58     protected:
59         AnyElementImpl();
60         AnyElementImpl(const AnyElementImpl& src);
61         
62         IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
63         
64         void marshallAttributes(xercesc::DOMElement* domElement) const;
65         void processChildElement(XMLObject* childXMLObject, const xercesc::DOMElement* childRoot);
66         void processAttribute(const xercesc::DOMAttr* attribute);
67     };
68     /// @endcond
69
70     /**
71      * Builder for AnyElementImpl objects.
72      * Use as the default builder when you want to wrap each unknown element and
73      * process the DOM content through xmltooling interfaces. 
74      */
75     class XMLTOOL_API AnyElementBuilder : public XMLObjectBuilder
76     {
77     public:
78         XMLObject* buildObject(
79             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const QName* schemaType=nullptr
80             ) const;
81     };
82
83 };
84
85 #if defined (_MSC_VER)
86     #pragma warning( pop )
87 #endif
88
89 #endif /* __xmltooling_anyelement_h__ */