/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
/**
- * @file XMLObject.h
+ * @file xmltooling/XMLObject.h
*
* Abstract interface to objects that can be manipulated in and out of XML form.
*/
#ifndef __xmltooling_xmlobj_h__
#define __xmltooling_xmlobj_h__
-#include <xmltooling/QName.h>
#include <xmltooling/Namespace.h>
+#include <xmltooling/util/XMLConstants.h>
#include <set>
#include <list>
#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.
class XMLTOOL_API XMLObject
{
public:
- virtual ~XMLObject() {}
+ virtual ~XMLObject();
/**
* Creates a copy of the object, along with all of its children.
* @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.
/**
* 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.
virtual XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false)=0;
protected:
- XMLObject() {}
+ XMLObject();
private:
XMLObject& operator=(const XMLObject& src);
};