feisty meow concerns codebase  2.140
basis::byte_array Class Reference

A very common template for a dynamic array of bytes. More...

#include <byte_array.h>

Inheritance diagram for basis::byte_array:
Collaboration diagram for basis::byte_array:

Public Member Functions

 byte_array (int number=0, const abyte *initial_contents=NULL_POINTER)
 constructs an array of "number" bytes from "initial_contents". More...
 
 byte_array (const byte_array &to_copy)
 constructs an array bytes by copying the "to_copy" array. More...
 
 byte_array (const array< abyte > &to_copy)
 constructs an array bytes by copying the "to_copy" array. More...
 
virtual ~byte_array ()
 
 DEFINE_CLASS_NAME ("byte_array")
 returns an array of zero bytes. More...
 
virtual bool equal_to (const equalizable &s2) const
 
virtual bool less_than (const orderable &s2) const
 
int comparator (const byte_array &s2) const
 
- Public Member Functions inherited from basis::array< abyte >
 DEFINE_CLASS_NAME ("array")
 
 array (int number=0, const abyte *init=NULL_POINTER, int flags=EXPONENTIAL_GROWTH|FLUSH_INVISIBLE)
 Constructs an array with room for "number" objects. More...
 
 array (const array< abyte > &copy_from)
 copies the contents & sizing information from "copy_from". More...
 
virtual ~array ()
 destroys the memory allocated for the objects. More...
 
void reset (int number=0, const abyte *initial_contents=NULL_POINTER)
 Resizes this array and sets the contents from an array of contents. More...
 
arrayoperator= (const array< abyte > &copy_from)
 Copies the array in "copy_from" into this. More...
 
int length () const
 Returns the current reported length of the allocated C array. More...
 
int last () const
 Returns the last valid element in the array. More...
 
int flags () const
 Provides the raw flags value, without interpreting what it means. More...
 
bool exponential () const
 Returns true if this allocator will grow exponentially on resize. More...
 
bool simple () const
 Reports whether the templated object is a simple type or not. More...
 
const abyteget (int index) const
 Accesses individual objects stored in "this" at the "index" position. More...
 
abyteuse (int index)
 A non-constant version of get(); the returned object can be modified. More...
 
const abyteoperator[] (int index) const
 Synonym for get that provides the expected array indexing syntax. More...
 
abyteoperator[] (int index)
 Synonym for use that provides the expected array indexing syntax. More...
 
outcome put (int index, const abyte &to_put)
 Stores an object at the index "index" in the array. More...
 
array concatenation (const array &to_concatenate) const
 Returns the concatenation of "this" and the array "to_concatenate". More...
 
array concatenation (const abyte &to_concatenate) const
 Returns the concatenation of "this" and the object "to_concatenate". More...
 
arrayconcatenate (const array &to_concatenate)
 Appends the array "to_concatenate" onto "this" and returns "this". More...
 
arrayconcatenate (const abyte &to_concatenate)
 Appends the object "to_concatenate" onto "this" and returns "this". More...
 
arrayconcatenate (const abyte *to_concatenate, int length)
 Concatenates a C-array "to_concatenate" onto "this" and returns "this". More...
 
array operator+ (const array &to_cat) const
 Synonym for concatenation. More...
 
array operator+ (const abyte &to_concatenate) const
 Synonym for concatenation. More...
 
arrayoperator+= (const array &to_concatenate)
 Synonym for concatenate that modifies "this". More...
 
arrayoperator+= (const abyte &to_concatenate)
 Synonym for concatenate that modifies "this". More...
 
const abyteobserve () const
 Returns a pointer to the underlying C array of data. More...
 
abyteaccess ()
 A non-constant access of the underlying C-array. BE REALLY CAREFUL. More...
 
void swap_contents (array< abyte > &other)
 Exchanges the contents of "this" and "other". More...
 
void snarf (array &new_contents)
 Drops "this" array's contents into the dustbin and uses "new_contents". More...
 
array subarray (int start, int end) const
 Returns the array segment between the indices "start" and "end". More...
 
outcome insert (int index, int new_indices)
 Adds "new_indices" new positions for objects into the array at "index". More...
 
outcome overwrite (int index, const array &write_with, int count=-1)
 Stores the array "write_with" into the current array at the "index". More...
 
outcome stuff (int length, abyte *to_stuff) const
 Copies at most "length" elements from this into the array "to_stuff". More...
 
outcome resize (int new_size, how_to_copy way=NEW_AT_END)
 Changes the size of the C array to "new_size". More...
 
outcome zap (int start, int end)
 Deletes from "this" the objects inclusively between "start" and "end". More...
 
outcome shrink ()
 Cuts loose any allocated space that is beyond the real length. More...
 
outcome retrain (int new_size, const abyte *to_copy)
 Resizes the C array and stuffs it with the contents in "to_copy". More...
 
void shift_data (shift_directions where)
 The valid portion of the array is moved to the left or right. More...
 
int internal_real_length () const
 Gritty Internal: the real allocated length. More...
 
int internal_offset () const
 Gritty Internal: the offset from real start to stored data. More...
 
const abyteinternal_block_start () const
 Gritty Internal: constant peek at the real allocated pointer. More...
 
abyteinternal_block_start ()
 Gritty Internal: the real allocated pointer made accessible. More...
 
abyte *const * internal_offset_mem () const
 Gritty Internal: the start of the actual stored data. More...
 
- Public Member Functions inherited from basis::orderable
virtual bool operator< (const orderable &s2) const
 the virtual method for object ordering. More...
 
- Public Member Functions inherited from basis::equalizable
virtual bool operator== (const equalizable &s2) const
 the virtual method for object equality. More...
 

Static Public Member Functions

static const byte_arrayempty_array ()
 

Additional Inherited Members

- Public Types inherited from basis::array< abyte >
enum  specialc_flags
 the flags specify how the array treats its contents and its length. More...
 
enum  how_to_copy
 
enum  shift_directions
 

Detailed Description

A very common template for a dynamic array of bytes.

byte_array provides a simple wrapper around array<byte>, but with the exponential growth and simple copy modes automatically enabled. Note that it is almost always best to forward declare byte_arrays in ones own headers rather than including this header.

Definition at line 35 of file byte_array.h.

Constructor & Destructor Documentation

◆ byte_array() [1/3]

basis::byte_array::byte_array ( int  number = 0,
const abyte initial_contents = NULL_POINTER 
)
inline

constructs an array of "number" bytes from "initial_contents".

Definition at line 38 of file byte_array.h.

◆ byte_array() [2/3]

basis::byte_array::byte_array ( const byte_array to_copy)
inline

constructs an array bytes by copying the "to_copy" array.

Definition at line 42 of file byte_array.h.

◆ byte_array() [3/3]

basis::byte_array::byte_array ( const array< abyte > &  to_copy)
inline

constructs an array bytes by copying the "to_copy" array.

Definition at line 46 of file byte_array.h.

◆ ~byte_array()

virtual basis::byte_array::~byte_array ( )
inlinevirtual

Definition at line 49 of file byte_array.h.

Member Function Documentation

◆ comparator()

int basis::byte_array::comparator ( const byte_array s2) const
inline

◆ DEFINE_CLASS_NAME()

basis::byte_array::DEFINE_CLASS_NAME ( "byte_array"  )

returns an array of zero bytes.

note that this is implemented in the opsystem library to avoid bad issues with static objects mixed into multiple dlls from a static library.

◆ empty_array()

static const byte_array& basis::byte_array::empty_array ( )
inlinestatic

Definition at line 57 of file byte_array.h.

◆ equal_to()

virtual bool basis::byte_array::equal_to ( const equalizable s2) const
inlinevirtual

Implements basis::equalizable.

Definition at line 61 of file byte_array.h.

References comparator().

◆ less_than()

virtual bool basis::byte_array::less_than ( const orderable s2) const
inlinevirtual

Implements basis::orderable.

Definition at line 66 of file byte_array.h.

References comparator().


The documentation for this class was generated from the following file: