[cpp-xmltooling COMMIT] in /branches/REL_1/xmltooling: AbstractAttributeExtensibleXMLObject.cpp AbstractComplexElemen...

noreply at shibboleth.net noreply at shibboleth.net
Thu Dec 8 05:20:13 GMT 2011


Author: scantor
Date: Thu Dec  8 05:20:11 2011
New Revision: 935

URL: http://svn.shibboleth.net/view/cpp-xmltooling?rev=935&view=rev
Log:
More boostisms

Modified:
    branches/REL_1/xmltooling/AbstractAttributeExtensibleXMLObject.cpp
    branches/REL_1/xmltooling/AbstractComplexElement.cpp
    branches/REL_1/xmltooling/AbstractXMLObject.cpp
    branches/REL_1/xmltooling/AbstractXMLObject.h
    branches/REL_1/xmltooling/security/impl/InlineKeyResolver.cpp
    branches/REL_1/xmltooling/util/XMLHelper.cpp

Modified: branches/REL_1/xmltooling/AbstractAttributeExtensibleXMLObject.cpp
URL: http://svn.shibboleth.net/view/cpp-xmltooling/branches/REL_1/xmltooling/AbstractAttributeExtensibleXMLObject.cpp?rev=935&r1=934&r2=935&view=diff
==============================================================================
--- branches/REL_1/xmltooling/AbstractAttributeExtensibleXMLObject.cpp (original)
+++ branches/REL_1/xmltooling/AbstractAttributeExtensibleXMLObject.cpp Thu Dec  8 05:20:11 2011
@@ -31,15 +31,16 @@
 
 #include <algorithm>
 #include <functional>
+#include <boost/lambda/bind.hpp>
+#include <boost/lambda/lambda.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 using namespace xmltooling;
+using namespace xercesc;
+using namespace boost::lambda;
+using namespace boost;
 using namespace std;
-using xercesc::chColon;
-
-using xercesc::DOMAttr;
-using xercesc::DOMElement;
-using xercesc::XMLString;
+
 
 ElementExtensibleXMLObject::ElementExtensibleXMLObject()
 {
@@ -57,7 +58,7 @@
 {
 }
 
-set<QName> AttributeExtensibleXMLObject::m_idAttributeSet;
+set<xmltooling::QName> AttributeExtensibleXMLObject::m_idAttributeSet;
 
 AttributeExtensibleXMLObject::AttributeExtensibleXMLObject()
 {
@@ -67,22 +68,22 @@
 {
 }
 
-const set<QName>& AttributeExtensibleXMLObject::getRegisteredIDAttributes()
+const set<xmltooling::QName>& AttributeExtensibleXMLObject::getRegisteredIDAttributes()
 {
     return m_idAttributeSet;
 }
 
-bool AttributeExtensibleXMLObject::isRegisteredIDAttribute(const QName& name)
+bool AttributeExtensibleXMLObject::isRegisteredIDAttribute(const xmltooling::QName& name)
 {
     return m_idAttributeSet.find(name)!=m_idAttributeSet.end();
 }
 
-void AttributeExtensibleXMLObject::registerIDAttribute(const QName& name)
+void AttributeExtensibleXMLObject::registerIDAttribute(const xmltooling::QName& name)
 {
     m_idAttributeSet.insert(name);
 }
 
-void AttributeExtensibleXMLObject::deregisterIDAttribute(const QName& name)
+void AttributeExtensibleXMLObject::deregisterIDAttribute(const xmltooling::QName& name)
 {
     m_idAttributeSet.erase(name);
 }
@@ -101,7 +102,7 @@
     : AbstractXMLObject(src)
 {
     m_idAttribute = m_attributeMap.end();
-    for (map<QName,XMLCh*>::const_iterator i=src.m_attributeMap.begin(); i!=src.m_attributeMap.end(); i++) {
+    for (map<xmltooling::QName,XMLCh*>::const_iterator i = src.m_attributeMap.begin(); i != src.m_attributeMap.end(); ++i) {
         m_attributeMap[i->first] = XMLString::replicate(i->second);
     }
     if (src.m_idAttribute != src.m_attributeMap.end()) {
@@ -111,36 +112,43 @@
 
 AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject()
 {
-    for (map<QName,XMLCh*>::iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++)
-        XMLString::release(&(i->second));
-}
-
-const XMLCh* AbstractAttributeExtensibleXMLObject::getAttribute(const QName& qualifiedName) const
-{
-    map<QName,XMLCh*>::const_iterator i=m_attributeMap.find(qualifiedName);
-    return (i==m_attributeMap.end()) ? nullptr : i->second;
-}
-
-void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID)
-{
-    map<QName,XMLCh*>::iterator i=m_attributeMap.find(qualifiedName);
-    if (i!=m_attributeMap.end()) {
+    static void (*release)(XMLCh**,MemoryManager*) = &XMLString::release;
+    for_each(
+        m_attributeMap.begin(), m_attributeMap.end(),
+        lambda::bind(
+            release,
+            &lambda::bind(&map<xmltooling::QName,XMLCh*>::value_type::second, boost::ref(_1)),
+            XMLPlatformUtils::fgMemoryManager
+            )
+        );
+}
+
+const XMLCh* AbstractAttributeExtensibleXMLObject::getAttribute(const xmltooling::QName& qualifiedName) const
+{
+    map<xmltooling::QName,XMLCh*>::const_iterator i = m_attributeMap.find(qualifiedName);
+    return (i != m_attributeMap.end()) ? i->second : nullptr;
+}
+
+void AbstractAttributeExtensibleXMLObject::setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID)
+{
+    map<xmltooling::QName,XMLCh*>::iterator i=m_attributeMap.find(qualifiedName);
+    if (i != m_attributeMap.end()) {
         releaseThisandParentDOM();
         XMLString::release(&(i->second));
         if (value && *value) {
-            i->second=XMLString::replicate(value);
+            i->second = XMLString::replicate(value);
             if (ID)
-                m_idAttribute=i;
+                m_idAttribute = i;
         }
         else {
-            if (m_idAttribute==i)
-                m_idAttribute=m_attributeMap.end();

[... 411 lines stripped ...]


More information about the commits mailing list