Commit 53eaca81 authored by Nicolas Michon's avatar Nicolas Michon

bellesip::Object marshalling now uses virtual toString() for easier debug and leaks analysis

parent d55bac08
......@@ -43,11 +43,8 @@ class BELLESIP_EXPORT Object {
Object();
Object *ref();
void unref();
virtual belle_sip_error_code marshal(char* buff, size_t buff_size, size_t *offset);
std::string toString()const{
std::string ret(belle_sip_object_to_string(&mObject));
return ret;
}
//Overrides should keep the size of toString() lower than BELLE_SIP_MAX_TO_STRING_SIZE
virtual std::string toString() const;
virtual Object *clone()const;
belle_sip_cpp_object_t *getCObject();
const belle_sip_cpp_object_t *getCObject()const;
......@@ -66,8 +63,7 @@ class BELLESIP_EXPORT Object {
private:
void init();
belle_sip_cpp_object_t mObject;
static belle_sip_cpp_object_t *sClone(belle_sip_cpp_object_t *);
static belle_sip_error_code sMarshal(belle_sip_cpp_object_t* obj, char* buff, size_t buff_size, size_t *offset);
belle_sip_error_code marshal(char* buff, size_t buff_size, size_t *offset);
};
/**
......
......@@ -69,11 +69,25 @@ void Object::unref(){
belle_sip_object_unref(&mObject);
}
std::string Object::toString() const {
std::ostringstream ss;
ss << "bellesip::Object. cObject(";
ss << static_cast<const void *>(&mObject);
ss << ")";
return ss.str();
}
belle_sip_error_code Object::marshal(char* buff, size_t buff_size, size_t *offset){
return mObject.vptr->get_parent()->marshal(&mObject, buff, buff_size, offset); /*default to belle_sip_object_t's implementation*/
std::string tmp = toString();
if (tmp.size() >= buff_size) {
return BELLE_SIP_BUFFER_OVERFLOW;
}
strncpy(buff, tmp.c_str(), buff_size);
*offset += tmp.size();
return BELLE_SIP_OK;
}
Object *Object::clone()const{
Object *Object::clone() const {
return new Object(*this);
}
......
Markdown is supported
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