X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/031fcd433e233cf31c4ee732883940d9b8c8165a..5f25f8927d0670eabcbcb8ef1e71b7887c63b887:/src/clave_variable.cpp diff --git a/src/clave_variable.cpp b/src/clave_variable.cpp index c97b9d9..e4452b0 100644 --- a/src/clave_variable.cpp +++ b/src/clave_variable.cpp @@ -3,10 +3,9 @@ #include "clave_variable.h" #include -ClaveVariable::ClaveVariable (const std::string &s, uint bd) +ClaveVariable::ClaveVariable (const std::string &s) { data = s; - block_data = bd; } ClaveVariable::ClaveVariable (uchar *n) @@ -124,12 +123,24 @@ std::string ClaveVariable::abreviar(std::string &p, std::string &a, int &iguales uchar *ClaveVariable::ToRaw (uint &size) const { - uchar *out; - size = raw_data.size ()*sizeof (uchar)+sizeof (uint); - uint len = raw_data.size (); - out = new uchar[size]; - memcpy (out, &len, sizeof (uint)); - memcpy (out+sizeof(uint), raw_data.c_str (), raw_data.size ()*sizeof (uchar)); + std::stringstream ss; + + ss << "["; + ss << data.size (); + ss << "]"; + ss << "["; + ss << raw_data; + ss << "]"; + ss << "["; + ss << block_data; + ss << "]"; + + std::string s = ss.str (); + + uchar *out = new uchar[s.size ()]; + memcpy (out, s.c_str (), s.size ()); + + size = s.size (); return out; }