]> git.sur5r.net Git - openldap/blobdiff - contrib/ldapc++/src/LDAPEntry.cpp
added support for deleting attribute type from the list of attributes
[openldap] / contrib / ldapc++ / src / LDAPEntry.cpp
index eb3dd5d6abdbd5d46a8827bca6d839bd6b92c4b6..bdf7fa8f2e1715053909fd1660a23b6c583be0f8 100644 (file)
@@ -1,3 +1,4 @@
+// $OpenLDAP$
 /*
  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -7,6 +8,7 @@
 #include "debug.h"
 #include "LDAPEntry.h"
 
+#include "LDAPAsynConnection.h"
 #include "LDAPException.h"
 
 using namespace std;
@@ -21,8 +23,11 @@ LDAPEntry::LDAPEntry(const LDAPEntry& entry){
 LDAPEntry::LDAPEntry(const string& dn, const LDAPAttributeList *attrs){
     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl);
     DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
-            "   dn:" << dn << endl << " attrs:" << *attrs << endl);
-    m_attrs=new LDAPAttributeList(*attrs);
+            "   dn:" << dn << endl);
+    if ( attrs )
+        m_attrs=new LDAPAttributeList(*attrs);
+    else
+        m_attrs=new LDAPAttributeList();
     m_dn=dn;
 }
 
@@ -39,6 +44,13 @@ LDAPEntry::~LDAPEntry(){
     delete m_attrs;
 }
 
+LDAPEntry& LDAPEntry::operator=(const LDAPEntry& from){
+    m_dn = from.m_dn;
+    delete m_attrs;
+    m_attrs = new LDAPAttributeList( *(from.m_attrs));
+    return *this;
+}
+
 void LDAPEntry::setDN(const string& dn){
     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::setDN()" << endl);
     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
@@ -66,6 +78,26 @@ const LDAPAttributeList* LDAPEntry::getAttributes() const{
     return m_attrs;
 }
 
+const LDAPAttribute* LDAPEntry::getAttributeByName(const std::string& name) const 
+{
+    return m_attrs->getAttributeByName(name);
+}
+
+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); 
+}
+
 ostream& operator << (ostream& s, const LDAPEntry& le){
     s << "DN: " << le.m_dn << ": " << *(le.m_attrs); 
     return s;