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