+// $OpenLDAP$
/*
- * Copyright 2000-2002, OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "LDAPAsynConnection.h"
#include "LDAPMessage.h"
+#include <cstdlib>
+
using namespace std;
// little helper function for doing case insensitve string comparison
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()){
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();
}
}
+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();
}
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 << "; ";
}