https://issues.shibboleth.net/jira/browse/CPPXT-32
authorScott Cantor <cantor.2@osu.edu>
Tue, 21 Jul 2009 22:37:17 +0000 (22:37 +0000)
committerScott Cantor <cantor.2@osu.edu>
Tue, 21 Jul 2009 22:37:17 +0000 (22:37 +0000)
xmltooling/AbstractComplexElement.cpp
xmltooling/AbstractComplexElement.h

index 335520f..6f6f9f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright 2001-2007 Internet2
+*  Copyright 2001-2009 Internet2
  * 
 * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,12 +30,25 @@ using namespace std;
 
 using xercesc::XMLString;
 
+namespace {
+    bool _nonnull(const XMLObject* ptr) {
+        return (ptr!=NULL);
+    }
+}
+
 AbstractComplexElement::~AbstractComplexElement() {
     for_each(m_children.begin(), m_children.end(), cleanup<XMLObject>());
     for (vector<XMLCh*>::iterator i=m_text.begin(); i!=m_text.end(); ++i)
         XMLString::release(&(*i));
 }
 
+bool AbstractComplexElement::hasChildren() const
+{
+    if (m_children.empty())
+        return false;
+    return (find_if(m_children.begin(), m_children.end(), _nonnull) != m_children.end());
+}
+
 void AbstractComplexElement::removeChild(XMLObject* child)
 {
     m_children.erase(remove(m_children.begin(), m_children.end(), child), m_children.end());
index d163f29..cf88200 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,9 +41,7 @@ namespace xmltooling {
     public:
         virtual ~AbstractComplexElement();
         
-        bool hasChildren() const {
-            return !m_children.empty();
-        }
+        bool hasChildren() const;
 
         const std::list<XMLObject*>& getOrderedChildren() const {
             return m_children;