X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fimpl%2FUnknownElement.h;h=aa4cd3194c9364b717acb4448a3d07d1fc1b1897;hb=5cb314df178f78c6fa7b9826c2c5a5298ec7a473;hp=701bb8fa40e51c1be78945959f4d5cbb38ce1664;hpb=c47d9a28b514e071b6fbb1dfce4b5f258d26a67f;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/impl/UnknownElement.h b/xmltooling/impl/UnknownElement.h index 701bb8f..aa4cd31 100644 --- a/xmltooling/impl/UnknownElement.h +++ b/xmltooling/impl/UnknownElement.h @@ -1,91 +1,108 @@ -/* -* Copyright 2001-2006 Internet2 - * -* Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file UnknownElement.h - * - * Basic implementation suitable for use as default for unrecognized content - */ - -#if !defined(__xmltooling_unkelement_h__) -#define __xmltooling_unkelement_h__ - -#include -#include -#include -#include -#include - -#include - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - -namespace xmltooling { - - /// @cond off - class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractChildlessElement, public AbstractDOMCachingXMLObject - { - public: - UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL) - : AbstractXMLObject(namespaceURI, elementLocalName, namespacePrefix) {} - - void releaseDOM(); - - XMLObject* clone() const; - - DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const; - DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const; - XMLObject* unmarshall(DOMElement* element, bool bindDocument=false); - - protected: - void setDocumentElement(DOMDocument* document, DOMElement* element) const { - DOMElement* documentRoot = document->getDocumentElement(); - if (documentRoot) - document->replaceChild(documentRoot, element); - else - document->appendChild(element); - } - - mutable std::string m_xml; - - void serialize(std::string& s) const; - }; - /// @endcond - - /** - * Builder for UnknownElementImpl objects. - * Use as the default builder when you want unknown DOM content treated as raw/ignored XML. - */ - class XMLTOOL_API UnknownElementBuilder : public XMLObjectBuilder - { - public: - XMLObject* buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL - ) const { - return new UnknownElementImpl(nsURI,localName,prefix); - } - }; - -}; - -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - -#endif /* __xmltooling_unkelement_h__ */ +/* +* Copyright 2001-2007 Internet2 + * +* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file xmltooling/impl/UnknownElement.h + * + * Basic implementation suitable for use as default for unrecognized content + */ + +#ifndef __xmltooling_unkelement_h__ +#define __xmltooling_unkelement_h__ + +#include +#include +#include +#include +#include + +#include + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4250 4251 ) +#endif + +namespace xmltooling { + + /// @cond off + class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractSimpleElement, public AbstractDOMCachingXMLObject + { + public: + UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL) + : AbstractXMLObject(namespaceURI, elementLocalName, namespacePrefix) {} + + void releaseDOM() const; + + XMLObject* clone() const; + + const XMLCh* getTextContent(unsigned int position=0) const { + throw XMLObjectException("Direct access to content is not permitted."); + } + + void setTextContent(const XMLCh*, unsigned int position=0) { + throw XMLObjectException("Direct access to content is not permitted."); + } + + DOMElement* marshall( + DOMDocument* document=NULL +#ifndef XMLTOOLING_NO_XMLSEC + ,const std::vector* sigs=NULL +#endif + ) const; + + DOMElement* marshall( + DOMElement* parentElement +#ifndef XMLTOOLING_NO_XMLSEC + ,const std::vector* sigs=NULL +#endif + ) const; + XMLObject* unmarshall(DOMElement* element, bool bindDocument=false); + + protected: + void setDocumentElement(DOMDocument* document, DOMElement* element) const { + DOMElement* documentRoot = document->getDocumentElement(); + if (documentRoot) + document->replaceChild(element, documentRoot); + else + document->appendChild(element); + } + + mutable std::string m_xml; + + void serialize(std::string& s) const; + }; + /// @endcond + + /** + * Builder for UnknownElementImpl objects. + * Use as the default builder when you want unknown DOM content treated as raw/ignored XML. + */ + class XMLTOOL_API UnknownElementBuilder : public XMLObjectBuilder + { + public: + XMLObject* buildObject( + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL + ) const; + }; + +}; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +#endif /* __xmltooling_unkelement_h__ */