Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / impl / UnknownElement.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/UnknownElement.h
23  * 
24  * Basic implementation suitable for use as default for unrecognized content.
25  */
26
27 #ifndef __xmltooling_unkelement_h__
28 #define __xmltooling_unkelement_h__
29
30 #include <xmltooling/AbstractSimpleElement.h>
31 #include <xmltooling/exceptions.h>
32 #include <xmltooling/XMLObjectBuilder.h>
33 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
34 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
35
36 #include <string>
37
38 #if defined (_MSC_VER)
39     #pragma warning( push )
40     #pragma warning( disable : 4250 4251 )
41 #endif
42
43 namespace xmltooling {
44
45     /// @cond off
46     class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractSimpleElement, public AbstractDOMCachingXMLObject
47     {
48     public:
49         UnknownElementImpl(const XMLCh* namespaceURI=nullptr, const XMLCh* elementLocalName=nullptr, const XMLCh* namespacePrefix=nullptr);
50     
51         virtual ~UnknownElementImpl();
52
53         void releaseDOM() const;
54         XMLObject* clone() const;
55         const XMLCh* getTextContent(unsigned int position=0) const;
56         void setTextContent(const XMLCh*, unsigned int position=0);
57
58         xercesc::DOMElement* marshall(
59             xercesc::DOMDocument* document=nullptr
60 #ifndef XMLTOOLING_NO_XMLSEC
61             ,const std::vector<xmlsignature::Signature*>* sigs=nullptr
62             ,const Credential* credential=nullptr
63 #endif
64             ) const;
65
66         xercesc::DOMElement* marshall(
67             xercesc::DOMElement* parentElement
68 #ifndef XMLTOOLING_NO_XMLSEC
69             ,const std::vector<xmlsignature::Signature*>* sigs=nullptr
70             ,const Credential* credential=nullptr
71 #endif
72             ) const;
73         XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false);
74         
75     protected:
76         void setDocumentElement(xercesc::DOMDocument* document, xercesc::DOMElement* element) const;
77
78         mutable std::string m_xml;
79
80         void serialize(std::string& s) const;
81     };
82     /// @endcond
83     
84     /**
85      * Builder for UnknownElementImpl objects.
86      * Use as the default builder when you want unknown DOM content treated as raw/ignored XML.
87      */
88     class XMLTOOL_API UnknownElementBuilder : 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_unkelement_h__ */