Debian Codegraph @

contrib/ldapc++/src/LDAPEntry.h

raw
1 // $OpenLDAP$
2 /*
3 * Copyright 2000-2024 The 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 structures.
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 * Deletes all values of an Attribute from the list of Attributes
84 * (simple wrapper around LDAPAttributeList::delAttribute() ).
85 * @param type The attribute to delete.
86 */
87 void delAttribute(const std::string& type);
88
89 /**
90 * Replace an Attribute in the List of Attributes (simple wrapper
91 * around LDAPAttributeList::replaceAttribute() ).
92 * @param attr The attribute to add to the list.
93 */
94 void replaceAttribute(const LDAPAttribute& attr);
95
96 /**
97 * @returns The current DN of the entry.
98 */
99 const std::string& getDN() const ;
100
101 /**
102 * @returns A const pointer to the attributes of the entry.
103 */
104 const LDAPAttributeList* getAttributes() const;
105
106 /**
107 * This method can be used to dump the data of a LDAPResult-Object.
108 * It is only useful for debugging purposes at the moment
109 */
110 friend std::ostream& operator << (std::ostream& s, const LDAPEntry& le);
111
112 private :
113 LDAPAttributeList *m_attrs;
114 std::string m_dn;
115 };
116 #endif //LDAP_ENTRY_H