summaryrefslogtreecommitdiffstats
path: root/contrib/ldapc++/src/LDAPControlSet.h
blob: 59490796b01a0a3ef58af6213afde31f2e123ef1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// $OpenLDAP$
/*
 * Copyright 2000-2018 The OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#ifndef LDAP_CONTROL_SET_H
#define LDAP_CONTROL_SET_H

#include <list>
#include <ldap.h>
#include <LDAPControl.h>

typedef std::list<LDAPCtrl> CtrlList;

/**
 * This container class is used to store multiple LDAPCtrl-objects.
 */
class LDAPControlSet {
    typedef CtrlList::const_iterator const_iterator;
    public :
        /**
         * Constructs an empty std::list
         */
        LDAPControlSet();   


        /**
         * Copy-constructor
         */
        LDAPControlSet(const LDAPControlSet& cs);
        
        /**
         * For internal use only
         *
         * This constructor creates a new LDAPControlSet for a
         * 0-terminiated array of LDAPControl-structures as used by the
         * C-API
         * @param controls: pointer to a 0-terminated array of pointers to 
         *                  LDAPControll-structures
         * @note: untested til now. Due to lack of server that return 
         *          Controls
         */
        LDAPControlSet(LDAPControl** controls);

        /**
         * Destructor
         */
        ~LDAPControlSet();

        /**
         * @return The number of LDAPCtrl-objects that are currently
         * stored in this list.
         */
        size_t size() const ;
        
        /**
         * @return true if there are zero LDAPCtrl-objects currently
         * stored in this list.
         */
        bool empty() const;
        
        /**
         * @return A iterator that points to the first element of the list.
         */
        const_iterator begin() const;

        /**
         * @return A iterator that points to the element after the last
         * element of the list.
         */
        const_iterator end() const;
       
        /**
         * Adds one element to the end of the list.
         * @param ctrl The Control to add to the list.
         */
        void add(const LDAPCtrl& ctrl); 
        
        /**
         * Translates the list to a 0-terminated array of pointers to
         * LDAPControl-structures as needed by the C-API
         */
        LDAPControl** toLDAPControlArray()const ;
	static void freeLDAPControlArray(LDAPControl **ctrl);
    private :
        CtrlList data;
} ;
#endif //LDAP_CONTROL_SET_H