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