xref: /netbsd-src/external/bsd/openldap/dist/contrib/ldapc++/src/LDAPEntry.h (revision 549b59ed3ccf0d36d3097190a0db27b770f3a839)
1*549b59edSchristos /*	$NetBSD: LDAPEntry.h,v 1.3 2021/08/14 16:14:49 christos Exp $	*/
24e6df137Slukem 
3d11b170bStron // $OpenLDAP$
42de962bdSlukem /*
5*549b59edSchristos  * Copyright 2000-2021 The OpenLDAP Foundation, All Rights Reserved.
62de962bdSlukem  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
72de962bdSlukem  */
82de962bdSlukem 
92de962bdSlukem 
102de962bdSlukem #ifndef LDAP_ENTRY_H
112de962bdSlukem #define LDAP_ENTRY_H
122de962bdSlukem #include <ldap.h>
132de962bdSlukem 
142de962bdSlukem #include <LDAPAttributeList.h>
152de962bdSlukem 
162de962bdSlukem class LDAPAsynConnection;
172de962bdSlukem 
182de962bdSlukem /**
192de962bdSlukem  * This class is used to store every kind of LDAP Entry.
202de962bdSlukem  */
212de962bdSlukem class LDAPEntry{
222de962bdSlukem 
232de962bdSlukem     public :
242de962bdSlukem         /**
252de962bdSlukem          * Copy-constructor
262de962bdSlukem          */
272de962bdSlukem         LDAPEntry(const LDAPEntry& entry);
282de962bdSlukem 
292de962bdSlukem         /**
302de962bdSlukem          * Constructs a new entry (also used as standard constructor).
312de962bdSlukem          *
322de962bdSlukem          * @param dn    The Distinguished Name for the new entry.
332de962bdSlukem          * @param attrs The attributes for the new entry.
342de962bdSlukem          */
352de962bdSlukem         LDAPEntry(const std::string& dn=std::string(),
362de962bdSlukem                 const LDAPAttributeList *attrs=0);
372de962bdSlukem 
382de962bdSlukem         /**
392de962bdSlukem          * Used internally only.
402de962bdSlukem          *
412de962bdSlukem          * The constructor is used internally to create a LDAPEntry from
42*549b59edSchristos          * the C-API's data structures.
432de962bdSlukem          */
442de962bdSlukem         LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg);
452de962bdSlukem 
462de962bdSlukem         /**
472de962bdSlukem          * Destructor
482de962bdSlukem          */
492de962bdSlukem         ~LDAPEntry();
502de962bdSlukem 
512de962bdSlukem         /**
522de962bdSlukem          * Assignment operator
532de962bdSlukem          */
542de962bdSlukem         LDAPEntry& operator=(const LDAPEntry& from);
552de962bdSlukem 
562de962bdSlukem         /**
572de962bdSlukem          * Sets the DN-attribute.
582de962bdSlukem          * @param dn: The new DN for the entry.
592de962bdSlukem          */
602de962bdSlukem         void setDN(const std::string& dn);
612de962bdSlukem 
622de962bdSlukem         /**
632de962bdSlukem          * Sets the attributes of the entry.
642de962bdSlukem          * @param attr: A pointer to a std::list of the new attributes.
652de962bdSlukem          */
662de962bdSlukem         void setAttributes(LDAPAttributeList *attrs);
672de962bdSlukem 
682de962bdSlukem 	/**
692de962bdSlukem 	 * Get an Attribute by its AttributeType (simple wrapper around
702de962bdSlukem          * LDAPAttributeList::getAttributeByName() )
712de962bdSlukem 	 * @param name The name of the Attribute to look for
722de962bdSlukem 	 * @return a pointer to the LDAPAttribute with the AttributeType
732de962bdSlukem 	 *	"name" or 0, if there is no Attribute of that Type
742de962bdSlukem 	 */
752de962bdSlukem 	const LDAPAttribute* getAttributeByName(const std::string& name) const;
762de962bdSlukem 
772de962bdSlukem         /**
782de962bdSlukem          * Adds one Attribute to the List of Attributes (simple wrapper around
792de962bdSlukem          * LDAPAttributeList::addAttribute() ).
802de962bdSlukem          * @param attr The attribute to add to the list.
812de962bdSlukem          */
822de962bdSlukem         void addAttribute(const LDAPAttribute& attr);
832de962bdSlukem 
842de962bdSlukem         /**
85bb30016cSlukem          * Deletes all values of an Attribute from the list of Attributes
86bb30016cSlukem          * (simple wrapper around LDAPAttributeList::delAttribute() ).
87bb30016cSlukem          * @param type The attribute to delete.
88bb30016cSlukem          */
89bb30016cSlukem         void delAttribute(const std::string& type);
90bb30016cSlukem 
91bb30016cSlukem         /**
922de962bdSlukem          * Replace an Attribute in the List of Attributes (simple wrapper
932de962bdSlukem          * around LDAPAttributeList::replaceAttribute() ).
942de962bdSlukem          * @param attr The attribute to add to the list.
952de962bdSlukem          */
962de962bdSlukem         void replaceAttribute(const LDAPAttribute& attr);
972de962bdSlukem 
982de962bdSlukem         /**
992de962bdSlukem          * @returns The current DN of the entry.
1002de962bdSlukem          */
1012de962bdSlukem         const std::string& getDN() const ;
1022de962bdSlukem 
1032de962bdSlukem         /**
1042de962bdSlukem          * @returns A const pointer to the attributes of the entry.
1052de962bdSlukem          */
1062de962bdSlukem         const LDAPAttributeList* getAttributes() const;
1072de962bdSlukem 
1082de962bdSlukem         /**
1092de962bdSlukem          * This method can be used to dump the data of a LDAPResult-Object.
1102de962bdSlukem          * It is only useful for debugging purposes at the moment
1112de962bdSlukem          */
1122de962bdSlukem         friend std::ostream& operator << (std::ostream& s, const LDAPEntry& le);
1132de962bdSlukem 
1142de962bdSlukem     private :
1152de962bdSlukem         LDAPAttributeList *m_attrs;
1162de962bdSlukem         std::string m_dn;
1172de962bdSlukem };
1182de962bdSlukem #endif  //LDAP_ENTRY_H
119