xmltooling::AbstractXMLObject Class Reference

An abstract implementation of XMLObject. More...

`#include <xmltooling/AbstractXMLObject.h>`

Inheritance diagram for xmltooling::AbstractXMLObject:

## Public Member Functions

void | detach ()
| Specialized function for detaching a child object from its parent while disposing of the parent.
const QName & | getElementQName () const
| Gets the QName for this element.
const std::set< Namespace > & | getNamespaces () const
| Gets the namespaces that are scoped to this element.
void | addNamespace (const Namespace &ns) const
| Adds a namespace to the ones already scoped to this element.
void | removeNamespace (const Namespace &ns)
| Removes a namespace from this element.
const QName * | getSchemaType () const
| Gets the XML schema type of this element.
const XMLCh * | getXMLID () const
| Gets the value of the ID attribute set on this object, if any.
xmlconstants::xmltooling_bool_t | getNil () const
| Returns the xsi:nil property as an explicit enumerated value.
void | nil (xmlconstants::xmltooling_bool_t value)
| Sets the xsi:nil property using an enumerated value.
bool | hasParent () const
| Checks to see if this object has a parent.
XMLObject * | getParent () const
| Gets the parent of this element or null if there is no parent.
void | setParent (XMLObject *parent)
| Sets the parent of this element.
Public Member Functions inherited from xmltooling::XMLObject
virtual XMLObject * | clone () const =0
| Creates a copy of the object, along with all of its children.
virtual const XMLCh * | getLang () const
| Returns the xml:lang property of the object, if any.
bool | nil () const
| Returns the xsi:nil property of the object, or false if not set.
void | nil (bool value)
| Sets the xsi:nil property.
void | setNil (const XMLCh *value)
| Sets the xsi:nil property using a string constant.
virtual bool | hasChildren () const =0
| Checks if this XMLObject has children.
virtual const std::list< XMLObject * > & | getOrderedChildren () const =0
| Returns an unmodifiable list of child objects in the order that they should appear in the serialized representation.
virtual void | removeChild (XMLObject *child)=0
| Used by a child's detach method to isolate the child from this parent object in preparation for destroying the parent (this object).
virtual const XMLCh * | getTextContent (unsigned int position=0) const =0
| Returns the text content at the specified position relative to any child elements.
virtual void | setTextContent (const XMLCh *value, unsigned int position=0)=0
| Sets (or clears) text content relative to a child element's position.
virtual xercesc::DOMElement * | getDOM () const =0
| Gets the DOM representation of this XMLObject, if one exists.
virtual void | setDOM (xercesc::DOMElement *dom, bool bindDocument=false) const =0
| Sets the DOM representation of this XMLObject.
virtual void | setDocument (xercesc::DOMDocument *doc) const =0
| Assigns ownership of a DOM document to the XMLObject.
virtual void | releaseDOM () const =0
| Releases the DOM representation of this XMLObject, if there is one.
virtual void | releaseParentDOM (bool propagateRelease=true) const =0
| Releases the DOM representation of this XMLObject's parent.
virtual void | releaseChildrenDOM (bool propagateRelease=true) const =0
| Releases the DOM representation of this XMLObject's children.
void | releaseThisandParentDOM () const
| A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).
void | releaseThisAndChildrenDOM () const
| A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().
virtual xercesc::DOMElement * | marshall (xercesc::DOMDocument *document=0, const std::vector< xmlsignature::Signature * > *sigs=0, const Credential *credential=0) const =0
| Marshalls the XMLObject, and its children, into a DOM element.
virtual xercesc::DOMElement * | marshall (xercesc::DOMElement *parentElement, const std::vector< xmlsignature::Signature * > *sigs=0, const Credential *credential=0) const =0
| Marshalls the XMLObject and appends it as a child of the given parent element.
virtual XMLObject * | unmarshall (xercesc::DOMElement *element, bool bindDocument=false)=0
| Unmarshalls the given W3C DOM element into the XMLObject.

## Protected Member Functions

| AbstractXMLObject (const XMLCh *nsURI=0, const XMLCh *localName=0, const XMLCh *prefix=0, const QName *schemaType=0)
| Constructor.
| AbstractXMLObject (const AbstractXMLObject &src)
| Copy constructor.
XMLCh * | prepareForAssignment (XMLCh *oldValue, const XMLCh *newValue)
| A helper function for derived classes, for assignment of strings.
xercesc::XMLDateTime * | prepareForAssignment (xercesc::XMLDateTime *oldValue, const xercesc::XMLDateTime *newValue)
| A helper function for derived classes, for assignment of date/time data.
xercesc::XMLDateTime * | prepareForAssignment (xercesc::XMLDateTime *oldValue, time_t newValue, bool duration=false)
| A helper function for derived classes, for assignment of date/time data.
xercesc::XMLDateTime * | prepareForAssignment (xercesc::XMLDateTime *oldValue, const XMLCh *newValue, bool duration=false)
| A helper function for derived classes, for assignment of date/time data.
QName * | prepareForAssignment (QName *oldValue, const QName *newValue)
| A helper function for derived classes, for assignment of QName data.
XMLObject * | prepareForAssignment (XMLObject *oldValue, XMLObject *newValue)
| A helper function for derived classes, for assignment of (singleton) XML objects.

## Protected Attributes

std::set< Namespace > | m_namespaces
| Set of namespaces associated with the object.
logging::Category & | m_log
| Logging object.
XMLCh * | m_schemaLocation
| Stores off xsi:schemaLocation attribute.
XMLCh * | m_noNamespaceSchemaLocation
| Stores off xsi:noNamespaceSchemaLocation attribute.
xmlconstants::xmltooling_bool_t | m_nil
| Stores off xsi:nil attribute.

## Detailed Description

An abstract implementation of XMLObject.

This is the primary concrete base class, and supplies basic namespace, type, and parent handling. Most implementation classes should not directly inherit from this class, but rather from the various mixins that supply the rest of the XMLObject interface, as required.

## Constructor & Destructor Documentation

## AbstractXMLObject()

xmltooling::AbstractXMLObject::AbstractXMLObject | ( | const XMLCh * | nsURI = 0,
|  | const XMLCh * | localName = 0,
|  | const XMLCh * | prefix = 0,
|  | const QName * | schemaType = 0 )

protected

Constructor.

Parameters

  nsURI | the namespace of the element
  localName | the local name of the XML element this Object represents
  prefix | the namespace prefix to use
  schemaType | the xsi:type to use

## Member Function Documentation

## addNamespace()

void xmltooling::AbstractXMLObject::addNamespace | ( | const Namespace & | ns | ) | const

virtual

Adds a namespace to the ones already scoped to this element.

Parameters

  ns | the namespace to add

Implements xmltooling::XMLObject.

## detach()

void xmltooling::AbstractXMLObject::detach | ( |  | ) |

virtual

Specialized function for detaching a child object from its parent while disposing of the parent.

This is not a generic way of detaching any child object, but only of pruning a single child from the root of an XMLObject tree. If the detached XMLObject's parent is itself a child, an exception will be thrown. It's mainly useful for turning a child into the new root of the tree without having to clone the child.

Implements xmltooling::XMLObject.

## getElementQName()

const QName & xmltooling::AbstractXMLObject::getElementQName | ( |  | ) | const

virtual

Gets the QName for this element.

This QName MUST contain the namespace URI, namespace prefix, and local element name.

Returns
  constant reference to the QName for this object

Implements xmltooling::XMLObject.

## getNamespaces()

const std::set< Namespace > & xmltooling::AbstractXMLObject::getNamespaces | ( |  | ) | const

virtual

Gets the namespaces that are scoped to this element.

The caller MUST NOT modify the set returned, but may use any non-modifying operations or algorithms on it. Iterators will remain valid unless the set member referenced is removed using the removeNamespace method.

Returns
  the namespaces that are scoped to this element

Implements xmltooling::XMLObject.

## getNil()

xmlconstants::xmltooling_bool_t xmltooling::AbstractXMLObject::getNil | ( |  | ) | const

virtual

Returns the xsi:nil property as an explicit enumerated value.

Returns
  the xsi:nil property

Implements xmltooling::XMLObject.

## getParent()

XMLObject * xmltooling::AbstractXMLObject::getParent | ( |  | ) | const

virtual

Gets the parent of this element or null if there is no parent.

Returns
  the parent of this element or null

Implements xmltooling::XMLObject.

## getSchemaType()

const QName * xmltooling::AbstractXMLObject::getSchemaType | ( |  | ) | const

virtual

Gets the XML schema type of this element.

This translates to contents the xsi:type attribute for the element.

Returns
  XML schema type of this element

Implements xmltooling::XMLObject.

## getXMLID()

const XMLCh * xmltooling::AbstractXMLObject::getXMLID | ( |  | ) | const

virtual

Gets the value of the ID attribute set on this object, if any.

Returns
  an ID value or nullptr

Implements xmltooling::XMLObject.

## hasParent()

bool xmltooling::AbstractXMLObject::hasParent | ( |  | ) | const

virtual

Checks to see if this object has a parent.

Returns
  true if the object has a parent, false if not

Implements xmltooling::XMLObject.

## nil()

void xmltooling::AbstractXMLObject::nil | ( | xmlconstants::xmltooling_bool_t | value | ) |

virtual

Sets the xsi:nil property using an enumerated value.

Parameters

  value | value to set

Implements xmltooling::XMLObject.

## prepareForAssignment() [1/6]

QName * xmltooling::AbstractXMLObject::prepareForAssignment | ( | QName * | oldValue,
|  | const QName * | newValue )

protected

A helper function for derived classes, for assignment of QName data.

It invalidates the DOM, frees the old object, and returns the new.

Parameters

  oldValue | the current value
  newValue | the new value

Returns
  the value that should be assigned

## prepareForAssignment() [2/6]

xercesc::XMLDateTime * xmltooling::AbstractXMLObject::prepareForAssignment | ( | xercesc::XMLDateTime * | oldValue,
|  | const xercesc::XMLDateTime * | newValue )

protected

A helper function for derived classes, for assignment of date/time data.

It invalidates the DOM, frees the old object, and returns the new.

Parameters

  oldValue | the current value
  newValue | the new value

Returns
  the value that should be assigned

## prepareForAssignment() [3/6]

xercesc::XMLDateTime * xmltooling::AbstractXMLObject::prepareForAssignment | ( | xercesc::XMLDateTime * | oldValue,
|  | const XMLCh * | newValue,
|  | bool | duration = false )

protected

A helper function for derived classes, for assignment of date/time data.

It invalidates the DOM, frees the old object, and returns the new.

Parameters

  oldValue | the current value
  newValue | the new value in string form
  duration | true iff the value is a duration rather than an absolute timestamp

Returns
  the value that should be assigned

## prepareForAssignment() [4/6]

xercesc::XMLDateTime * xmltooling::AbstractXMLObject::prepareForAssignment | ( | xercesc::XMLDateTime * | oldValue,
|  | time_t | newValue,
|  | bool | duration = false )

protected

A helper function for derived classes, for assignment of date/time data.

It invalidates the DOM, frees the old object, and returns the new.

Parameters

  oldValue | the current value
  newValue | the epoch to assign as the new value
  duration | true iff the value is a duration rather than an absolute timestamp

Returns
  the value that should be assigned

## prepareForAssignment() [5/6]

XMLCh * xmltooling::AbstractXMLObject::prepareForAssignment | ( | XMLCh * | oldValue,
|  | const XMLCh * | newValue )

protected

A helper function for derived classes, for assignment of strings.

This 'normalizes' newString, and then if it is different from oldString, it invalidates the DOM, frees the old string, and returns the new. If not different, it frees the new string and just returns the old value.

Parameters

  oldValue | the current value
  newValue | the new value

Returns
  the value that should be assigned

## prepareForAssignment() [6/6]

XMLObject * xmltooling::AbstractXMLObject::prepareForAssignment | ( | XMLObject * | oldValue,
|  | XMLObject * | newValue )

protected

A helper function for derived classes, for assignment of (singleton) XML objects.

It is indifferent to whether either the old or the new version of the value is null. This method will do a safe compare of the objects and will also invalidate the DOM if appropriate. Note that since the new value (even if nullptr) is always returned, it may be more efficient to discard the return value and just assign independently if a dynamic cast would be involved.

Parameters

  oldValue | current value
  newValue | proposed new value

Returns
  the new value

Exceptions

  XMLObjectException | if the new child already has a parent.

## removeNamespace()

void xmltooling::AbstractXMLObject::removeNamespace | ( | const Namespace & | ns | ) |

virtual

Removes a namespace from this element.

Parameters

  ns | the namespace to remove

Implements xmltooling::XMLObject.

## setParent()

void xmltooling::AbstractXMLObject::setParent | ( | XMLObject * | parent | ) |

virtual

Sets the parent of this element.

Parameters

  parent | the parent of this element

Implements xmltooling::XMLObject.

The documentation for this class was generated from the following file:

- xmltooling/AbstractXMLObject.h