]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPAttributeList.h
some changes to make the library working with gcc 3.0 (mostly namespace
[openldap] / contrib / ldapc++ / src / LDAPAttributeList.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #ifndef LDAP_ATTRIBUTE_LIST_H
8 #define LDAP_ATTRIBUTE_LIST_H
9
10 #include <ldap.h>
11 #include <list>
12 class LDAPAttribute;
13 class LDAPAsynConnection;
14 class LDAPMsg;
15
16 typedef std::list<LDAPAttribute> AttrList;
17
18 /**
19  * This container class is used to store multiple LDAPAttribute-objects.
20  */
21 class LDAPAttributeList{
22     private :
23         AttrList m_attrs;
24
25     public :
26         typedef AttrList::const_iterator const_iterator;
27
28
29         /**
30          * Copy-constructor
31          */
32         LDAPAttributeList(const LDAPAttributeList& al);
33         
34         /**
35          * For internal use only
36          *
37          * This constructor is used by the library internally to create a
38          * list of attributes from a LDAPMessage-struct that was return by
39          * the C-API
40          */
41         LDAPAttributeList(const LDAPAsynConnection *ld, LDAPMessage *msg);
42
43         /**
44          * Constructs an empty list.
45          */   
46         LDAPAttributeList();
47
48         /**
49          * Destructor
50          */
51         virtual ~LDAPAttributeList();
52
53         /**
54          * @return The number of LDAPAttribute-objects that are currently
55          * stored in this list.
56          */
57         size_t size() const;
58
59         /**
60          * @return true if there are zero LDAPAttribute-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 attr The attribute to add to the list.
79          */
80         void addAttribute(const LDAPAttribute& attr);
81
82         /**
83          * Translates the list of Attributes to a 0-terminated array of
84          * LDAPMod-structures as needed by the C-API
85          */
86         LDAPMod** toLDAPModArray() const;
87         
88         /**
89          * This method can be used to dump the data of a LDAPResult-Object.
90          * It is only useful for debugging purposes at the moment
91          */
92         friend std::ostream& operator << (std::ostream& s, 
93                                           const LDAPAttributeList& al);
94 };
95 #endif // LDAP_ATTRIBUTE_LIST_H
96