X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/78ac68dcad2dc4582213848e8d1a98e3b16abff1..ce024cc2ec8438c906824afe3a634d928b5cf92e:/src/clave_fija.cpp?ds=sidebyside diff --git a/src/clave_fija.cpp b/src/clave_fija.cpp index 5a547eb..ea8c09e 100644 --- a/src/clave_fija.cpp +++ b/src/clave_fija.cpp @@ -10,18 +10,20 @@ ClaveFija::ClaveFija (int n) ClaveFija::ClaveFija (uchar *n) { memcpy (&data, n, sizeof(int)); + memcpy (&block_data, n+sizeof(int), sizeof(int)); } uint ClaveFija::Size () const { - return sizeof (int); + return sizeof (int)+sizeof(uint); } uchar *ClaveFija::ToArray () const { uchar *out; - out = new uchar[sizeof(int)]; + out = new uchar[Size ()]; memcpy (out, &data, sizeof(int)); + memcpy (out+sizeof (int), &block_data, sizeof(int)); return out; } @@ -36,3 +38,28 @@ bool ClaveFija::operator < (const Clave &c) const return data < ((ClaveFija&)c).data; } +bool ClaveFija::operator == (const Clave &c) const +{ + return data == ((ClaveFija&)c).data; +} + +uchar *ClaveFija::ToRaw (uint &size) const +{ + std::stringstream ss; + + ss << "["; + ss << 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; +} +