]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPAttributeList.h
5cbe8f55f4132d68b536a566291548150794f2e2
[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 <list>
11 class LDAPAttribute;
12 class LDAPAsynConnection;
13 class LDAPMsg;
14
15 typedef list<LDAPAttribute> AttrList;
16
17 /**
18  * This container class is used to store multiple LDAPAttribute-objects.
19  */
20 class LDAPAttributeList{
21         private :
22                 AttrList m_attrs;
23
24         public :
25                 typedef AttrList::const_iterator const_iterator;
26
27
28         /**
29          * Copy-constructor
30          */
31                 LDAPAttributeList(const LDAPAttributeList& al);
32         
33         /**
34          * For internal use only
35          *
36          * This constructor is used by the library internally to create a
37          * list of attributes from a LDAPMessage-struct that was return by
38          * the C-API
39          */
40                 LDAPAttributeList(const LDAPAsynConnection *ld, LDAPMessage *msg);
41
42         /**
43          * Constructs an empty list.
44          */   
45                 LDAPAttributeList();
46
47         /**
48          * Destructor
49          */
50         virtual ~LDAPAttributeList();
51
52         /**
53          * @return The number of LDAPAttribute-objects that are currently
54          * stored in this list.
55          */
56         size_t size() const;
57
58         /**
59          * @return A iterator that points to the first element of the list.
60          */
61         const_iterator begin() const;
62         
63         /**
64          * @return A iterator that points to the element after the last
65          * element of the list.
66          */
67         const_iterator end() const;
68
69         /**
70          * Adds one element to the end of the list.
71          * @param attr The attribute to add to the list.
72          */
73                 void addAttribute(const LDAPAttribute& attr);
74
75         /**
76          * Translates the list of Attributes to a 0-terminated array of
77          * LDAPMod-structures as needed by the C-API
78          */
79                 LDAPMod** toLDAPModArray() const;
80                 
81         /**
82          * This method can be used to dump the data of a LDAPResult-Object.
83          * It is only useful for debugging purposes at the moment
84          */
85                 friend ostream& operator << (ostream& s, const LDAPAttributeList& al);
86 };
87 #endif // LDAP_ATTRIBUTE_LIST_H
88