Index

DKByteArray

Purpose:

The DKByteArray provides a class to represent binary byte data.

Class summary:

class DKEXPORT DKByteArray
 {
   public:
         DKByteArray();
         DKByteArray(char* data, long length);
         DKByteArray(const DKByteArray& byteArray);
         virtual ~DKByteArray();
         DKByteArray& operator=  (const DKByteArray& byteArray);
         DKBoolean operator== (const DKByteArray& byteArray) const;
         DKBoolean operator!= (const DKByteArray& byteArray) const;
         friend DKEXPORT ostream& operator << (ostream& outStream, const
         DKByteArray& byteArray);
         long  length();
         char* getData();
         void  setData(char* data, long length);
         };

Members:

Constructors and Destructor

DKByteArray()
Default constructor for the DKByteArray class. Constructs and initializes the object.

DKByteArray(char* data, long length)
Constructs and initializes a DKByteArray object with the data. The data passed in should be a valid pointer of length greater than zero.

Parameters:

data
A non null pointer to a character string which is at least one character.

length
A long value specifying the length of the character string pointed by data.

DKByteArray(const DKByteArray& byteArray)
Copy constructor for the DKByteArray class. Creates a new object and copies the data in the specified object.

Parameters:

byteArray
A reference to a DKByteArray object which is to be copied.

DKByteArray(char* data, long length, short flag)
Constructs and initializes a DKByteArray object with the data specified.

Parameters:

data
A non null pointer to a character string which is at least one character. The data passed in should be a valid pointer of length greater than zero.

length
A long value specifying the length of the character string pointed by data.

flag
Memory allocation flag. If 0, new storage is allocated for the data and the specified data is passed in. If 1, new storage is not allocated and assumes that the storage is allocated by the caller. The storage allocated for data is absorbed.
Important: This storage should not be freed by the caller. This storage is freed by this object upon desctruction.

virtual ~DKByteArray()
Destructor for the DKByteArray object. Frees the storage allocated for the data.

Operators

operator=
The DKByteArray assignment operator reinitialized this object with the data from the source object. The source object is a DKByteArray object.
DKByteArray& operator=  (const DKByteArray& byteArray);

operator==
The DKByteArray comparison operator compares two DKByteArray objects. If the two objects are equal it returns TRUE else it returns FALSE.
DKBoolean operator== (const DKByteArray& byteArray) const;

operator+=
The DKByteArray compound addition and assignment operator adds the contents of the input byte array to this byte array and assigns the result to this byte array. The input byte array object is a DKByteArray object.
DKBoolean operator+= (const DKByteArray& byteArray);

operator!=
Checks to see if byte arrays are not equal. Returns TRUE if the they are not equal else it returns FALSE.
DKBoolean operator!= (const DKByteArray& byteArray) const;

operator<<
The DKByteArray insertion operator to dump or store the byte array data.

Member Functions

asString
Returns a DKString object that contains the data from the byte array.

length
Returns the length of the byte array.

getData
Gets the pointer to the byte array data.
Returns:
The pointer to the byte array data.
char* getData();

setData
Sets the binary data of byte array
Parameters:

data
The binary data that is to be set in the byte array.

length
Length of the binary data.


void setData(char* data, long length);

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.