xmltooling  1.4.2
xmltooling::AbstractXMLObject Class Reference

An abstract implementation of XMLObject. More...

#include <xmltooling/AbstractXMLObject.h>

Inheritance diagram for xmltooling::AbstractXMLObject:
Collaboration diagram for xmltooling::AbstractXMLObject:

Public Member Functions

void detach ()
 Specialized function for detaching a child object from its parent while disposing of the parent. More...
 
const QNamegetElementQName () const
 Gets the QName for this element. More...
 
const std::set< Namespace > & getNamespaces () const
 Gets the namespaces that are scoped to this element. More...
 
void addNamespace (const Namespace &ns) const
 Adds a namespace to the ones already scoped to this element. More...
 
void removeNamespace (const Namespace &ns)
 Removes a namespace from this element. More...
 
const QNamegetSchemaType () const
 Gets the XML schema type of this element. More...
 
const XMLCh * getXMLID () const
 Gets the value of the ID attribute set on this object, if any. More...
 
xmlconstants::xmltooling_bool_t getNil () const
 Returns the xsi:nil property as an explicit enumerated value. More...
 
void nil (xmlconstants::xmltooling_bool_t value)
 Sets the xsi:nil property using an enumerated value. More...
 
bool hasParent () const
 Checks to see if this object has a parent. More...
 
XMLObjectgetParent () const
 Gets the parent of this element or null if there is no parent. More...
 
void setParent (XMLObject *parent)
 Sets the parent of this element. More...
 
- Public Member Functions inherited from xmltooling::XMLObject
virtual XMLObjectclone () const =0
 Creates a copy of the object, along with all of its children. More...
 
bool nil () const
 Returns the xsi:nil property of the object, or false if not set. More...
 
void nil (bool value)
 Sets the xsi:nil property. More...
 
void setNil (const XMLCh *value)
 Sets the xsi:nil property using a string constant. More...
 
virtual bool hasChildren () const =0
 Checks if this XMLObject has children. More...
 
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. More...
 
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). More...
 
virtual const XMLCh * getTextContent (unsigned int position=0) const =0
 Returns the text content at the specified position relative to any child elements. More...
 
virtual void setTextContent (const XMLCh *value, unsigned int position=0)=0
 Sets (or clears) text content relative to a child element's position. More...
 
virtual xercesc::DOMElement * getDOM () const =0
 Gets the DOM representation of this XMLObject, if one exists. More...
 
virtual void setDOM (xercesc::DOMElement *dom, bool bindDocument=false) const =0
 Sets the DOM representation of this XMLObject. More...
 
virtual void setDocument (xercesc::DOMDocument *doc) const =0
 Assigns ownership of a DOM document to the XMLObject. More...
 
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. More...
 
virtual void releaseChildrenDOM (bool propagateRelease=true) const =0
 Releases the DOM representation of this XMLObject's children. More...
 
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. More...
 
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. More...
 
virtual XMLObjectunmarshall (xercesc::DOMElement *element, bool bindDocument=false)=0
 Unmarshalls the given W3C DOM element into the XMLObject. More...
 

Protected Member Functions

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

Protected Attributes

std::set< Namespacem_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

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

Constructor.

Parameters
nsURIthe namespace of the element
localNamethe local name of the XML element this Object represents
prefixthe namespace prefix to use
schemaTypethe xsi:type to use
xmltooling::AbstractXMLObject::AbstractXMLObject ( const AbstractXMLObject src)
protected

Copy constructor.

Member Function Documentation

void xmltooling::AbstractXMLObject::addNamespace ( const Namespace ns) const
virtual

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

Parameters
nsthe namespace to add

Implements xmltooling::XMLObject.

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.

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.

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.

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.

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.

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.

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.

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.

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

Sets the xsi:nil property using an enumerated value.

Parameters
valuevalue to set

Implements xmltooling::XMLObject.

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
oldValuethe current value
newValuethe new value
Returns
the value that should be assigned
DateTime* xmltooling::AbstractXMLObject::prepareForAssignment ( DateTime oldValue,
const DateTime 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
oldValuethe current value
newValuethe new value
Returns
the value that should be assigned
DateTime* xmltooling::AbstractXMLObject::prepareForAssignment ( DateTime 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
oldValuethe current value
newValuethe epoch to assign as the new value
durationtrue iff the value is a duration rather than an absolute timestamp
Returns
the value that should be assigned
DateTime* xmltooling::AbstractXMLObject::prepareForAssignment ( DateTime 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
oldValuethe current value
newValuethe new value in string form
durationtrue iff the value is a duration rather than an absolute timestamp
Returns
the value that should be assigned
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
oldValuethe current value
newValuethe new value
Returns
the value that should be assigned
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
oldValuecurrent value
newValueproposed new value
Returns
the new value
Exceptions
XMLObjectExceptionif the new child already has a parent.
void xmltooling::AbstractXMLObject::removeNamespace ( const Namespace ns)
virtual

Removes a namespace from this element.

Parameters
nsthe namespace to remove

Implements xmltooling::XMLObject.

void xmltooling::AbstractXMLObject::setParent ( XMLObject parent)
virtual

Sets the parent of this element.

Parameters
parentthe parent of this element

Implements xmltooling::XMLObject.


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