]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPControlSet.cpp
some changes to make the library working with gcc 3.0 (mostly namespace
[openldap] / contrib / ldapc++ / src / LDAPControlSet.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #include "debug.h"
7 #include "LDAPControlSet.h"
8
9 using namespace std;
10
11 LDAPControlSet::LDAPControlSet(){
12 }
13
14 LDAPControlSet::LDAPControlSet(const LDAPControlSet& cs){
15     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPControlSet::LDAPControlSet(&)" << endl);
16     data=cs.data;
17 }
18
19 LDAPControlSet::LDAPControlSet(LDAPControl** controls){
20     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPControlSet::LDAPControlSet()" << endl);
21     if(controls != 0){
22         LDAPControl** i;
23         for( i=controls; *i!=0;i++) {
24             add(LDAPCtrl(*i));
25         }
26     }
27 }
28
29 LDAPControlSet::~LDAPControlSet(){
30     DEBUG(LDAP_DEBUG_DESTROY,"LDAPControlSet::~LDAPControlSet()" << endl);
31 }
32
33 size_t LDAPControlSet::size() const {
34     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::size()" << endl);
35     return data.size();
36 }
37
38 bool LDAPControlSet::empty() const {
39     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::empty()" << endl);
40     return data.empty();
41 }
42
43 LDAPControlSet::const_iterator LDAPControlSet::begin() const{
44     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::begin()" << endl);
45     return data.begin();
46 }
47
48
49 LDAPControlSet::const_iterator LDAPControlSet::end() const{
50     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::end()" << endl);
51     return data.end ();
52 }
53
54 void LDAPControlSet::add(const LDAPCtrl& ctrl){
55     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::add()" << endl);
56     data.push_back(ctrl);
57 }
58
59 LDAPControl** LDAPControlSet::toLDAPControlArray() const{
60     DEBUG(LDAP_DEBUG_TRACE, "LDAPControlSet::toLDAPControlArray()" << endl);
61     if(data.empty()){
62         return 0;
63     }else{
64         LDAPControl** ret= new LDAPControl*[data.size()+1];
65         CtrlList::const_iterator i;
66         int j=0;
67         for(i=data.begin(); i!=data.end(); i++,j++){
68             ret[j] = i->getControlStruct();
69         }
70         ret[data.size()]=0;
71         return ret;
72     }
73 }
74