Commit cde66129 authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

- remove unneeded Copy-Constructor

- allow to create Controls with no value
parent c3d50a82
......@@ -10,13 +10,6 @@
using namespace std;
LDAPCtrl::LDAPCtrl(const LDAPCtrl& c){
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPCtrl::LDAPCtrl(&)" << endl);
m_oid=c.m_oid;
m_data=c.m_data;
m_isCritical=c.m_isCritical;
}
LDAPCtrl::LDAPCtrl(const char *oid, bool critical, const char* data,
int length){
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPCtrl::LDAPCtrl()" << endl);
......@@ -28,10 +21,10 @@ LDAPCtrl::LDAPCtrl(const char *oid, bool critical, const char* data,
m_data.assign(data,length);
}else{
m_data=string();
m_noData=true;
}
}
LDAPCtrl::LDAPCtrl(const string& oid, bool critical, const string& data){
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPCtrl::LDAPCtrl()" << endl);
DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
......@@ -39,6 +32,7 @@ LDAPCtrl::LDAPCtrl(const string& oid, bool critical, const string& data){
m_oid=oid;
m_isCritical=critical;
m_data=data;
m_noData=false;
}
LDAPCtrl::LDAPCtrl(const LDAPControl* ctrl){
......@@ -62,6 +56,10 @@ bool LDAPCtrl::isCritical()const {
return m_isCritical;
}
bool LDAPCtrl::hasData() const{
return !m_noData;
}
string LDAPCtrl::getData() const {
DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::getData()" << endl);
return m_data;
......@@ -73,9 +71,14 @@ LDAPControl* LDAPCtrl::getControlStruct() const {
ret->ldctl_oid= new char[m_oid.size() + 1];
m_oid.copy(ret->ldctl_oid,string::npos);
ret->ldctl_oid[m_oid.size()]=0;
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);
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;
}
......
......@@ -16,11 +16,6 @@
*/
class LDAPCtrl{
public :
/**
* Copy-constructor
*/
LDAPCtrl(const LDAPCtrl& c);
/**
* Constructor.
* @param oid: The Object Identifier of the Control
......@@ -29,7 +24,7 @@ class LDAPCtrl{
* @param data: If there is data for the control, put it here.
* @param length: The length of the data field
*/
LDAPCtrl(const char *oid, bool critical, const char *data=0,
LDAPCtrl(const char *oid, bool critical=false, const char *data=0,
int length=0);
/**
......@@ -39,8 +34,8 @@ class LDAPCtrl{
* critical by the server.
* @param data: If there is data for the control, put it here.
*/
LDAPCtrl(const std::string& oid, bool critical=false,
const std::string& data=std::string());
LDAPCtrl(const std::string& oid, bool critical,
const std::string& data);
/**
* Creates a copy of the Control that "ctrl is pointing to
......@@ -58,7 +53,13 @@ class LDAPCtrl{
std::string getOID() const;
/**
* @return The Data of the control as a std::string-Objekt
* @return true if there is no "Control Value" (there is a
* difference between no and an empty control value)
*/
bool hasData() const;
/**
* @return The Data of the control as a std::string-Object
*/
std::string getData() const;
......@@ -80,6 +81,7 @@ class LDAPCtrl{
std::string m_oid;
std::string m_data;
bool m_isCritical;
bool m_noData;
};
#endif //LDAP_CONTROL_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment