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