2008-03-28 07:05:10 -04:00
|
|
|
// $OpenLDAP$
|
2000-09-01 14:46:32 -04:00
|
|
|
/*
|
2014-01-25 08:21:25 -05:00
|
|
|
* Copyright 2000-2014 The OpenLDAP Foundation, All Rights Reserved.
|
2000-09-01 14:46:32 -04:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef LDAP_ATTRIBUTE_LIST_H
|
|
|
|
|
#define LDAP_ATTRIBUTE_LIST_H
|
|
|
|
|
|
2001-09-28 12:39:58 -04:00
|
|
|
#include <ldap.h>
|
2000-09-01 14:46:32 -04:00
|
|
|
#include <list>
|
2002-03-06 18:04:38 -05:00
|
|
|
#include <string>
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
class LDAPAttribute;
|
|
|
|
|
class LDAPAsynConnection;
|
|
|
|
|
class LDAPMsg;
|
2000-09-01 14:46:32 -04:00
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* This container class is used to store multiple LDAPAttribute-objects.
|
|
|
|
|
*/
|
2000-09-01 14:46:32 -04:00
|
|
|
class LDAPAttributeList{
|
2004-02-03 12:11:17 -05:00
|
|
|
typedef std::list<LDAPAttribute> ListType;
|
|
|
|
|
|
2001-05-04 10:38:13 -04:00
|
|
|
private :
|
2004-02-03 12:11:17 -05:00
|
|
|
ListType m_attrs;
|
2000-09-01 14:46:32 -04:00
|
|
|
|
2001-05-04 10:38:13 -04:00
|
|
|
public :
|
2004-02-03 12:11:17 -05:00
|
|
|
typedef ListType::const_iterator const_iterator;
|
|
|
|
|
typedef ListType::iterator iterator;
|
2001-03-15 06:07:58 -05:00
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Copy-constructor
|
|
|
|
|
*/
|
2001-05-04 10:38:13 -04:00
|
|
|
LDAPAttributeList(const LDAPAttributeList& al);
|
2000-10-03 14:25:34 -04:00
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* For internal use only
|
|
|
|
|
*
|
|
|
|
|
* This constructor is used by the library internally to create a
|
|
|
|
|
* list of attributes from a LDAPMessage-struct that was return by
|
|
|
|
|
* the C-API
|
2000-10-03 14:25:34 -04:00
|
|
|
*/
|
2001-05-04 10:38:13 -04:00
|
|
|
LDAPAttributeList(const LDAPAsynConnection *ld, LDAPMessage *msg);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs an empty list.
|
|
|
|
|
*/
|
2001-05-04 10:38:13 -04:00
|
|
|
LDAPAttributeList();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
virtual ~LDAPAttributeList();
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* @return The number of LDAPAttribute-objects that are currently
|
|
|
|
|
* stored in this list.
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
size_t size() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
2001-09-07 13:43:55 -04:00
|
|
|
/**
|
|
|
|
|
* @return true if there are zero LDAPAttribute-objects currently
|
|
|
|
|
* stored in this list.
|
|
|
|
|
*/
|
|
|
|
|
bool empty() const;
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* @return A iterator that points to the first element of the list.
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
const_iterator begin() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return A iterator that points to the element after the last
|
|
|
|
|
* element of the list.
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
const_iterator end() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
2002-03-06 18:04:38 -05:00
|
|
|
/**
|
|
|
|
|
* Get an Attribute by its AttributeType
|
|
|
|
|
* @param name The name of the Attribute to look for
|
|
|
|
|
* @return a pointer to the LDAPAttribute with the AttributeType
|
|
|
|
|
* "name" or 0, if there is no Attribute of that Type
|
|
|
|
|
*/
|
|
|
|
|
const LDAPAttribute* getAttributeByName(const std::string& name) const;
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* Adds one element to the end of the list.
|
|
|
|
|
* @param attr The attribute to add to the list.
|
|
|
|
|
*/
|
2001-05-04 10:38:13 -04:00
|
|
|
void addAttribute(const LDAPAttribute& attr);
|
2008-06-12 10:47:55 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes all values of an Attribute for the list
|
|
|
|
|
* @param type The attribute type to be deleted.
|
|
|
|
|
*/
|
|
|
|
|
void delAttribute(const std::string& type);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
2008-01-22 09:14:39 -05:00
|
|
|
/**
|
|
|
|
|
* Replace an Attribute in the List
|
|
|
|
|
* @param attr The attribute to add to the list.
|
|
|
|
|
*/
|
|
|
|
|
void replaceAttribute(const LDAPAttribute& attr);
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* Translates the list of Attributes to a 0-terminated array of
|
|
|
|
|
* LDAPMod-structures as needed by the C-API
|
|
|
|
|
*/
|
2001-05-04 10:38:13 -04:00
|
|
|
LDAPMod** toLDAPModArray() const;
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* This method can be used to dump the data of a LDAPResult-Object.
|
|
|
|
|
* It is only useful for debugging purposes at the moment
|
|
|
|
|
*/
|
2001-09-28 12:39:58 -04:00
|
|
|
friend std::ostream& operator << (std::ostream& s,
|
|
|
|
|
const LDAPAttributeList& al);
|
2000-09-01 14:46:32 -04:00
|
|
|
};
|
2002-03-06 18:04:38 -05:00
|
|
|
|
2000-09-01 14:46:32 -04:00
|
|
|
#endif // LDAP_ATTRIBUTE_LIST_H
|
|
|
|
|
|