X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fimpl%2FUnknownElement.h;h=e9aee3cf8b3fe13d1505135adedf64b10072f496;hb=6505807a62569ce65803b448b07a6872c6af2512;hp=0ad445df8f9377b4c00a2d7ea4ad0f347eda5f2f;hpb=53a2366efe13f4c6489f6c729e1b3de0f8057c12;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/impl/UnknownElement.h b/xmltooling/impl/UnknownElement.h index 0ad445d..e9aee3c 100644 --- a/xmltooling/impl/UnknownElement.h +++ b/xmltooling/impl/UnknownElement.h @@ -1,93 +1,110 @@ -/* -* 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 - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - -namespace xmltooling { - - /** - * Implements a thin wrapper around unknown DOM content. - */ - class XMLTOOL_DLLLOCAL UnknownElementImpl : 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; - }; - - /** - * Builder for UnknownElementImpl objects. - */ - class XMLTOOL_API UnknownElementBuilder : public XMLObjectBuilder - { - public: - /** - * @see XMLObjectBuilder::buildObject(const XMLCh*,const XMLCh*,const XMLCh*) - */ - UnknownElementImpl* buildObject( - const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL - ) const { - return new UnknownElementImpl(namespaceURI,elementLocalName,namespacePrefix); - } - }; - -}; - -#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 + ,const Credential* credential=NULL +#endif + ) const; + + DOMElement* marshall( + DOMElement* parentElement +#ifndef XMLTOOLING_NO_XMLSEC + ,const std::vector* sigs=NULL + ,const Credential* credential=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__ */