X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=contrib%2Fldapc%2B%2B%2Fsrc%2FLDAPAttributeList.cpp;h=6e5f66e7f2aa863711cdf1b0f2b4754feee71934;hb=55060f6b1f23c6e4276d8e10ef73eaf1f2a3ab3a;hp=5d3b467748cc9657229aa0d81e0066dde92cd6cb;hpb=025e612920068f186c8fa388422b0a3198b6c0a7;p=openldap diff --git a/contrib/ldapc++/src/LDAPAttributeList.cpp b/contrib/ldapc++/src/LDAPAttributeList.cpp index 5d3b467748..6e5f66e7f2 100644 --- a/contrib/ldapc++/src/LDAPAttributeList.cpp +++ b/contrib/ldapc++/src/LDAPAttributeList.cpp @@ -1,5 +1,6 @@ +// $OpenLDAP$ /* - * Copyright 2000-2002, OpenLDAP Foundation, All Rights Reserved. + * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ @@ -13,6 +14,8 @@ #include "LDAPAsynConnection.h" #include "LDAPMessage.h" +#include + using namespace std; // little helper function for doing case insensitve string comparison @@ -90,7 +93,7 @@ const LDAPAttribute* LDAPAttributeList::getAttributeByName( DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::getAttributeByName()" << endl); DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER, " name:" << name << endl); - AttrList::const_iterator i; + LDAPAttributeList::const_iterator i; for( i = m_attrs.begin(); i != m_attrs.end(); i++){ const std::string& tmpType = i->getName(); if(name.size() == tmpType.size()){ @@ -112,7 +115,7 @@ void LDAPAttributeList::addAttribute(const LDAPAttribute& attr){ const std::string::size_type attrLen = attrType.size(); std::string::size_type tmpAttrLen = 0; bool done=false; - AttrList::iterator i; + LDAPAttributeList::iterator i; for( i=m_attrs.begin(); i != m_attrs.end(); i++ ){ const std::string tmpAttrType = i->getName(); tmpAttrLen = tmpAttrType.size(); @@ -137,11 +140,37 @@ void LDAPAttributeList::addAttribute(const LDAPAttribute& attr){ } } +void LDAPAttributeList::delAttribute(const std::string& type) +{ + DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::replaceAttribute()" << 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(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); +} LDAPMod** LDAPAttributeList::toLDAPModArray() const{ DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::toLDAPModArray()" << endl); LDAPMod **ret = (LDAPMod**) malloc((m_attrs.size()+1) * sizeof(LDAPMod*)); - AttrList::const_iterator i; + LDAPAttributeList::const_iterator i; int j=0; for (i=m_attrs.begin(); i!= m_attrs.end(); i++, j++){ ret[j]=i->toLDAPMod(); @@ -151,7 +180,7 @@ LDAPMod** LDAPAttributeList::toLDAPModArray() const{ } ostream& operator << (ostream& s, const LDAPAttributeList& al){ - AttrList::const_iterator i; + LDAPAttributeList::const_iterator i; for(i=al.m_attrs.begin(); i!=al.m_attrs.end(); i++){ s << *i << "; "; }