]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPEntry.cpp
Initial check of the LDAP C++ SDK written by Ralf Haferkamp <rhafer@suse.de>
[openldap] / contrib / ldapc++ / src / LDAPEntry.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 // $Id: LDAPEntry.cpp,v 1.6 2000/08/31 17:43:48 rhafer Exp $
7
8 #include "debug.h"
9 #include "LDAPEntry.h"
10
11 LDAPEntry::LDAPEntry(const LDAPEntry& entry){
12     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::LDAPEntry(LDAPEntry&)" << endl);
13         this->setDN(entry.m_dn);
14         this->setAttributes(entry.m_attrs);
15 }
16
17
18 LDAPEntry::LDAPEntry(const char *dn, 
19         LDAPAttributeList *attrs=new LDAPAttributeList()){
20         m_attrs=attrs;
21         m_dn=strdup(dn);
22 }
23
24 LDAPEntry::LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg){
25     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::LDAPEntry()" << endl);
26         m_dn = ldap_get_dn(ld->getSessionHandle(),msg);
27         m_attrs = new LDAPAttributeList(ld, msg);
28         m_attrs->find("objectClass");
29 }
30
31 LDAPEntry::~LDAPEntry(){
32     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::~LDAPEntry()" << endl);
33         delete[] m_dn;
34         delete m_attrs;
35 }
36
37 void LDAPEntry::setDN(const char* dn){
38         if (m_dn != 0){
39                 delete[] m_dn;
40         }
41         m_dn=strdup(dn);
42 }
43
44 void LDAPEntry::setAttributes(LDAPAttributeList *attrs){
45         if (m_attrs != 0){
46                 delete m_attrs;
47         }
48         m_attrs=attrs;
49 }
50
51 char* LDAPEntry::getDN(){
52         return strdup(m_dn);
53 }
54
55 LDAPAttributeList* LDAPEntry::getAttributes(){
56         return m_attrs;
57 }
58
59 ostream& operator << (ostream& s, const LDAPEntry& le){
60         s << "DN: " << le.m_dn << ": " << *(le.m_attrs); 
61         return s;
62 }