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