]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/StringList.h
added empty() method to the list classes. (Patch was provided by Dan
[openldap] / contrib / ldapc++ / src / StringList.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #ifndef STRING_LIST_H
7 #define STRING_LIST_H
8
9 #include <string>
10 #include <list>
11 typedef list<string> ListType;
12
13 /**
14  * Container class to store multiple string-objects
15  */
16 class StringList{
17     private:
18         ListType m_data;
19
20     public:
21         typedef ListType::const_iterator const_iterator;
22    
23         /**
24          * Constructs an empty list.
25          */   
26         StringList();
27
28         /**
29          * Copy-constructor
30          */
31         StringList(const StringList& sl);
32
33         /**
34          * For internal use only
35          *
36          * This constructor is used by the library internally to create a
37          * list of string from a array for c-Strings (char*)thar was
38          * returned by the C-API
39          */
40         StringList(char** values);
41
42         /**
43          * Destructor
44          */
45         ~StringList();
46     
47         /**
48          * The methods converts the list to a 0-terminated array of
49          * c-Strings.
50          */
51         char** toCharArray() const;
52   
53         /**
54          * Adds one element to the end of the list.
55          * @param attr The attribute to add to the list.
56          */
57         void add(const string& value);
58
59         /**
60          * @return The number of strings that are currently
61          * stored in this list.
62          */
63         size_t size() const;
64
65         /**
66          * @return true if there are zero strings currently
67          * stored in this list.
68          */
69         bool empty() const;
70
71         /**
72          * @return A iterator that points to the first element of the list.
73          */
74         const_iterator begin() const;
75
76         /**
77          * @return A iterator that points to the element after the last
78          * element of the list.
79          */
80         const_iterator end() const;
81
82         /**
83          * removes all elements from the list
84          */
85         void clear(); 
86 };
87 #endif //STRING_LIST_H