Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / impl / AnyElement.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file xmltooling/impl/AnyElement.h
23  * 
24  * Advanced anyType implementation suitable for deep processing of unknown content.
25  */
26
27 #ifndef __xmltooling_anyelement_h__
28 #define __xmltooling_anyelement_h__
29
30 #include <xmltooling/ElementProxy.h>
31 #include <xmltooling/AbstractAttributeExtensibleXMLObject.h>
32 #include <xmltooling/AbstractComplexElement.h>
33 #include <xmltooling/XMLObjectBuilder.h>
34 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
35 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
36
37 #if defined (_MSC_VER)
38     #pragma warning( push )
39     #pragma warning( disable : 4250 4251 )
40 #endif
41
42 namespace xmltooling {
43
44     /**
45      * Implements a smart wrapper around unknown or arbitrary DOM content.
46      */
47     class XMLTOOL_API AnyElementImpl : public virtual ElementProxy,
48         public AbstractDOMCachingXMLObject,
49         public AbstractComplexElement,
50         public AbstractAttributeExtensibleXMLObject,
51         public AbstractXMLObjectMarshaller,
52         public AbstractXMLObjectUnmarshaller
53     {
54     /// @cond OFF
55     public:
56         virtual ~AnyElementImpl();
57
58         AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const QName* schemaType=nullptr);
59         
60         XMLObject* clone() const;
61         
62     protected:
63         AnyElementImpl();
64         AnyElementImpl(const AnyElementImpl& src);
65         
66         IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
67         
68         void marshallAttributes(xercesc::DOMElement* domElement) const;
69         void processChildElement(XMLObject* childXMLObject, const xercesc::DOMElement* childRoot);
70         void processAttribute(const xercesc::DOMAttr* attribute);
71     };
72     /// @endcond
73
74     /**
75      * Builder for AnyElementImpl objects.
76      * Use as the default builder when you want to wrap each unknown element and
77      * process the DOM content through xmltooling interfaces. 
78      */
79     class XMLTOOL_API AnyElementBuilder : public XMLObjectBuilder
80     {
81     public:
82         XMLObject* buildObject(
83             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const QName* schemaType=nullptr
84             ) const;
85     };
86
87 };
88
89 #if defined (_MSC_VER)
90     #pragma warning( pop )
91 #endif
92
93 #endif /* __xmltooling_anyelement_h__ */