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