X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2FXMLObject.h;h=e0391adcdd2421be59c28c83d144e7c88a135cfb;hb=1487fce9686a1f52165ecd0676315f50a52c6bff;hp=6dd887f0825815833e930dfd3ff34bf2f8fe29f6;hpb=6505807a62569ce65803b448b07a6872c6af2512;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/XMLObject.h b/xmltooling/XMLObject.h index 6dd887f..e0391ad 100644 --- a/xmltooling/XMLObject.h +++ b/xmltooling/XMLObject.h @@ -1,21 +1,25 @@ -/* - * 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 +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. * - * http://www.apache.org/licenses/LICENSE-2.0 + * UCAID licenses this file to you 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 * - * 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. + * 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 XMLObject.h + * @file xmltooling/XMLObject.h * * Abstract interface to objects that can be manipulated in and out of XML form. */ @@ -23,16 +27,14 @@ #ifndef __xmltooling_xmlobj_h__ #define __xmltooling_xmlobj_h__ -#include #include +#include #include #include #include #include -using namespace xercesc; - #ifndef XMLTOOLING_NO_XMLSEC namespace xmlsignature { class XMLTOOL_API Signature; @@ -49,6 +51,7 @@ namespace xmltooling { #ifndef XMLTOOLING_NO_XMLSEC class XMLTOOL_API Credential; #endif + class XMLTOOL_API QName; /** * Object that represents an XML Element that has been unmarshalled into this C++ object. @@ -56,7 +59,7 @@ namespace xmltooling { class XMLTOOL_API XMLObject { public: - virtual ~XMLObject() {} + virtual ~XMLObject(); /** * Creates a copy of the object, along with all of its children. @@ -123,9 +126,56 @@ namespace xmltooling { /** * Gets the value of the ID attribute set on this object, if any. * - * @return an ID value or NULL + * @return an ID value or nullptr */ virtual const XMLCh* getXMLID() const=0; + + /** + * Returns the xsi:nil property of the object, or false if not set. + * + * @return the xsi:nil property + */ + bool nil() const { + switch (getNil()) { + case xmlconstants::XML_BOOL_TRUE: + case xmlconstants::XML_BOOL_ONE: + return true; + case xmlconstants::XML_BOOL_FALSE: + case xmlconstants::XML_BOOL_ZERO: + default: + return false; + } + } + + /** + * Returns the xsi:nil property as an explicit enumerated value. + * + * @return the xsi:nil property + */ + virtual xmlconstants::xmltooling_bool_t getNil() const=0; + + /** + * Sets the xsi:nil property using an enumerated value. + * + * @param value value to set + */ + virtual void nil(xmlconstants::xmltooling_bool_t value)=0; + + /** + * Sets the xsi:nil property. + * + * @param value value to set + */ + void nil(bool value) { + nil(value ? xmlconstants::XML_BOOL_ONE : xmlconstants::XML_BOOL_ZERO); + } + + /** + * Sets the xsi:nil property using a string constant. + * + * @param value value to set + */ + void setNil(const XMLCh* value); /** * Checks to see if this object has a parent. @@ -188,7 +238,7 @@ namespace xmltooling { /** * Sets (or clears) text content relative to a child element's position. * - * @param value value to set, or NULL to clear + * @param value value to set, or nullptr to clear * @param position position relative to child element */ virtual void setTextContent(const XMLCh* value, unsigned int position=0)=0; @@ -198,7 +248,7 @@ namespace xmltooling { * * @return the DOM representation of this XMLObject */ - virtual DOMElement* getDOM() const=0; + virtual xercesc::DOMElement* getDOM() const=0; /** * Sets the DOM representation of this XMLObject. @@ -206,7 +256,7 @@ namespace xmltooling { * @param dom DOM representation of this XMLObject * @param bindDocument true if the object should take ownership of the associated Document */ - virtual void setDOM(DOMElement* dom, bool bindDocument=false) const=0; + virtual void setDOM(xercesc::DOMElement* dom, bool bindDocument=false) const=0; /** * Assigns ownership of a DOM document to the XMLObject. @@ -214,7 +264,7 @@ namespace xmltooling { * * @param doc DOM document bound to this object */ - virtual void setDocument(DOMDocument* doc) const=0; + virtual void setDocument(xercesc::DOMDocument* doc) const=0; /** * Releases the DOM representation of this XMLObject, if there is one. @@ -238,22 +288,12 @@ namespace xmltooling { /** * A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true). */ - void releaseThisandParentDOM() const { - if (getDOM()) { - releaseDOM(); - releaseParentDOM(true); - } - } + void releaseThisandParentDOM() const; /** * A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM(). */ - void releaseThisAndChildrenDOM() const { - if (getDOM()) { - releaseChildrenDOM(true); - releaseDOM(); - } - } + void releaseThisAndChildrenDOM() const; /** * Marshalls the XMLObject, and its children, into a DOM element. @@ -263,7 +303,7 @@ namespace xmltooling { * a new document will be created and bound to the lifetime of the root object being * marshalled, unless an existing DOM can be reused without creating a new document. * - * @param document the DOM document the marshalled element will be placed in, or NULL + * @param document the DOM document the marshalled element will be placed in, or nullptr * @param sigs ordered array of signatures to create after marshalling is complete * @param credential optional credential to supply signing key and related info * @return the DOM element representing this XMLObject @@ -271,11 +311,11 @@ namespace xmltooling { * @throws MarshallingException thrown if there is a problem marshalling the given object * @throws SignatureException thrown if a problem occurs during signature creation */ - virtual DOMElement* marshall( - DOMDocument* document=NULL + virtual xercesc::DOMElement* marshall( + xercesc::DOMDocument* document=nullptr #ifndef XMLTOOLING_NO_XMLSEC - ,const std::vector* sigs=NULL - ,const Credential* credential=NULL + ,const std::vector* sigs=nullptr + ,const Credential* credential=nullptr #endif ) const=0; @@ -293,11 +333,11 @@ namespace xmltooling { * @throws MarshallingException thrown if the given XMLObject can not be marshalled. * @throws SignatureException thrown if a problem occurs during signature creation */ - virtual DOMElement* marshall( - DOMElement* parentElement + virtual xercesc::DOMElement* marshall( + xercesc::DOMElement* parentElement #ifndef XMLTOOLING_NO_XMLSEC - ,const std::vector* sigs=NULL - ,const Credential* credential=NULL + ,const std::vector* sigs=nullptr + ,const Credential* credential=nullptr #endif ) const=0; @@ -313,10 +353,10 @@ namespace xmltooling { * * @throws UnmarshallingException thrown if an error occurs unmarshalling the DOM element into the XMLObject */ - virtual XMLObject* unmarshall(DOMElement* element, bool bindDocument=false)=0; + virtual XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false)=0; protected: - XMLObject() {} + XMLObject(); private: XMLObject& operator=(const XMLObject& src); };