Back to index

openldap  2.4.31
Public Types | Public Member Functions | Private Types | Private Attributes
StringList Class Reference

Container class to store multiple string-objects. More...

#include <StringList.h>

Collaboration diagram for StringList:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ListType::const_iterator const_iterator

Public Member Functions

 StringList ()
 Constructs an empty list.
 StringList (const StringList &sl)
 Copy-constructor.
 StringList (char **values)
 For internal use only.
 ~StringList ()
 Destructor.
char ** toCharArray () const
 The methods converts the list to a 0-terminated array of c-Strings.
void add (const std::string &value)
 Adds one element to the end of the list.
size_t size () const
bool empty () const
const_iterator begin () const
const_iterator end () const
void clear ()
 removes all elements from the list

Private Types

typedef std::list< std::string > ListType

Private Attributes

ListType m_data

Detailed Description

Container class to store multiple string-objects.

Definition at line 15 of file StringList.h.


Member Typedef Documentation

typedef ListType::const_iterator StringList::const_iterator

Definition at line 22 of file StringList.h.

typedef std::list<std::string> StringList::ListType [private]

Definition at line 16 of file StringList.h.


Constructor & Destructor Documentation

Constructs an empty list.

Definition at line 14 of file StringList.cpp.

                      {
}

Copy-constructor.

Definition at line 17 of file StringList.cpp.

StringList::StringList ( char **  values)

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

Definition at line 21 of file StringList.cpp.

                                   {
    if(values == 0){
        m_data=StringList::ListType();
    }else{
        char** i;
        for(i=values; *i != 0; i++){
            m_data.push_back(string(*i));
        }
    }
}

Destructor.

Definition at line 32 of file StringList.cpp.

                       {
    DEBUG(LDAP_DEBUG_TRACE,"StringList::~StringList()" << endl);
}

Member Function Documentation

void StringList::add ( const std::string &  value)

Adds one element to the end of the list.

Parameters:
attrThe attribute to add to the list.

Definition at line 53 of file StringList.cpp.

                                       {
    m_data.push_back(value);
}

Here is the caller graph for this function:

Returns:
A iterator that points to the first element of the list.

Definition at line 65 of file StringList.cpp.

                                                {
    return m_data.begin();
}

Here is the caller graph for this function:

removes all elements from the list

Definition at line 74 of file StringList.cpp.

                      {
    m_data.clear();
}
bool StringList::empty ( ) const
Returns:
true if there are zero strings currently stored in this list.

Definition at line 61 of file StringList.cpp.

                            {
    return m_data.empty();
}

Here is the caller graph for this function:

Returns:
A iterator that points to the element after the last element of the list.

Definition at line 69 of file StringList.cpp.

                                              {
    return m_data.end();
}

Here is the caller graph for this function:

size_t StringList::size ( ) const
Returns:
The number of strings that are currently stored in this list.

Definition at line 57 of file StringList.cpp.

                             {
    return m_data.size();
}
char ** StringList::toCharArray ( ) const

The methods converts the list to a 0-terminated array of c-Strings.

Definition at line 36 of file StringList.cpp.

                                    {
    if(!empty()){
        char** ret = (char**) malloc(sizeof(char*) * (size()+1));
        StringList::const_iterator i;
        int j=0;
        for(i=begin(); i != end(); i++,j++){
            ret[j]=(char*) malloc(sizeof(char) * (i->size()+1));
            i->copy(ret[j],string::npos);
            ret[j][i->size()]=0;
        }
        ret[size()]=0;
        return ret;
    }else{
        return 0;
    }
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 19 of file StringList.h.


The documentation for this class was generated from the following files: