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);
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,
m_oid=oid;
m_isCritical=critical;
m_data=data;
+ m_noData=false;
}
LDAPCtrl::LDAPCtrl(const LDAPControl* ctrl){
return m_isCritical;
}
+bool LDAPCtrl::hasData() const{
+ return !m_noData;
+}
+
string LDAPCtrl::getData() const {
DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::getData()" << endl);
return m_data;
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;
}
*/
class LDAPCtrl{
public :
- /**
- * Copy-constructor
- */
- LDAPCtrl(const LDAPCtrl& c);
-
/**
* Constructor.
* @param oid: The Object Identifier of the Control
* @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);
/**
* 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
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;
std::string m_oid;
std::string m_data;
bool m_isCritical;
+ bool m_noData;
};
#endif //LDAP_CONTROL_H