1251877Speter/* $NetBSD$ */ 2251877Speter 3251877Speter// OpenLDAP: pkg/ldap/contrib/ldapc++/src/LDAPAttributeList.h,v 1.9.6.3 2008/07/08 19:31:00 quanah Exp 4251877Speter/* 5251877Speter * Copyright 2000-2002, OpenLDAP Foundation, All Rights Reserved. 6251877Speter * COPYING RESTRICTIONS APPLY, see COPYRIGHT file 7251877Speter */ 8251877Speter 9251877Speter 10251877Speter#ifndef LDAP_ATTRIBUTE_LIST_H 11251877Speter#define LDAP_ATTRIBUTE_LIST_H 12251877Speter 13251877Speter#include <ldap.h> 14251877Speter#include <list> 15251877Speter#include <string> 16251877Speter 17251877Speterclass LDAPAttribute; 18251877Speterclass LDAPAsynConnection; 19253895Speterclass LDAPMsg; 20251877Speter 21251877Speter/** 22251877Speter * This container class is used to store multiple LDAPAttribute-objects. 23251877Speter */ 24251877Speterclass LDAPAttributeList{ 25251877Speter typedef std::list<LDAPAttribute> ListType; 26251877Speter 27251877Speter private : 28251877Speter ListType m_attrs; 29253895Speter 30253895Speter public : 31253895Speter typedef ListType::const_iterator const_iterator; 32253895Speter typedef ListType::iterator iterator; 33253895Speter 34253895Speter 35253895Speter /** 36251877Speter * Copy-constructor 37251877Speter */ 38251877Speter LDAPAttributeList(const LDAPAttributeList& al); 39251877Speter 40253895Speter /** 41253895Speter * For internal use only 42251877Speter * 43251877Speter * This constructor is used by the library internally to create a 44251877Speter * list of attributes from a LDAPMessage-struct that was return by 45251877Speter * the C-API 46251877Speter */ 47251877Speter LDAPAttributeList(const LDAPAsynConnection *ld, LDAPMessage *msg); 48251877Speter 49251877Speter /** 50251877Speter * Constructs an empty list. 51251877Speter */ 52251877Speter LDAPAttributeList(); 53251877Speter 54251877Speter /** 55251877Speter * Destructor 56251877Speter */ 57251877Speter virtual ~LDAPAttributeList(); 58251877Speter 59251877Speter /** 60251877Speter * @return The number of LDAPAttribute-objects that are currently 61251877Speter * stored in this list. 62251877Speter */ 63253895Speter size_t size() const; 64253895Speter 65251877Speter /** 66251877Speter * @return true if there are zero LDAPAttribute-objects currently 67251877Speter * stored in this list. 68251877Speter */ 69251877Speter bool empty() const; 70251877Speter 71251877Speter /** 72251877Speter * @return A iterator that points to the first element of the list. 73251877Speter */ 74251877Speter const_iterator begin() const; 75251877Speter 76251877Speter /** 77251877Speter * @return A iterator that points to the element after the last 78251877Speter * element of the list. 79251877Speter */ 80251877Speter const_iterator end() const; 81262339Speter 82262339Speter /** 83251877Speter * Get an Attribute by its AttributeType 84251877Speter * @param name The name of the Attribute to look for 85251877Speter * @return a pointer to the LDAPAttribute with the AttributeType 86251877Speter * "name" or 0, if there is no Attribute of that Type 87251877Speter */ 88251877Speter const LDAPAttribute* getAttributeByName(const std::string& name) const; 89253895Speter 90251877Speter /** 91253895Speter * Adds one element to the end of the list. 92253895Speter * @param attr The attribute to add to the list. 93253895Speter */ 94253895Speter void addAttribute(const LDAPAttribute& attr); 95253895Speter 96253895Speter /** 97253895Speter * Deletes all values of an Attribute for the list 98253895Speter * @param type The attribute type to be deleted. 99253895Speter */ 100253895Speter void delAttribute(const std::string& type); 101253895Speter 102253895Speter /** 103253895Speter * Replace an Attribute in the List 104253895Speter * @param attr The attribute to add to the list. 105253895Speter */ 106253895Speter void replaceAttribute(const LDAPAttribute& attr); 107253895Speter 108253895Speter /** 109253895Speter * Translates the list of Attributes to a 0-terminated array of 110253895Speter * LDAPMod-structures as needed by the C-API 111253895Speter */ 112262339Speter LDAPMod** toLDAPModArray() const; 113262339Speter 114253895Speter /** 115253895Speter * This method can be used to dump the data of a LDAPResult-Object. 116253895Speter * It is only useful for debugging purposes at the moment 117253895Speter */ 118253895Speter friend std::ostream& operator << (std::ostream& s, 119251877Speter const LDAPAttributeList& al); 120251877Speter}; 121251877Speter 122251877Speter#endif // LDAP_ATTRIBUTE_LIST_H 123251877Speter 124251877Speter