2000-10-03 14:50:44 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef STRING_LIST_H
|
|
|
|
|
#define STRING_LIST_H
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <list>
|
|
|
|
|
typedef list<string> ListType;
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* Container class to store multiple string-objects
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
class StringList{
|
|
|
|
|
private:
|
|
|
|
|
ListType m_data;
|
|
|
|
|
|
|
|
|
|
public:
|
2001-03-15 06:07:58 -05:00
|
|
|
typedef ListType::const_iterator const_iterator;
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* Constructs an empty list.
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
StringList();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Copy-constructor
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
StringList(const StringList& sl);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For internal use only
|
|
|
|
|
*
|
|
|
|
|
* This constructor is used by the library internally to create a
|
|
|
|
|
* list of string from a array for c-Strings (char*)thar was
|
|
|
|
|
* returned by the C-API
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
StringList(char** values);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
~StringList();
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* The methods converts the list to a 0-terminated array of
|
|
|
|
|
* c-Strings.
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
char** toCharArray() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds one element to the end of the list.
|
|
|
|
|
* @param attr The attribute to add to the list.
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
void add(const string& value);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The number of strings that are currently
|
|
|
|
|
* stored in this list.
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
size_t size() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
2001-09-07 13:43:55 -04:00
|
|
|
/**
|
|
|
|
|
* @return true if there are zero strings currently
|
|
|
|
|
* stored in this list.
|
|
|
|
|
*/
|
|
|
|
|
bool empty() const;
|
|
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* @return A iterator that points to the first element of the list.
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
const_iterator begin() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return A iterator that points to the element after the last
|
|
|
|
|
* element of the list.
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
const_iterator end() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* removes all elements from the list
|
|
|
|
|
*/
|
2000-10-03 14:50:44 -04:00
|
|
|
void clear();
|
|
|
|
|
};
|
|
|
|
|
#endif //STRING_LIST_H
|