]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPControlSet.h
initial support for SASL
[openldap] / contrib / ldapc++ / src / LDAPControlSet.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #ifndef LDAP_CONTROL_SET_H
7 #define LDAP_CONTROL_SET_H
8
9 #include <list>
10 #include <ldap.h>
11 #include <LDAPControl.h>
12
13 typedef std::list<LDAPCtrl> CtrlList;
14
15 /**
16  * This container class is used to store multiple LDAPCtrl-objects.
17  */
18 class LDAPControlSet {
19     typedef CtrlList::const_iterator const_iterator;
20     public :
21         /**
22          * Constructs an empty std::list
23          */
24         LDAPControlSet();   
25
26
27         /**
28          * Copy-constructor
29          */
30         LDAPControlSet(const LDAPControlSet& cs);
31         
32         /**
33          * For internal use only
34          *
35          * This constructor creates a new LDAPControlSet for a
36          * 0-terminiated array of LDAPControl-structures as used by the
37          * C-API
38          * @param controls: pointer to a 0-terminated array of pointers to 
39          *                  LDAPControll-structures
40          * @note: untested til now. Due to lack of server that return 
41          *          Controls
42          */
43         LDAPControlSet(LDAPControl** controls);
44
45         /**
46          * Destructor
47          */
48         ~LDAPControlSet();
49
50         /**
51          * @return The number of LDAPCtrl-objects that are currently
52          * stored in this list.
53          */
54         size_t size() const ;
55         
56         /**
57          * @return true if there are zero LDAPCtrl-objects currently
58          * stored in this list.
59          */
60         bool empty() const;
61         
62         /**
63          * @return A iterator that points to the first element of the list.
64          */
65         const_iterator begin() const;
66
67         /**
68          * @return A iterator that points to the element after the last
69          * element of the list.
70          */
71         const_iterator end() const;
72        
73         /**
74          * Adds one element to the end of the list.
75          * @param ctrl The Control to add to the list.
76          */
77         void add(const LDAPCtrl& ctrl); 
78         
79         /**
80          * Translates the list to a 0-terminated array of pointers to
81          * LDAPControl-structures as needed by the C-API
82          */
83         LDAPControl** toLDAPControlArray()const ;
84         static void freeLDAPControlArray(LDAPControl **ctrl);
85     private :
86         CtrlList data;
87 } ;
88 #endif //LDAP_CONTROL_SET_H