1 #ifndef BYTE_ARRAY_CLASS
2 #define BYTE_ARRAY_CLASS
63 if (!s2_cast)
throw "error: byte_array::==: unknown type";
68 if (!s2_cast)
throw "error: byte_array::<: unknown type";
115 template <
class contents>
120 template <
class contents>
123 if (
sizeof(detached) > source.
length())
return false;
124 detached = *(contents *)source.
observe();
125 source.
zap(0,
sizeof(detached) - 1);
Represents a sequential, ordered, contiguous collection of objects.
@ EXPONE
synonym for EXPONENTIAL_GROWTH.
@ SIMPLE_COPY
the contents can be memcpy'd and are not deep.
const abyte * observe() const
Returns a pointer to the underlying C array of data.
array & concatenate(const array &to_concatenate)
Appends the array "to_concatenate" onto "this" and returns "this".
int length() const
Returns the current reported length of the allocated C array.
outcome zap(int start, int end)
Deletes from "this" the objects inclusively between "start" and "end".
A very common template for a dynamic array of bytes.
byte_array(const byte_array &to_copy)
constructs an array bytes by copying the "to_copy" array.
DEFINE_CLASS_NAME("byte_array")
returns an array of zero bytes.
static const byte_array & empty_array()
virtual bool less_than(const orderable &s2) const
int comparator(const byte_array &s2) const
byte_array(int number=0, const abyte *initial_contents=NULL_POINTER)
constructs an array of "number" bytes from "initial_contents".
virtual bool equal_to(const equalizable &s2) const
byte_array(const array< abyte > &to_copy)
constructs an array bytes by copying the "to_copy" array.
Base class for object that can tell itself apart from other instances.
A base for objects that can be alphabetically (lexicographically) ordered.
A base class for objects that can pack into an array of bytes.
virtual int packed_size() const =0
Estimates the space needed for the packed structure.
virtual bool unpack(byte_array &packed_form)=0
Restores the packable from the "packed_form".
virtual void pack(byte_array &packed_form) const =0
Creates a packed form of the packable object in "packed_form".
Constants and objects used throughout HOOPLE.
#define NULL_POINTER
The value representing a pointer to nothing.
The guards collection helps in testing preconditions and reporting errors.
unsigned char abyte
A fairly important unit which is seldom defined...
bool detach_flat(byte_array &source, contents &detached)
detach_flat() pulls the "detached" object out of the array of bytes.
void attach_flat(byte_array &target, const contents &attachment)
attach_flat() places a copy of "attachment" onto the array of bytes.