Convert from NULL macro to nullptr.
[shibboleth/cpp-xmltooling.git] / xmltooling / util / XMLHelper.h
index 81c86c4..d776d03 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2009 Internet2
+ *  Copyright 2001-2010 Internet2
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 
 #include <xmltooling/base.h>
 
+#include <set>
 #include <iostream>
 #include <xercesc/dom/DOM.hpp>
 
@@ -56,7 +57,7 @@ namespace xmltooling {
         /**
          * Returns resource held by this object.
          *
-         * @return  the resource held or NULL
+         * @return  the resource held or nullptr
          */
         T* get() {
             return m_held;
@@ -65,7 +66,7 @@ namespace xmltooling {
         /**
          * Returns resource held by this object.
          *
-         * @return  the resource held or NULL
+         * @return  the resource held or nullptr
          */
         T* operator->() {
             return m_held;
@@ -74,11 +75,11 @@ namespace xmltooling {
         /**
          * Returns resource held by this object and releases it to the caller.
          *
-         * @return  the resource held or NULL
+         * @return  the resource held or nullptr
          */
         T* release() {
             T* ret=m_held;
-            m_held=NULL;
+            m_held=nullptr;
             return ret;
         }
     };
@@ -119,7 +120,7 @@ namespace xmltooling {
          *
          * @param tree  root of tree to search
          * @param id    ID value to locate
-         * @return XMLObject in the tree with a matching ID value, or NULL
+         * @return XMLObject in the tree with a matching ID value, or nullptr
          */
         static const XMLObject* getXMLObjectById(const XMLObject& tree, const XMLCh* id);
 
@@ -129,11 +130,19 @@ namespace xmltooling {
          *
          * @param tree  root of tree to search
          * @param id    ID value to locate
-         * @return XMLObject in the tree with a matching ID value, or NULL
+         * @return XMLObject in the tree with a matching ID value, or nullptr
          */
         static XMLObject* getXMLObjectById(XMLObject& tree, const XMLCh* id);
 
         /**
+         * Returns a list of non-visibly-used namespace prefixes found in a tree.
+         *
+         * @param tree      root of tree to search
+         * @param prefixes  container to store prefix list
+         */
+        static void getNonVisiblyUsedPrefixes(const XMLObject& tree, std::set<xstring>& prefixes);
+
+        /**
          * Gets the QName for the given DOM node.
          *
          * @param domNode the DOM node
@@ -176,45 +185,43 @@ namespace xmltooling {
          * @param local local name to compare with
          * @return  true iff the node's qualified name matches the other parameters
          */
-        static bool isNodeNamed(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* local) {
-            return (n && xercesc::XMLString::equals(local,n->getLocalName()) && xercesc::XMLString::equals(ns,n->getNamespaceURI()));
-        }
+        static bool isNodeNamed(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* local);
 
         /**
          * Returns the first matching child element of the node if any.
          *
          * @param n         node to check
-         * @param localName local name to compare with or NULL for any match
-         * @return  the first matching child node of type Element, or NULL
+         * @param localName local name to compare with or nullptr for any match
+         * @return  the first matching child node of type Element, or nullptr
          */
-        static xercesc::DOMElement* getFirstChildElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+        static xercesc::DOMElement* getFirstChildElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
 
         /**
          * Returns the last matching child element of the node if any.
          *
          * @param n     node to check
-         * @param localName local name to compare with or NULL for any match
-         * @return  the last matching child node of type Element, or NULL
+         * @param localName local name to compare with or nullptr for any match
+         * @return  the last matching child node of type Element, or nullptr
          */
-        static xercesc::DOMElement* getLastChildElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+        static xercesc::DOMElement* getLastChildElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
 
         /**
          * Returns the next matching sibling element of the node if any.
          *
          * @param n     node to check
-         * @param localName local name to compare with or NULL for any match
-         * @return  the next matching sibling node of type Element, or NULL
+         * @param localName local name to compare with or nullptr for any match
+         * @return  the next matching sibling node of type Element, or nullptr
          */
-        static xercesc::DOMElement* getNextSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+        static xercesc::DOMElement* getNextSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
 
         /**
          * Returns the previous matching sibling element of the node if any.
          *
          * @param n     node to check
-         * @param localName local name to compare with or NULL for any match
-         * @return  the previous matching sibling node of type Element, or NULL
+         * @param localName local name to compare with or nullptr for any match
+         * @return  the previous matching sibling node of type Element, or nullptr
          */
-        static xercesc::DOMElement* getPreviousSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+        static xercesc::DOMElement* getPreviousSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
 
         /**
          * Returns the first matching child element of the node if any.
@@ -222,7 +229,7 @@ namespace xmltooling {
          * @param n         node to check
          * @param ns        namespace to compare with
          * @param localName local name to compare with
-         * @return  the first matching child node of type Element, or NULL
+         * @return  the first matching child node of type Element, or nullptr
          */
         static xercesc::DOMElement* getFirstChildElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
 
@@ -232,7 +239,7 @@ namespace xmltooling {
          * @param n         node to check
          * @param ns        namespace to compare with
          * @param localName local name to compare with
-         * @return  the last matching child node of type Element, or NULL
+         * @return  the last matching child node of type Element, or nullptr
          */
         static xercesc::DOMElement* getLastChildElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
 
@@ -242,7 +249,7 @@ namespace xmltooling {
          * @param n         node to check
          * @param ns        namespace to compare with
          * @param localName local name to compare with
-         * @return  the next matching sibling node of type Element, or NULL
+         * @return  the next matching sibling node of type Element, or nullptr
          */
         static xercesc::DOMElement* getNextSiblingElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
 
@@ -252,7 +259,7 @@ namespace xmltooling {
          * @param n         node to check
          * @param ns        namespace to compare with
          * @param localName local name to compare with
-         * @return  the previous matching sibling node of type Element, or NULL
+         * @return  the previous matching sibling node of type Element, or nullptr
          */
         static xercesc::DOMElement* getPreviousSiblingElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
 
@@ -262,7 +269,7 @@ namespace xmltooling {
          * examples the immediate children of the element.
          *
          * @param e     element to examine
-         * @return the content of the first Text node found, or NULL
+         * @return the content of the first Text node found, or nullptr
          */
         static const XMLCh* getTextContent(const xercesc::DOMElement* e);