1 #ifndef OBJECT_PACKERS_CLASS
2 #define OBJECT_PACKERS_CLASS
123 template <
class contents>
126 for (
int i = 0; i < to_pack.
length(); i++) to_pack[i].
pack(packed_form);
130 template <
class contents>
137 if (!swappy_array.
observe())
return false;
138 for (
int i = 0; i < (int)len; i++) {
139 if (!swappy_array[i].
unpack(packed_form))
148 template <
class contents>
150 int to_return =
sizeof(int) * 2;
151 for (
int i = 0; i < to_pack.
length(); i++)
159 template <
class contents>
162 for (
int i = 0; i < to_pack.
length(); i++)
163 attach(packed_form, to_pack[i]);
169 template <
class contents>
175 if (!swappy_array.
observe())
return false;
176 for (
int i = 0; i < len; i++) {
177 if (!
detach(packed_form, swappy_array[i]))
Represents a sequential, ordered, contiguous collection of objects.
int flags() const
Provides the raw flags value, without interpreting what it means.
void reset(int number=0, const contents *initial_contents=NULL_POINTER)
Resizes this array and sets the contents from an array of contents.
const contents * observe() const
Returns a pointer to the underlying C array of data.
int length() const
Returns the current reported length of the allocated C array.
void swap_contents(array< contents > &other)
Exchanges the contents of "this" and "other".
A very common template for a dynamic array of bytes.
Constants and objects used throughout HOOPLE.
#define NULL_POINTER
The value representing a pointer to nothing.
unsigned char abyte
A fairly important unit which is seldom defined...
unsigned int un_int
Abbreviated name for unsigned integers.
unsigned short un_short
Abbreviated name for unsigned short integers.
A dynamic container class that holds any kind of object via pointers.
int packed_size_array(const basis::array< contents > &to_pack)
provides space estimation for the objects to be packed.
bool unpack(basis::byte_array &packed_form, set< contents > &to_unpack)
provides a way to unpack any set that stores packable objects.
bool obscure_detach(byte_array &packed_form, un_int &to_detach)
shifts the number back and checks validity, false returned if corrupted.
void obscure_attach(byte_array &packed_form, un_int to_attach)
like the normal attach but shifts in some recognizable sentinel data.
const int PACKED_SIZE_BYTE
bool unpack_simple(basis::byte_array &packed_form, basis::array< contents > &to_unpack)
Unpacks flat objects from an array of bytes.
void attach(byte_array &packed_form, const byte_array &to_attach)
Packs a byte_array "to_attach" into "packed_form".
const int PACKED_SIZE_INT16
bool unpack_array(basis::byte_array &packed_form, basis::array< contents > &to_unpack)
provides a way to unpack any array that stores packable objects.
void pack(basis::byte_array &packed_form, const set< contents > &to_pack)
provides a way to pack any set that stores packable objects.
void pack_simple(basis::byte_array &packed_form, const basis::array< contents > &to_pack)
Packs flat objects into an array of bytes.
const int PACKED_SIZE_INT64
const int PACKED_SIZE_INT32
void pack_array(basis::byte_array &packed_form, const basis::array< contents > &to_pack)
provides a way to pack any array that stores packable objects.
bool detach(byte_array &packed_form, byte_array &to_detach)
Unpacks a byte_array "to_detach" from "packed_form".
int packed_size(const byte_array &packed_form)
Reports the size required to pack a byte array into a byte array.