Page 21 out of 26 total pages


QbStringClass


QbStringClass is a utility class that is not derived from any other class. It performs string functions and related memory management. The class contains a set of overloaded operators to allow the object to be cast to either an unsigned char or char variable type.

In this class, the += operator has been overloaded to concatenate two QbString objects.

This chapter describes the following methods:

QbStringClass method

This is the constructor for the class. This method has overloaded functions. Depending on which function you use, the length of the object's internal buffer is the same as the length of the input string, or is a size you specify. The second argument indicates that the memory of the internal buffer is cleared when the object is destroyed.

Syntax

QbStringClass( const char * string, Boolean destructorDeleteArg = True 
)

QbStringClass( const unsigned long size, Boolean destructorDeleteArg = 
True )

Parameters

Input

Output

None

~QbStringClass method

This is the destructor for the class.

Syntax

virtual ~QbStringClass( void )

Parameters

None

EncodeAndConcat method

This method encodes the input string to a hexadecimal representation and appends the result to the internal buffer of the object.

Syntax

int EncodeAndConcat ( const unsigned char *input, const unsigned long 
size )

Parameters

Input

Output

An integer value: 0 indicates success; -1 indicates failure

GetSize method

This method returns the size of the object's internal buffer that holds the string.

Syntax

unsigned long GetSize( void )

Parameters

Input

None

Output

An unsigned long integer that represents the size of the object's internal buffer

IsOk method

This method returns a Boolean value that indicates the current state of the object. Any operation that requires memory, such as the += operator, could fail and leave the object in an "unhealthy" state.

Syntax

Boolean IsOK( void )

Parameters

Input

None

Output

A Boolean value: True means the object is "healthy"; False means the object experienced a memory allocation error

SetDestructorDelete method

This method indicates whether the destructor should delete the internal buffer. This method overrides what you specify in the class constructor for destructorDeleteArg.

Syntax

void SetDestructorDelete( Boolean destructorDeleteArg )

Parameters

Input

destructorDeleteArg-A Boolean value: True indicates that the destructor will delete the buffer; False indicates that it will not.

Output

None




Page 21 out of 26 total pages


xzhu@almaden.ibm.com or tedl@almaden.ibm.com
Copyright © 1998, IBM Corporation. All rights reserved.