X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/1b6152a8b901df0e8b57c35b9846a6e609b8b7df..59b7476481f01388fcfd13492adbba7ef841755c:/src/clave_fija.cpp?ds=inline diff --git a/src/clave_fija.cpp b/src/clave_fija.cpp index 05c9814..71f6f0d 100644 --- a/src/clave_fija.cpp +++ b/src/clave_fija.cpp @@ -2,16 +2,51 @@ #include #include "clave_fija.h" -uint ClaveFija::Size () +ClaveFija::ClaveFija (int n, uint bd) { - return sizeof (int); + data = n; + block_data = bd; } -uchar *ClaveFija::ToArray () +ClaveFija::ClaveFija (uchar *n) +{ + memcpy (&data, n, sizeof(int)); + memcpy (&block_data, n+sizeof(int), sizeof(int)); +} + +uint ClaveFija::Size () const +{ + 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; } +Clave *ClaveFija::Clone () const +{ + ClaveFija *k = new ClaveFija (*this); + return k; +} + +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 +{ + size = Size (); + return ToArray (); +} +