+bool ClaveVariable::Abrev (ClaveVariable *c)
+{
+ if (c == NULL) return false;
+ int iguales = 0;
+ std::string resto;
+
+ resto = abreviar (c->data, data, iguales);
+
+ /* No hago nada si solo machea un caracter */
+ if (iguales < 2) return false;
+
+ std::stringstream ss;
+ ss << iguales;
+ ss << "|";
+ ss << resto;
+ data = ss.str ();
+
+ return true;
+}
+
+bool ClaveVariable::DesAbrev (ClaveVariable *c)
+{
+ if (c == NULL) return false;
+
+ int pos = data.find ("|");
+
+ /* No esta abreviada! */
+ if (pos <= 0) return false;
+
+ std::string siguales = data.substr (0, pos);
+ int iguales = atoi (siguales.c_str ());
+
+ std::string primera_parte = c->data.substr (0, iguales);
+ std::string segunda_parte = data.substr (pos+1, data.size () - pos - 1);
+
+ data = primera_parte + segunda_parte;
+
+ return true;
+}
+
+std::string ClaveVariable::abreviar(std::string &p, std::string &a, int &iguales)
+{
+ char *primera = (char *)p.c_str ();
+ char *actual = (char *)a.c_str ();
+
+ iguales = 0;
+ while (((*primera) != '\0') && ((*actual) != '\0')) {
+ if ((*primera) == (*actual)) {
+ primera++;
+ actual++;
+ iguales++;
+ } else {
+ /* No coinciden mas! */
+ break;
+ }
+ }
+
+ return std::string (actual);
+}
+
+uchar *ClaveVariable::ToRaw (uint &size) const
+{
+ 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;
+}
+