]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPControlSet.cpp
08cdddc938c3bfc4a252a7dab89a76827b129dae
[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 LDAPControlSet::LDAPControlSet(){
10 }
11
12 LDAPControlSet::LDAPControlSet(const LDAPControlSet& cs){
13     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPControlSet::LDAPControlSet(&)" << endl);
14     data=cs.data;
15 }
16
17 LDAPControlSet::LDAPControlSet(LDAPControl** controls){
18     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPControlSet::LDAPControlSet()" << endl);
19     if(controls != 0){
20         LDAPControl** i;
21         for( i=controls; *i!=0;i++) {
22             add(LDAPCtrl(*i));
23         }
24     }
25 }
26
27 LDAPControlSet::~LDAPControlSet(){
28     DEBUG(LDAP_DEBUG_DESTROY,"LDAPControlSet::~LDAPControlSet()" << endl);
29 }
30
31 size_t LDAPControlSet::size() const {
32     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::size()" << endl);
33     return data.size();
34 }
35
36 LDAPControlSet::const_iterator LDAPControlSet::begin() const{
37     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::begin()" << endl);
38     return data.begin();
39 }
40
41
42 LDAPControlSet::const_iterator LDAPControlSet::end() const{
43     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::end()" << endl);
44     return data.end ();
45 }
46
47 void LDAPControlSet::add(const LDAPCtrl& ctrl){
48     DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::add()" << endl);
49     data.push_back(ctrl);
50 }
51
52 LDAPControl** LDAPControlSet::toLDAPControlArray() const{
53     DEBUG(LDAP_DEBUG_TRACE, "LDAPControlSet::toLDAPControlArray()" << endl);
54     if(data.size() == 0){
55         return 0;
56     }else{
57         LDAPControl** ret= new LDAPControl*[data.size()+1];
58         CtrlList::const_iterator i;
59         int j=0;
60         for(i=data.begin(); i!=data.end(); i++,j++){
61             ret[j] = i->getControlStruct();
62         }
63         ret[data.size()]=0;
64         return ret;
65     }
66 }
67