SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions
RWDBBinaryCallback Class Referenceabstract

Base class for user-defined callback methods that fetch and send binary data. More...

#include <rw/db/datacb.h>

Inheritance diagram for RWDBBinaryCallback:
RWDBDataCallback

Public Member Functions

 RWDBBinaryCallback (size_t entries=1)
 
 RWDBBinaryCallback (const RWDBBinaryCallback &cb)
 
virtual ~RWDBBinaryCallback ()
 
virtual bool onFetch (size_t rownum, const void *theData, size_t byteLength, RWDBNullIndicator ni, bool &lastPiece)=0
 
virtual bool onSend (size_t rownum, void *theData, size_t &byteLength, RWDBNullIndicator &ni, bool &lastPiece)=0
 
RWDBBinaryCallbackoperator= (const RWDBBinaryCallback &cb)
 
- Public Member Functions inherited from RWDBDataCallback
size_t entries () const
 
virtual size_t getLength (size_t rownum) const
 

Detailed Description

RWDBBinaryCallback is a base class for user-defined callback methods for binary data. Derive from this class to implement the callback methods to send and retrieve binary data.

Example
Please see the example in the entry for RWDBDataCallback.

Constructor & Destructor Documentation

RWDBBinaryCallback::RWDBBinaryCallback ( size_t  entries = 1)
inline

Constructs an RWDBBinaryCallback with entries entries. If entries is more than one, array binding is in effect. Please see the DB Interface Module User's Guide chapter "Bulk/Array Input", in the section "Using the Open SQL Classes", for more information.

RWDBBinaryCallback::RWDBBinaryCallback ( const RWDBBinaryCallback cb)
inline

Copy constructor.

virtual RWDBBinaryCallback::~RWDBBinaryCallback ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

virtual bool RWDBBinaryCallback::onFetch ( size_t  rownum,
const void *  theData,
size_t  byteLength,
RWDBNullIndicator  ni,
bool &  lastPiece 
)
pure virtual

When data callback classes are bound to a SQL statement and RWDBOSql::fetch() is called to fetch the results, this method is invoked to receive the data.

Parameters
rownumThe row in the current rowset this data is from (0-based indexing). Each call to RWDBOSql::fetch() retrieves the next rowset from the result set of the SQL statement execution. This method is invoked by the Access Module as many times as needed for each row in the rowset.
theDataA pointer to an array containing the fetched data. The contents of theData are undefined if ni is true.
byteLengthThe length in bytes of the data in theData, if any.
niThe null indicator parameter. true if the fetched value is null, false otherwise.
lastPiecetrue if this is the last piece of data for this value, otherwise it is false. This parameter can be set to true by the callee to stop fetching data for this row's value and to move to the next row.
Returns
Return false or throw an exception from this method to stop fetching data and terminate the operation, otherwise return true to continue.
virtual bool RWDBBinaryCallback::onSend ( size_t  rownum,
void *  theData,
size_t &  byteLength,
RWDBNullIndicator ni,
bool &  lastPiece 
)
pure virtual

When data callback classes are bound to a SQL statement and RWDBOSql::execute() is called to execute the statement this method is invoked as needed to supply the data to send to the database. Note that the method RWDBDataCallback::getLength() may need to be be implemented in the derived class to send data to the database.

Parameters
rownumThe row for which data is needed (0-based indexing). This will always be 0 unless array binding is used. Array binding is in effect when the callback is constructed with entries greater than 1. Please see the DB Interface Module User's Guide chapter "Bulk/Array Input", in the section "Using the Open SQL Classes", for more information.
theDataA pointer to an array where the callee should put the data to be sent. If ni is true this parameter is ignored.
byteLengthThe size of theData in bytes and should be set by the callee to the length in bytes written to theData. If ni is true this parameter is ignored.
niSet this to true to indicate that a null value is being sent to the database. If ni is true, theData, lastPiece, and byteLength are ignored.
lastPieceWhen the last piece of data for rownum is being supplied this must be set to true. This parameter is ignored if ni is true.
Returns
Return false or throw an exception to stop sending data and terminate the operation, otherwise return true.
RWDBBinaryCallback& RWDBBinaryCallback::operator= ( const RWDBBinaryCallback cb)
inline

Assignment operator.

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.