]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPControlSet.h
- some minor bugfixes
[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 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 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 A iterator that points to the first element of the list.
58          */
59         const_iterator begin() const;
60
61         /**
62          * @return A iterator that points to the element after the last
63          * element of the list.
64          */
65         const_iterator end() const;
66        
67         /**
68          * Adds one element to the end of the list.
69          * @param ctrl The Control to add to the list.
70          */
71         void add(const LDAPCtrl& ctrl); 
72         
73         /**
74          * Translates the list to a 0-terminated array of pointers to
75          * LDAPControl-structures as needed by the C-API
76          */
77         LDAPControl** toLDAPControlArray()const ;
78
79     private :
80         CtrlList data;
81 } ;
82 #endif //LDAP_CONTROL_SET_H