X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fimpl%2FUnknownElement.h;h=90d9a67b4e0ebcf160ddcac82a0c4c800d1b5da0;hb=a0d768778a8f5f539b909baf5b115e70ea765f0f;hp=764e17d2f5ea14e39709f107828625905a8f2dc9;hpb=60f3be64ed06c66d430173ad1514c148cd35610f;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/impl/UnknownElement.h b/xmltooling/impl/UnknownElement.h index 764e17d..90d9a67 100644 --- a/xmltooling/impl/UnknownElement.h +++ b/xmltooling/impl/UnknownElement.h @@ -1,154 +1,98 @@ -/* -* 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 implementations suitable for use as defaults for unrecognized content - */ - -#if !defined(__xmltooling_unkelement_h__) -#define __xmltooling_unkelement_h__ - -#include "internal.h" -#include "AbstractDOMCachingXMLObject.h" -#include "XMLObjectBuilder.h" -#include "io/Marshaller.h" -#include "io/Unmarshaller.h" - -#include - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - -namespace xmltooling { - - /** - * Implementation class for unrecognized DOM elements. - * Purpose is to wrap the DOM and do any necessary caching/reconstruction - * when a DOM has to cross into a new document. - */ - class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractDOMCachingXMLObject - { - public: - UnknownElementImpl() {} - - /** - * Overridden to ensure XML content of DOM isn't lost. - * - * @see DOMCachingXMLObject::releaseDOM() - */ - void releaseDOM(); - - /** - * @see XMLObject::clone() - */ - XMLObject* clone() const; - - /** - * @see XMLObject::hasChildren() - */ - bool hasChildren() const { - return false; - } - - /** - * @see XMLObject::getOrderedChildren() - */ - size_t getOrderedChildren(std::vector& v) const { - return 0; - } - - protected: - /** - * When needed, we can serialize the DOM into XML form and preserve it here. - */ - std::string m_xml; - - private: - void serialize(std::string& s) const; - friend class XMLTOOL_API UnknownElementMarshaller; - }; - - /** - * Factory for UnknownElementImpl objects - */ - class XMLTOOL_DLLLOCAL UnknownElementBuilder : public virtual XMLObjectBuilder - { - public: - UnknownElementBuilder() {} - virtual ~UnknownElementBuilder() {} - - /** - * @see XMLObjectBuilder::buildObject() - */ - XMLObject* buildObject() const { - return new UnknownElementImpl(); - } - }; - - /** - * Marshaller for UnknownElementImpl objects - */ - class XMLTOOL_DLLLOCAL UnknownElementMarshaller : public virtual Marshaller - { - public: - UnknownElementMarshaller() {} - virtual ~UnknownElementMarshaller() {} - - /** - * @see Marshaller::marshall(XMLObject*,DOMDocument*) - */ - DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document=NULL) const; - - /** - * @see Marshaller::marshall(XMLObject*,DOMElement*) - */ - DOMElement* marshall(XMLObject* xmlObject, DOMElement* parentElement) const; - - protected: - void setDocumentElement(DOMDocument* document, DOMElement* element) const { - DOMElement* documentRoot = document->getDocumentElement(); - if (documentRoot) - document->replaceChild(documentRoot, element); - else - document->appendChild(element); - } - }; - - /** - * Marshaller for UnknownElementImpl objects - */ - class XMLTOOL_DLLLOCAL UnknownElementUnmarshaller : public virtual Unmarshaller - { - public: - UnknownElementUnmarshaller() {} - virtual ~UnknownElementUnmarshaller() {} - - /** - * @see Unmarshaller::unmarshall() - */ - XMLObject* unmarshall(DOMElement* element, bool bindDocument=false) const; - }; -}; - -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - -#endif /* __xmltooling_unkelement_h__ */ +/* +* Copyright 2001-2010 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=nullptr, const XMLCh* elementLocalName=nullptr, const XMLCh* namespacePrefix=nullptr); + + virtual ~UnknownElementImpl(); + + void releaseDOM() const; + XMLObject* clone() const; + const XMLCh* getTextContent(unsigned int position=0) const; + void setTextContent(const XMLCh*, unsigned int position=0); + + xercesc::DOMElement* marshall( + xercesc::DOMDocument* document=nullptr +#ifndef XMLTOOLING_NO_XMLSEC + ,const std::vector* sigs=nullptr + ,const Credential* credential=nullptr +#endif + ) const; + + xercesc::DOMElement* marshall( + xercesc::DOMElement* parentElement +#ifndef XMLTOOLING_NO_XMLSEC + ,const std::vector* sigs=nullptr + ,const Credential* credential=nullptr +#endif + ) const; + XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false); + + protected: + void setDocumentElement(xercesc::DOMDocument* document, xercesc::DOMElement* element) const; + + 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=nullptr, const QName* schemaType=nullptr + ) const; + }; + +}; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +#endif /* __xmltooling_unkelement_h__ */