An abstract implementation of XMLObject. More...
#include <xmltooling/AbstractXMLObject.h>
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) |
Protected Member Functions | |
AbstractXMLObject (const XMLCh *nsURI=nullptr, const XMLCh *localName=nullptr, const XMLCh *prefix=nullptr, const QName *schemaType=nullptr) | |
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. |
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.
xmltooling::AbstractXMLObject::AbstractXMLObject | ( | const XMLCh * | nsURI = nullptr , |
|
const XMLCh * | localName = nullptr , |
|||
const XMLCh * | prefix = nullptr , |
|||
const QName * | schemaType = nullptr | |||
) | [protected] |
Constructor.
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 |
xmltooling::AbstractXMLObject::AbstractXMLObject | ( | const AbstractXMLObject & | src | ) | [protected] |
Copy constructor.
void xmltooling::AbstractXMLObject::addNamespace | ( | const Namespace & | ns | ) | const [virtual] |
Adds a namespace to the ones already scoped to this element.
ns | the 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.
Reimplemented in xmltooling::AbstractDOMCachingXMLObject.
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.
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.
Implements xmltooling::XMLObject.
xmlconstants::xmltooling_bool_t xmltooling::AbstractXMLObject::getNil | ( | ) | const [virtual] |
Returns the xsi:nil property as an explicit enumerated value.
Implements xmltooling::XMLObject.
XMLObject* xmltooling::AbstractXMLObject::getParent | ( | ) | const [virtual] |
Gets the parent of this element or null if there is no parent.
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.
Implements xmltooling::XMLObject.
const XMLCh* xmltooling::AbstractXMLObject::getXMLID | ( | ) | const [virtual] |
Gets the value of the ID attribute set on this object, if any.
Implements xmltooling::XMLObject.
Reimplemented in xmltooling::AbstractAttributeExtensibleXMLObject.
bool xmltooling::AbstractXMLObject::hasParent | ( | ) | const [virtual] |
Checks to see if this object has a parent.
Implements xmltooling::XMLObject.
void xmltooling::AbstractXMLObject::nil | ( | xmlconstants::xmltooling_bool_t | value | ) | [virtual] |
Sets the xsi:nil property using an enumerated value.
value | value to set |
Implements xmltooling::XMLObject.
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.
oldValue | current value | |
newValue | proposed new value |
XMLObjectException | if the new child already has a parent. |
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.
oldValue | the current value | |
newValue | the new value |
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.
oldValue | the current value | |
newValue | the new value in string form | |
duration | true iff the value is a duration rather than an absolute timestamp |
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.
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 |
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.
oldValue | the current value | |
newValue | the new value |
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.
oldValue | the current value | |
newValue | the new value |
void xmltooling::AbstractXMLObject::removeNamespace | ( | const Namespace & | ns | ) | [virtual] |
Removes a namespace from this element.
ns | the namespace to remove |
Implements xmltooling::XMLObject.