X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Fstructures%2Fobject_packers.h;h=91bee7a37012660158a2c3c3dc90710e4598f149;hb=aa7455f9107b309dde0f3088cb1be5c995e43600;hp=fecb78761032223bd4d4b26c323ba241de6ee791;hpb=3ea085ec301ed1399dfa1e9f3a240312dc95410b;p=feisty_meow.git diff --git a/nucleus/library/structures/object_packers.h b/nucleus/library/structures/object_packers.h index fecb7876..91bee7a3 100644 --- a/nucleus/library/structures/object_packers.h +++ b/nucleus/library/structures/object_packers.h @@ -25,6 +25,7 @@ namespace structures { const int PACKED_SIZE_BYTE = 1; const int PACKED_SIZE_INT16 = 2; const int PACKED_SIZE_INT32 = 4; +const int PACKED_SIZE_INT64 = 8; // these functions pack and unpack popular data types. @@ -70,6 +71,14 @@ void attach(basis::byte_array &packed_form, int to_attach); bool detach(basis::byte_array &packed_form, int &to_detach); //!< Unpacks an integer "to_attach" from "packed_form". +void attach(basis::byte_array &packed_form, long int to_attach); + //!< Packs an integer "to_attach" into "packed_form". + /*!< This method and the other simple numerical storage methods use a little + endian ordering of the bytes. They are platform independent with respect to + endianness and will reassemble the number properly on any platform. */ +bool detach(basis::byte_array &packed_form, long int &to_detach); + //!< Unpacks an integer "to_attach" from "packed_form". + void obscure_attach(basis::byte_array &packed_form, basis::un_int to_attach); //!< like the normal attach but shifts in some recognizable sentinel data. /*!< this is slightly more sure than a simple integer attachment. it can @@ -123,7 +132,7 @@ bool unpack_array(basis::byte_array &packed_form, basis::array &to_unp to_unpack.reset(); basis::un_int len; if (!obscure_detach(packed_form, len)) return false; - basis::array swappy_array(len, NIL, to_unpack.flags()); + basis::array swappy_array(len, NULL_POINTER, to_unpack.flags()); // we create an array of the specified length to see if it's tenable. if (!swappy_array.observe()) return false; // failed to allocate. for (int i = 0; i < (int)len; i++) { @@ -162,7 +171,7 @@ bool unpack_simple(basis::byte_array &packed_form, basis::array &to_un to_unpack.reset(); basis::un_int len; if (!obscure_detach(packed_form, len)) return false; - basis::array swappy_array(len, NIL, to_unpack.flags()); + basis::array swappy_array(len, NULL_POINTER, to_unpack.flags()); if (!swappy_array.observe()) return false; // failed to allocate. for (int i = 0; i < len; i++) { if (!detach(packed_form, swappy_array[i]))