libUTL++
utl::BinaryData Class Reference

Vector of bytes. More...

#include <BinaryData.h>

Inheritance diagram for utl::BinaryData:

Public Member Functions

 BinaryData (size_t size, size_t increment=1)
 Constructor. More...
 
 BinaryData (byte_t *array, size_t size, bool owner=true, size_t increment=1)
 Constructor. More...
 
virtual void serialize (Stream &stream, uint_t io, uint_t mode=ser_default)
 Serialize to or from a stream. More...
 
- Public Member Functions inherited from utl::Vector< byte_t >
 Vector (std::initializer_list< byte_t > list)
 Constructor. More...
 
 Vector (size_t size, size_t increment=1)
 Constructor. More...
 
 Vector (byte_t *array, size_t size, bool owner=true, size_t increment=1)
 Constructor. More...
 
virtual int compare (const Object &rhs) const
 Compare with another object. More...
 
virtual size_t innerAllocatedSize () const
 Get the "inner" allocated size. More...
 
bool isOwner () const
 Get the owner flag. More...
 
bool autoInit () const
 Get the autoInit flag. More...
 
const byte_tget () const
 Get the associated array. More...
 
byte_tget ()
 Get the associated array. More...
 
const byte_tget (size_t idx) const
 Get a const reference to the object at the given index. More...
 
const byte_tget (int idx) const
 get() with int parameter. More...
 
bool empty () const
 Is the sequence empty?
 
size_t length () const
 Get the size of the sequence. More...
 
size_t size () const
 Get the size of the sequence. More...
 
size_t increment () const
 Get the growth increment. More...
 
byte_tget (size_t idx)
 Get a reference to the object at the given index. More...
 
byte_tget (int idx)
 get() with int parameter. More...
 
void clear ()
 Empty the sequence. More...
 
void excise ()
 Empty the sequence, delete the allocated array (if isOwner()) and set it to nullptr. More...
 
void economize ()
 Make the allocation exactly large enough to contain the sequence. More...
 
virtual void steal (Object &rhs)
 "Steal" the internal representation from another instance. More...
 
virtual void copy (const Object &)
 Copy another instance. More...
 
void copy (size_t idx, const Vector< byte_t > &src, size_t srcBegin=0, size_t srcEnd=size_t_max)
 Copy (part of) another vector. More...
 
void copy (size_t idx, const byte_t *src, size_t srcBegin, size_t srcEnd)
 Copy (part of) the given sequence. More...
 
void copy (size_t idx, std::initializer_list< byte_t > list)
 Copy an initializer_list into this sequence. More...
 
void move (size_t idx, const Vector< byte_t > &src, size_t srcBegin=0, size_t srcEnd=size_t_max)
 Move (part of) another vector. More...
 
void move (size_t idx, byte_t *src, size_t srcBegin, size_t srcEnd)
 Move (part of) the given sequence. More...
 
void setOwner (bool owner)
 Set the ownership flag. More...
 
void assertOwner ()
 Ensure that self owns the allocation. More...
 
void assertOwner (size_t allocSize)
 Ensure that self owns the allocation. More...
 
void assertOwner (size_t allocSize, size_t increment)
 Ensure that self owns the allocation. More...
 
void setSize (size_t size)
 Set the size of the sequence. More...
 
void grow (size_t size)
 Ensure the sequence is no smaller than the given size. More...
 
void grow (size_t size, size_t increment)
 Ensure the sequence is no smaller than the given size. More...
 
void reserve (size_t allocSize)
 Reserve allocation space. More...
 
void reserve (size_t allocSize, size_t increment)
 Reserve allocation space. More...
 
void setAutoInit (bool autoInit)
 Set the autoInit flag. More...
 
void append (const byte_t &val)
 Append an object to the sequence. More...
 
void append (const Vector< byte_t > &v)
 Append another sequence to this one. More...
 
void append (const byte_t *array, size_t arraySize)
 Append another sequence to this one. More...
 
void append (std::initializer_list< byte_t > list)
 Append another sequence to this one. More...
 
void insert (size_t idx, size_t num)
 Insert uninitialized objects in the range [idx,idx+num). More...
 
void insert (size_t idx, size_t num, const byte_t &val)
 Insert objects into the sequence. More...
 
void insert (size_t idx, size_t num, const byte_t *val)
 Insert objects into the sequence. More...
 
void insert (size_t idx, const byte_t *array, size_t arraySize)
 Insert another sequence into this one. More...
 
void insert (size_t idx, std::initializer_list< byte_t > list)
 Insert another sequence into this one. More...
 
void remove (size_t idx, size_t num)
 Remove objects from the sequence. More...
 
void relocate (size_t destIdx, size_t srcIdx)
 Relocate one object within the sequence. More...
 
void reverse (size_t idx, size_t num)
 Reverse the order of the objects in the sequence. More...
 
void set (byte_t *array, size_t size)
 clear(), then set the given array/size. More...
 
void set (byte_t *array, size_t size, bool owner, size_t increment)
 clear(), then set the given array/size and owner flag. More...
 
void set (const byte_t &val)
 Assign val to all objects in the sequence. More...
 
void set (size_t idx, size_t num, const byte_t &val)
 Assign a value to objects in the sequence. More...
 
void set (size_t idx, const byte_t &val)
 Set the value of the object at the given index. More...
 
void setIncrement (size_t increment)
 Set the growth increment. More...
 
void swap (size_t i, size_t j)
 Swap the objects at the given indexes. More...
 
void swap (size_t i, size_t j, size_t n)
 Swap the sub-arrays described by the index ranges [i, i + n) and [j, j + n).
 
const_iterator begin () const
 Get begin iterator (const version). More...
 
iterator begin ()
 Get begin iterator. More...
 
const_iterator end () const
 Get end iterator (const version). More...
 
iterator end ()
 Get end iterator. More...
 
const_iterator cbegin ()
 Get begin iterator (const version). More...
 
const_iterator cend ()
 Get end iterator (const version). More...
 
size_t indexOf (const_iterator it) const
 Convert iterator to index. More...
 
size_t indexOf (iterator it)
 Convert iterator to index. More...
 
byte_toperator[] (size_t idx)
 Array access operator. More...
 
const byte_toperator[] (size_t idx) const
 Array access operator. More...
 
byte_toperator[] (int idx)
 Same as above, but takes an int parameter. More...
 
const byte_toperator[] (int idx) const
 Same as above, but takes an int parameter. More...
 
 operator const byte_t * () const
 Conversion to const T*. More...
 
 operator const byte_t * ()
 Conversion to const T*. More...
 
 operator byte_t * ()
 Conversion to T*. More...
 
 operator const void * () const
 Conversion to const void*. More...
 
 operator const void * ()
 Conversion to const void*. More...
 
 operator void * ()
 Conversion to void*. More...
 
byte_toperator+ (ssize_t n)
 Pointer addition (ssize_t argument). More...
 
const byte_toperator+ (ssize_t n) const
 Pointer addition (ssize_t argument). More...
 
byte_toperator+ (size_t n)
 Pointer addition (size_t argument). More...
 
const byte_toperator+ (size_t n) const
 Pointer addition (size_t argument). More...
 
- Public Member Functions inherited from utl::Object
void clear ()
 Revert to initial state. More...
 
virtual void vclone (const Object &rhs)
 Make an exact copy of another instance. More...
 
virtual void dump (Stream &os, uint_t level=uint_t_max) const
 Dump a human-readable representation of self to the given output stream. More...
 
void dumpWithClassName (Stream &os, uint_t indent=4, uint_t level=uint_t_max) const
 Front-end for dump() that prints the object's class name. More...
 
virtual const ObjectgetKey () const
 Get the key for this object. More...
 
bool hasKey () const
 Determine whether or not the object has a key. More...
 
virtual const ObjectgetProxiedObject () const
 Get the proxied object (= self if none). More...
 
virtual ObjectgetProxiedObject ()
 Get the proxied object (= self if none). More...
 
virtual size_t hash (size_t size) const
 Get the hash code for the object. More...
 
bool _isA (const RunTimeClass *runTimeClass) const
 Determine whether self's class is a descendent of the given class. More...
 
virtual String toString () const
 Return a string representation of self. More...
 
 operator String () const
 Conversion to String. More...
 
size_t allocatedSize () const
 Get the total allocated size of this object. More...
 
virtual void addOwnedIt (const class FwdIt *it) const
 Notify self that it owns the given iterator. More...
 
virtual void removeOwnedIt (const class FwdIt *it) const
 Notify self that the given owned iterator has been destroyed. More...
 
bool operator< (const Object &rhs) const
 Less-than operator. More...
 
bool operator<= (const Object &rhs) const
 Less-than-or-equal-to operator. More...
 
bool operator> (const Object &rhs) const
 Greater-than operator. More...
 
bool operator>= (const Object &rhs) const
 Greater-than-or-equal-to operator. More...
 
bool operator== (const Object &rhs) const
 Equal-to operator. More...
 
bool operator!= (const Object &rhs) const
 Unequal-to operator. More...
 
void serializeIn (Stream &is, uint_t mode=ser_default)
 Serialize from an input stream. More...
 
void serializeOut (Stream &os, uint_t mode=ser_default) const
 Serialize to an output stream. More...
 
void serializeOutBoxed (Stream &os, uint_t mode=ser_default) const
 Serialize a boxed object to an output stream. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from utl::Object
static ObjectserializeInNullable (Stream &is, uint_t mode=ser_default)
 Serialize a nullptr-able object from an input stream. More...
 
static void serializeOutNullable (const Object *object, Stream &os, uint_t mode=ser_default)
 Serialize a nullptr-able object to an output stream. More...
 
static void serializeNullable (Object *&object, Stream &stream, uint_t io, uint_t mode=ser_default)
 Serialize a nullptr-able object to or from a stream. More...
 
static ObjectserializeInBoxed (Stream &is, uint_t mode=ser_default)
 Serialize a boxed object from an input stream. More...
 
static void serializeBoxed (Object *&object, Stream &stream, uint_t io, uint_t mode=ser_default)
 Serialize a boxed object to or from a stream. More...
 
- Protected Member Functions inherited from utl::FlagsMI
 FlagsMI ()
 Constructor. More...
 
virtual ~FlagsMI ()
 Destructor. More...
 
void copyFlags (const FlagsMI &rhs)
 Copy the given flags. More...
 
void copyFlags (const FlagsMI &rhs, uint_t lsb, uint_t msb)
 Copy (some of) the given flags. More...
 
void copyFlags (uint64_t flags, uint_t lsb, uint_t msb)
 Copy (some of) the given flags. More...
 
bool getFlag (uint_t flagNum) const
 Get a user-defined flag. More...
 
void setFlag (uint_t flagNum, bool val)
 Set a user-defined flag. More...
 
uint64_t getFlagsNumber (uint64_t mask, uint64_t shift=0)
 Get a multi-bit value in the flags data (which is stored as one 64-bit integer). More...
 
void setFlagsNumber (uint64_t mask, uint64_t shift, uint64_t num)
 Set a multi-bit value in the flags data (which is stored as one 64-bit integer). More...
 
uint64_t getFlags () const
 Get the flags. More...
 
void setFlags (uint64_t flags)
 Set the flags. More...
 

Detailed Description

Vector of bytes.

Author
Adam McKee

Definition at line 22 of file BinaryData.h.

Constructor & Destructor Documentation

◆ BinaryData() [1/2]

utl::BinaryData::BinaryData ( size_t  size,
size_t  increment = 1 
)
inline

Constructor.

Parameters
sizearray size
increment(optional : size_t_max) growth increment

Definition at line 32 of file BinaryData.h.

◆ BinaryData() [2/2]

utl::BinaryData::BinaryData ( byte_t array,
size_t  size,
bool  owner = true,
size_t  increment = 1 
)
inline

Constructor.

Parameters
arrayassociated array
sizearray size
owner(optional : true) owner flag
increment(optional : size_t_max) growth increment

Definition at line 44 of file BinaryData.h.

References utl::deInit(), utl::init(), utl::ser_default, and utl::serialize().

Member Function Documentation

◆ serialize()

virtual void utl::BinaryData::serialize ( Stream stream,
uint_t  io,
uint_t  mode = ser_default 
)
virtual

Serialize to or from a stream.

This is the only virtual method for serialization. You must override this in any class that has data to be serialized, and ensure that the superclass's serialize() gets called.

Parameters
streamstream to serialize from/to
iosee utl::io_t
modesee utl::serialize_t

Reimplemented from utl::Vector< byte_t >.


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