ImqBinary

Figure 4. ImqBinary class

A Booch class diagram showing the ImqBinary class and its parent class, ImqItem.

This class encapsulates a binary byte array that can be used for ImqMessage accounting token, correlation id, and message id values. It allows easy assignment, copying, and comparison.

Other relevant classes

ImqItem (see ImqItem)

ImqMessage (see ImqMessage)

Object attributes

data
An array of bytes of binary data. The initial value is null.

data length
The number of bytes. The initial value is zero.

data pointer
The address of the first byte of the data. The initial value is zero.

Constructors

ImqBinary( );
The default constructor.

ImqBinary( const ImqBinary & binary );
The copy constructor.

ImqBinary( const void * data, const size_t length );
Copies length bytes from data.

Overloaded "ImqItem" methods

virtual ImqBoolean copyOut( ImqMessage & msg );
Copies the data to the message buffer, replacing any existing content. Sets the msg format to MQFMT_NONE.

See the ImqItem class method description for further details.

virtual ImqBoolean pasteIn( ImqMessage & msg );
Sets the data by transferring the remaining data from the message buffer, replacing the existing data.

To be successful, the ImqMessage format must be MQFMT_NONE.

See the ImqItem class method description for further details.

Object methods (public)

void operator = ( const ImqBinary & binary );
Copies bytes from binary.

ImqBoolean operator == ( const ImqBinary & binary );
Compares this object with binary. It returns FALSE if not equal and TRUE otherwise. The objects are equal if they have the same data length and the bytes match.

ImqBoolean copyOut( void * buffer, const size_t length, const char pad = 0 );
Copies up to length bytes from the data pointer to buffer. If the data length is insufficient, the remaining space in buffer is filled with pad bytes. buffer may be zero if length is also zero. length must not be negative. It returns TRUE if successful.

size_t dataLength( ) const ;
Returns the data length.

ImqBoolean setDataLength( const size_t length );
Sets the data length. If the data length is changed as a result of this method, the data in the object is uninitialized. It returns TRUE if successful.

void * dataPointer( ) const ;
Returns the data pointer.

ImqBoolean isNull( ) const ;
Returns TRUE if the data length is zero, or if all of the data bytes are zero. Otherwise it returns FALSE.

ImqBoolean set( const void * buffer, const size_t length );
Copies length bytes from buffer. It returns TRUE if successful.

Object methods (protected)

void clear( );
Reduces the data length to zero.

Reason codes

MQRC_NO_BUFFER

MQRC_STORAGE_NOT_AVAILABLE

MQRC_INCONSISTENT_FORMAT



© IBM Corporation 2001. All Rights Reserved