From: cantor Date: Tue, 21 Jul 2009 22:37:17 +0000 (+0000) Subject: https://bugs.internet2.edu/jira/browse/CPPXT-32 X-Git-Tag: 1.4.1~230 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fxmltooling.git;a=commitdiff_plain;h=5ca4faea8ef50c19338f9e7fc45c7b3a93a05663 https://bugs.internet2.edu/jira/browse/CPPXT-32 git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@602 de75baf8-a10c-0410-a50a-987c0e22f00f --- diff --git a/xmltooling/AbstractComplexElement.cpp b/xmltooling/AbstractComplexElement.cpp index 335520f..6f6f9f1 100644 --- a/xmltooling/AbstractComplexElement.cpp +++ b/xmltooling/AbstractComplexElement.cpp @@ -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()); for (vector::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()); diff --git a/xmltooling/AbstractComplexElement.h b/xmltooling/AbstractComplexElement.h index d163f29..cf88200 100644 --- a/xmltooling/AbstractComplexElement.h +++ b/xmltooling/AbstractComplexElement.h @@ -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& getOrderedChildren() const { return m_children;