xref: /netbsd-src/external/bsd/openldap/dist/contrib/ldapc++/src/LDAPEntry.h (revision 4b71a66d0f279143147d63ebfcfd8a59499a3684)
1 // $OpenLDAP: pkg/ldap/contrib/ldapc++/src/LDAPEntry.h,v 1.6.8.5 2008/04/14 23:30:47 quanah Exp $
2 /*
3  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 
7 
8 #ifndef LDAP_ENTRY_H
9 #define LDAP_ENTRY_H
10 #include <ldap.h>
11 
12 #include <LDAPAttributeList.h>
13 
14 class LDAPAsynConnection;
15 
16 /**
17  * This class is used to store every kind of LDAP Entry.
18  */
19 class LDAPEntry{
20 
21     public :
22         /**
23          * Copy-constructor
24          */
25         LDAPEntry(const LDAPEntry& entry);
26 
27         /**
28          * Constructs a new entry (also used as standard constructor).
29          *
30          * @param dn    The Distinguished Name for the new entry.
31          * @param attrs The attributes for the new entry.
32          */
33         LDAPEntry(const std::string& dn=std::string(),
34                 const LDAPAttributeList *attrs=0);
35 
36         /**
37          * Used internally only.
38          *
39          * The constructor is used internally to create a LDAPEntry from
40          * the C-API's data structurs.
41          */
42         LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg);
43 
44         /**
45          * Destructor
46          */
47         ~LDAPEntry();
48 
49         /**
50          * Assignment operator
51          */
52         LDAPEntry& operator=(const LDAPEntry& from);
53 
54         /**
55          * Sets the DN-attribute.
56          * @param dn: The new DN for the entry.
57          */
58         void setDN(const std::string& dn);
59 
60         /**
61          * Sets the attributes of the entry.
62          * @param attr: A pointer to a std::list of the new attributes.
63          */
64         void setAttributes(LDAPAttributeList *attrs);
65 
66 	/**
67 	 * Get an Attribute by its AttributeType (simple wrapper around
68          * LDAPAttributeList::getAttributeByName() )
69 	 * @param name The name of the Attribute to look for
70 	 * @return a pointer to the LDAPAttribute with the AttributeType
71 	 *	"name" or 0, if there is no Attribute of that Type
72 	 */
73 	const LDAPAttribute* getAttributeByName(const std::string& name) const;
74 
75         /**
76          * Adds one Attribute to the List of Attributes (simple wrapper around
77          * LDAPAttributeList::addAttribute() ).
78          * @param attr The attribute to add to the list.
79          */
80         void addAttribute(const LDAPAttribute& attr);
81 
82         /**
83          * Replace an Attribute in the List of Attributes (simple wrapper
84          * around LDAPAttributeList::replaceAttribute() ).
85          * @param attr The attribute to add to the list.
86          */
87         void replaceAttribute(const LDAPAttribute& attr);
88 
89         /**
90          * @returns The current DN of the entry.
91          */
92         const std::string& getDN() const ;
93 
94         /**
95          * @returns A const pointer to the attributes of the entry.
96          */
97         const LDAPAttributeList* getAttributes() const;
98 
99         /**
100          * This method can be used to dump the data of a LDAPResult-Object.
101          * It is only useful for debugging purposes at the moment
102          */
103         friend std::ostream& operator << (std::ostream& s, const LDAPEntry& le);
104 
105     private :
106         LDAPAttributeList *m_attrs;
107         std::string m_dn;
108 };
109 #endif  //LDAP_ENTRY_H
110