Back to index

openldap  2.4.31
Public Member Functions | Static Public Member Functions | Private Attributes
LDAPCtrl Class Reference

This class is used to store Controls. More...

#include <LDAPControl.h>

Collaboration diagram for LDAPCtrl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LDAPCtrl (const char *oid, bool critical=false, const char *data=0, int length=0)
 Constructor.
 LDAPCtrl (const std::string &oid, bool critical, const std::string &data)
 Constructor.
 LDAPCtrl (const LDAPControl *ctrl)
 Creates a copy of the Control that "ctrl is pointing to.
 ~LDAPCtrl ()
 Destructor.
std::string getOID () const
bool hasData () const
std::string getData () const
bool isCritical () const
LDAPControlgetControlStruct () const
 For internal use only.

Static Public Member Functions

static void freeLDAPControlStruct (LDAPControl *ctrl)

Private Attributes

std::string m_oid
std::string m_data
bool m_isCritical
bool m_noData

Detailed Description

This class is used to store Controls.

Controls are a mechanism to extend and modify LDAP-Operations.

Definition at line 17 of file LDAPControl.h.


Constructor & Destructor Documentation

LDAPCtrl::LDAPCtrl ( const char *  oid,
bool  critical = false,
const char *  data = 0,
int  length = 0 
)

Constructor.

Parameters:
oid,:The Object Identifier of the Control
critical,:"true" if the Control should be handled critical by the server.
data,:If there is data for the control, put it here.
length,:The length of the data field

Definition at line 13 of file LDAPControl.cpp.

                   {
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPCtrl::LDAPCtrl()" << endl);
    DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
            "   oid:" << oid << endl << "   critical:" << critical << endl);
    m_oid = oid;
    m_isCritical=critical;
    if (data != 0 && length !=0){
        m_data.assign(data,length);
        m_noData=false;
    }else{
        m_data=string();
        m_noData=true;
    }
}
LDAPCtrl::LDAPCtrl ( const std::string &  oid,
bool  critical,
const std::string &  data 
)

Constructor.

Parameters:
oid,:The Object Identifier of the Control
critical,:"true" if the Control should be handled critical by the server.
data,:If there is data for the control, put it here.

Definition at line 29 of file LDAPControl.cpp.

                                                                      {
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPCtrl::LDAPCtrl()" << endl);
    DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
            "   oid:" << oid << endl << "   critical:" << critical << endl);
    m_oid=oid;
    m_isCritical=critical;
    m_data=data;
    m_noData=false;
}

Creates a copy of the Control that "ctrl is pointing to.

Definition at line 39 of file LDAPControl.cpp.

                                         {
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPCtrl::LDAPCtrl()" << endl);
    m_oid = string(ctrl->ldctl_oid);
    m_oid = ctrl->ldctl_iscritical ? true : false;
    m_oid = string(ctrl->ldctl_value.bv_val, ctrl->ldctl_value.bv_len );
}

Destructor.

Definition at line 46 of file LDAPControl.cpp.

                   {
    DEBUG(LDAP_DEBUG_DESTROY,"LDAPCtrl::~LDAPCtrl" << endl);
}

Member Function Documentation

Definition at line 87 of file LDAPControl.cpp.

                                                     {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::freeControlStruct()" << endl);
    delete[] ctrl->ldctl_oid;
    delete[] ctrl->ldctl_value.bv_val;
    delete ctrl;
}

Here is the caller graph for this function:

For internal use only.

Translates the control to a LDAPControl-structure as needed by the C-API

Definition at line 69 of file LDAPControl.cpp.

                                              {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::getControlStruct()" << endl);
    LDAPControl* ret = new LDAPControl;
    ret->ldctl_oid= new char[m_oid.size() + 1];
    m_oid.copy(ret->ldctl_oid,string::npos);
    ret->ldctl_oid[m_oid.size()]=0;
    if ( m_noData ) {
        ret->ldctl_value.bv_len = 0;
        ret->ldctl_value.bv_val = NULL;
    } else {
        ret->ldctl_value.bv_len=m_data.size();
        ret->ldctl_value.bv_val= new char[m_data.size()];
        m_data.copy(ret->ldctl_value.bv_val,string::npos);
    }
    ret->ldctl_iscritical = ( m_isCritical ? 1:0);
    return ret;
}
string LDAPCtrl::getData ( ) const
Returns:
The Data of the control as a std::string-Object

Definition at line 64 of file LDAPControl.cpp.

                               {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::getData()" << endl);
    return m_data;
}
string LDAPCtrl::getOID ( ) const
Returns:
The OID of the control

Definition at line 50 of file LDAPControl.cpp.

                             {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::getOID()" << endl);
    return m_oid;
}
bool LDAPCtrl::hasData ( ) const
Returns:
true if there is no "Control Value" (there is a difference between no and an empty control value)

Definition at line 60 of file LDAPControl.cpp.

                            {
    return !m_noData;
}
bool LDAPCtrl::isCritical ( ) const
Returns:
"true" if the control is critical

Definition at line 55 of file LDAPControl.cpp.

                               {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::isCritical()" << endl);
    return m_isCritical;
}

Member Data Documentation

std::string LDAPCtrl::m_data [private]

Definition at line 82 of file LDAPControl.h.

bool LDAPCtrl::m_isCritical [private]

Definition at line 83 of file LDAPControl.h.

bool LDAPCtrl::m_noData [private]

Definition at line 84 of file LDAPControl.h.

std::string LDAPCtrl::m_oid [private]

Definition at line 81 of file LDAPControl.h.


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