str[len] = '\0';
data = std::string ((const char *)(str));
delete [] str;
+ raw_data = data;
}
uint ClaveVariable::Size () const
{
- return data.size ()+sizeof (uint);
+ return data.size ()*sizeof (uchar)+sizeof (uint);
}
uchar *ClaveVariable::ToArray () const
uint len = data.size ();
out = new uchar[Size ()];
memcpy (out, &len, sizeof (uint));
- memcpy (out+sizeof(uint), data.c_str (), data.size ());
+ memcpy (out+sizeof(uint), data.c_str (), data.size ()*sizeof (uchar));
return out;
}
if (pos <= 0) return false;
std::string siguales = data.substr (0, pos);
- std::cout << siguales << std::endl;
int iguales = atoi (siguales.c_str ());
std::string primera_parte = c->data.substr (0, iguales);
return std::string (actual);
}
+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));
+ return out;
+}
+