]> git.sur5r.net Git - openldap/commitdiff
added support for deleting attribute type from the list of attributes
authorQuanah Gibson-Mount <quanah@openldap.org>
Tue, 8 Jul 2008 21:31:00 +0000 (21:31 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 8 Jul 2008 21:31:00 +0000 (21:31 +0000)
contrib/ldapc++/src/LDAPAttributeList.cpp
contrib/ldapc++/src/LDAPAttributeList.h
contrib/ldapc++/src/LDAPEntry.cpp
contrib/ldapc++/src/LDAPEntry.h

index a8dbc184eb24fec4753a7be21a3a9b8388329c6e..de17579a5584c912301d8079555f2b83c0949bc0 100644 (file)
@@ -140,22 +140,30 @@ void LDAPAttributeList::addAttribute(const LDAPAttribute& attr){
     }
 }
 
-void LDAPAttributeList::replaceAttribute(const LDAPAttribute& attr)
+void LDAPAttributeList::delAttribute(const std::string& type)
 {
     DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::replaceAttribute()" << endl);
-    DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
-            "   attr:" << attr << endl);
-    
+    DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER, "   type: " << type << endl);
     LDAPAttributeList::iterator i;
     for( i = m_attrs.begin(); i != m_attrs.end(); i++){
-       if(attr.getName().size() == i->getName().size()){
-           if(equal(attr.getName().begin(), attr.getName().end(), i->getName().begin(),
+       if(type.size() == i->getName().size()){
+           if(equal(type.begin(), type.end(), i->getName().begin(),
                    nocase_compare)){
                 m_attrs.erase(i);
                 break;
             }
         }
     }
+}
+
+void LDAPAttributeList::replaceAttribute(const LDAPAttribute& attr)
+{
+    DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::replaceAttribute()" << endl);
+    DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
+            "   attr:" << attr << endl);
+    
+    LDAPAttributeList::iterator i;
+    this->delAttribute( attr.getName() );
     m_attrs.push_back(attr);
 }
 
index 7f9161ae80e52aecd93391a02e489429e3b3c4cb..1e6ba6d51e51640acc9e342a5decd0c8fb96f8a2 100644 (file)
@@ -90,6 +90,12 @@ class LDAPAttributeList{
          * @param attr The attribute to add to the list.
          */
         void addAttribute(const LDAPAttribute& attr);
+        
+        /**
+         * Deletes all values of an Attribute for the list
+         * @param type The attribute type to be deleted.
+         */
+        void delAttribute(const std::string& type);
 
         /**
          * Replace an Attribute in the List
index 19b99a1e9463d7ab63a75f8d5ee172272510276f..bdf7fa8f2e1715053909fd1660a23b6c583be0f8 100644 (file)
@@ -88,6 +88,11 @@ void LDAPEntry::addAttribute(const LDAPAttribute& attr)
     m_attrs->addAttribute(attr);
 }
 
+void LDAPEntry::delAttribute(const std::string& type)
+{
+    m_attrs->delAttribute(type);
+}
+
 void LDAPEntry::replaceAttribute(const LDAPAttribute& attr)
 {
     m_attrs->replaceAttribute(attr); 
index bb16fe8c6be5c60550165a98d7ad880477c783d1..9f2aaf02572736ebcc211ea34f9fc5f0d0c1792d 100644 (file)
@@ -78,6 +78,13 @@ class LDAPEntry{
          * @param attr The attribute to add to the list.
          */
         void addAttribute(const LDAPAttribute& attr);
+        
+        /**
+         * Deletes all values of an Attribute from the list of Attributes 
+         * (simple wrapper around LDAPAttributeList::delAttribute() ).
+         * @param type The attribute to delete.
+         */
+        void delAttribute(const std::string& type);
 
         /**
          * Replace an Attribute in the List of Attributes (simple wrapper