X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=blobdiff_plain;f=xmltooling%2FXMLObject.h;h=85f70548a50d9c8159a4c156d759cadbf9bcb573;hp=1d86737bcb3431e82455e38a9999f60d256ec60a;hb=f6221acce6ee490b9189dd2f5efabda3b9e64fb1;hpb=5cb314df178f78c6fa7b9826c2c5a5298ec7a473 diff --git a/xmltooling/XMLObject.h b/xmltooling/XMLObject.h index 1d86737..85f7054 100644 --- a/xmltooling/XMLObject.h +++ b/xmltooling/XMLObject.h @@ -15,7 +15,7 @@ */ /** - * @file XMLObject.h + * @file xmltooling/XMLObject.h * * Abstract interface to objects that can be manipulated in and out of XML form. */ @@ -25,14 +25,13 @@ #include #include +#include #include #include #include #include -using namespace xercesc; - #ifndef XMLTOOLING_NO_XMLSEC namespace xmlsignature { class XMLTOOL_API Signature; @@ -46,6 +45,10 @@ namespace xmlsignature { namespace xmltooling { +#ifndef XMLTOOLING_NO_XMLSEC + class XMLTOOL_API Credential; +#endif + /** * Object that represents an XML Element that has been unmarshalled into this C++ object. */ @@ -122,6 +125,53 @@ namespace xmltooling { * @return an ID value or NULL */ 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. @@ -194,7 +244,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. @@ -202,7 +252,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. @@ -210,7 +260,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. @@ -261,15 +311,17 @@ namespace xmltooling { * * @param document the DOM document the marshalled element will be placed in, or NULL * @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 * * @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=NULL #ifndef XMLTOOLING_NO_XMLSEC ,const std::vector* sigs=NULL + ,const Credential* credential=NULL #endif ) const=0; @@ -281,15 +333,17 @@ namespace xmltooling { * * @param parentElement the parent element to append the resulting DOM tree * @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 marshalled element tree * @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 #endif ) const=0; @@ -305,7 +359,7 @@ 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() {}