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