]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPEntry.cpp
795a5f1832b3c6d66c7e84beb8bc9a6873808be8
[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
7 #include "debug.h"
8 #include "LDAPEntry.h"
9
10 #include "LDAPException.h"
11
12 LDAPEntry::LDAPEntry(const LDAPEntry& entry){
13     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry(&)" << endl);
14     m_dn=entry.m_dn;
15     m_attrs=new LDAPAttributeList( *(entry.m_attrs));
16 }
17
18
19 LDAPEntry::LDAPEntry(const string& dn, const LDAPAttributeList *attrs){
20     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl);
21     DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
22             "   dn:" << dn << endl << " attrs:" << *attrs << endl);
23     m_attrs=new LDAPAttributeList(*attrs);
24     m_dn=dn;
25 }
26
27 LDAPEntry::LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg){
28     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl);
29     char* tmp=ldap_get_dn(ld->getSessionHandle(),msg);
30     m_dn=string(tmp);
31     delete[] tmp;
32     m_attrs = new LDAPAttributeList(ld, msg);
33 }
34
35 LDAPEntry::~LDAPEntry(){
36     DEBUG(LDAP_DEBUG_DESTROY,"LDAPEntry::~LDAPEntry()" << endl);
37     delete m_attrs;
38 }
39
40 void LDAPEntry::setDN(const string& dn){
41     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::setDN()" << endl);
42     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
43             "   dn:" << dn << endl);
44     m_dn=dn;
45 }
46
47 void LDAPEntry::setAttributes(LDAPAttributeList *attrs){
48     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::setAttributes()" << endl);
49     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
50             "   attrs:" << *attrs << endl);
51     if (m_attrs != 0){
52         delete m_attrs;
53     }
54     m_attrs=attrs;
55 }
56
57 const string LDAPEntry::getDN() const{
58     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::getDN()" << endl);
59     return m_dn;
60 }
61
62 const LDAPAttributeList* LDAPEntry::getAttributes() const{
63     DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::getAttributes()" << endl);
64     return m_attrs;
65 }
66
67 ostream& operator << (ostream& s, const LDAPEntry& le){
68     s << "DN: " << le.m_dn << ": " << *(le.m_attrs); 
69     return s;
70 }