blob: 66c4bae6c76db91eedc03ee08c95381eb8b138b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// $OpenLDAP$
/*
* Copyright 2000-2018 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "StringList.h"
#include "debug.h"
#include <cstdlib>
using namespace std;
StringList::StringList(){
}
StringList::StringList(const StringList& sl){
m_data= StringList::ListType(sl.m_data);
}
StringList::StringList(char** values){
if(values == 0){
m_data=StringList::ListType();
}else{
char** i;
for(i=values; *i != 0; i++){
m_data.push_back(string(*i));
}
}
}
StringList::~StringList(){
DEBUG(LDAP_DEBUG_TRACE,"StringList::~StringList()" << endl);
}
char** StringList::toCharArray() const{
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;
}
}
void StringList::add(const string& value){
m_data.push_back(value);
}
size_t StringList::size() const{
return m_data.size();
}
bool StringList::empty() const{
return m_data.empty();
}
StringList::const_iterator StringList::begin() const{
return m_data.begin();
}
StringList::const_iterator StringList::end() const{
return m_data.end();
}
void StringList::clear(){
m_data.clear();
}
|