X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2FAbstractXMLObject.h;h=e72f3eb54428f95ef379827e84c09bca5147d30b;hb=c5183613326e3d36a544b2941654d0667a29b836;hp=a3b5a70a11706046e26c6f84fd0fa83d985fd36f;hpb=5b17688631ba903af821a15221614b4423bb1dc9;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/AbstractXMLObject.h b/xmltooling/AbstractXMLObject.h index a3b5a70..e72f3eb 100644 --- a/xmltooling/AbstractXMLObject.h +++ b/xmltooling/AbstractXMLObject.h @@ -38,9 +38,7 @@ namespace xmltooling { class XMLTOOL_API AbstractXMLObject : public virtual XMLObject { public: - virtual ~AbstractXMLObject() { - delete m_typeQname; - } + virtual ~AbstractXMLObject(); /** * @see XMLObject::getElementQName() @@ -66,8 +64,10 @@ namespace xmltooling { /** * @see XMLObject::addNamespace() */ - void addNamespace(const Namespace& ns) { - m_namespaces.insert(ns); + void addNamespace(const Namespace& ns) const { + if (ns.alwaysDeclare() || m_namespaces.find(ns)==m_namespaces.end()) { + m_namespaces.insert(ns); + } } /** @@ -116,24 +116,51 @@ namespace xmltooling { void setParent(XMLObject* parent) { m_parent = parent; } - - protected: - AbstractXMLObject() : m_typeQname(NULL), m_parent(NULL) {} /** + * @see XMLObject::hasChildren() + */ + bool hasChildren() const { + return !m_children.empty(); + } + + /** + * @see XMLObject::getOrderedChildren() + */ + const std::list& getOrderedChildren() const { + return m_children; + } + + protected: + /** * Constructor * * @param namespaceURI the namespace the element is in * @param elementLocalName the local name of the XML element this Object represents + * @param namespacePrefix the namespace prefix to use */ - AbstractXMLObject(const XMLCh* namespaceURI, const XMLCh* elementLocalName) - : m_elementQname(namespaceURI,elementLocalName), m_typeQname(NULL), m_parent(NULL) {} - + AbstractXMLObject(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL); + + /** + * Underlying list of child objects. + * Manages the lifetime of the children. + */ + std::list m_children; + + /** + * Set of namespaces associated with the object. + */ + mutable std::set m_namespaces; + + /** + * Logging object. + */ + void* m_log; + private: XMLObject* m_parent; QName m_elementQname; QName* m_typeQname; - std::set m_namespaces; }; };