https://issues.shibboleth.net/jira/browse/CPPOST-70
[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         /**
67          * Copies the content of a source object into a newly constructed instance.
68          * <p>Used to solve compiler problems that limit calling virtual functions
69          * from the actual copy constructor.
70          *
71          * @param src source to clone
72          */
73         void _clone(const AnyElementImpl& src);
74
75         IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
76         
77         void marshallAttributes(xercesc::DOMElement* domElement) const;
78         void processChildElement(XMLObject* childXMLObject, const xercesc::DOMElement* childRoot);
79         void processAttribute(const xercesc::DOMAttr* attribute);
80     };
81     /// @endcond
82
83     /**
84      * Builder for AnyElementImpl objects.
85      * Use as the default builder when you want to wrap each unknown element and
86      * process the DOM content through xmltooling interfaces. 
87      */
88     class XMLTOOL_API AnyElementBuilder : public XMLObjectBuilder
89     {
90     public:
91         XMLObject* buildObject(
92             const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const QName* schemaType=nullptr
93             ) const;
94     };
95
96 };
97
98 #if defined (_MSC_VER)
99     #pragma warning( pop )
100 #endif
101
102 #endif /* __xmltooling_anyelement_h__ */