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