SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWDBMultiRow Class Reference

Provides a mechanism by which a collection of bindable objects can be used with the RWDBValue and RWDBRow interface. More...

#include <rw/db/multirow.h>

Public Member Functions

 RWDBMultiRow ()
 
 RWDBMultiRow (const RWDBMultiRow &rhs)
 
 RWDBMultiRow (const RWDBSchema &s, size_t rows=1)
 
 ~RWDBMultiRow ()
 
void append (RWDBAbstractBuffer *item, bool ownership=true)
 
void append (RWDBDataCallback *item, bool ownership=true)
 
RWDBAbstractBufferbufferAt (size_t index) const
 
size_t entries () const
 
size_t numberOfColumns () const
 
RWDBMultiRowoperator= (const RWDBMultiRow &r)
 
RWDBMultiRowoperator>> (RWDBAbstractBuffer &b)
 
RWDBMultiRowoperator>> (RWDBDataCallback &b)
 
RWDBRow operator[] (size_t i) const
 
RWDBSchema schema () const
 

Detailed Description

Class RWDBMultiRow provides a mechanism by which a collection of bindable objects can be used with the RWDBValue and RWDBRow interface. These bindable objects are subclasses of RWDBAbstractBuffer, typically RWDBTBuffer objects, and subclasses of RWDBDataCallback. They can be manually created and appended to the RWDBMultiRow, or the RWDBMultiRow can create appropriate RWDBAbstractBuffer objects when given an RWDBSchema.

Synopsis
#include <rw/db/multirow.h>
Example
Please see Example 2 in the entry for RWDBOSql.

Constructor & Destructor Documentation

RWDBMultiRow::RWDBMultiRow ( )

Default constructor. Creates an RWDBMultiRow with no bindable objects or ownership indicators; in other words, an empty instance. Internally, RWDBMultiRow is a handle class that refers to a body that contains the state. The constructor creates a new implementation object for the body.

RWDBMultiRow::RWDBMultiRow ( const RWDBMultiRow rhs)

Copy constructor. Creates an RWDBMultiRow that shares an implementation with rhs.

RWDBMultiRow::RWDBMultiRow ( const RWDBSchema s,
size_t  rows = 1 
)

Creates an RWDBMultiRow and populates it with multiple RWDBTBuffer instances, each corresponding to, and type-compatible with, the columns from s. Each created RWDBTBuffer is of length rows. Each created RWDBTBuffer is owned by the RWDBMultiRow.

RWDBMultiRow::~RWDBMultiRow ( )

Standard handle/body destructor. The destructor of the body object deletes all Type arrays that are owned by the RWDBMultiRow.

Member Function Documentation

void RWDBMultiRow::append ( RWDBAbstractBuffer item,
bool  ownership = true 
)

Appends this bindable object to the collection of bindable objects. If ownership is true the item is considered to be owned by self.

void RWDBMultiRow::append ( RWDBDataCallback item,
bool  ownership = true 
)

Appends this bindable object to the collection of bindable objects. If ownership is true the item is considered to be owned by self.

RWDBAbstractBuffer& RWDBMultiRow::bufferAt ( size_t  index) const

Returns a reference to the index th RWDBAbstractBuffer. Bounds checking is performed on index in debug versions of the library.

size_t RWDBMultiRow::entries ( ) const

Returns the number of rows. If bindable objects of varying lengths were appended, returns the minimum of the lengths of the contained bindable objects.

size_t RWDBMultiRow::numberOfColumns ( ) const

Returns the number of columns in the RWDBMultiRow, that is, the number of bindable objects appended to it.

RWDBMultiRow& RWDBMultiRow::operator= ( const RWDBMultiRow r)

Assignment operator. Discards self's current implementation and shares that of r.

RWDBMultiRow& RWDBMultiRow::operator>> ( RWDBAbstractBuffer b)

Appends b to the collection of bindable objects. b is not considered to be owned by the RWDBMultiRow. This operator is overloaded to allow the following syntax:

RWDBOSql aSql ("SELECT INTCOL FROM MYTABLE");
RWDBTBuffer<int> aBuffer(10);
aSql[0] >> aBuffer;
aSql.execute(aConnection);
aSql.fetch();

In this example, aBuffer is appended to the output RWDBMultiRow for the 0 th result set, and the result data for INTCOL is fetched into aBuffer. Also see RWDBOSql::operator[](size_t).

RWDBMultiRow& RWDBMultiRow::operator>> ( RWDBDataCallback b)

Appends b to the collection of bindable objects. b is not considered to be owned by the RWDBMultiRow.

RWDBRow RWDBMultiRow::operator[] ( size_t  i) const

Returns an RWDBRow by value for the data in all the contained RWDBAbstractBuffer and RWDBDataCallback instances at row i. The RWDBRow will contain values of RWDBValue::NoType for any RWDBDataCallback instances in the row, or any types unknown to RWDBValue. In debug mode libraries, bounds checking is performed on i. Note that changes made to the returned RWDBRow are not reflected in the RWDBAbstractBuffer instances held by the RWDBMultiRow.

RWDBSchema RWDBMultiRow::schema ( ) const

Returns the RWDBSchema passed in during construction if the relevant constructor was chosen. Otherwise, creates and returns a schema representing the metadata of the contained RWDBAbstractBuffer instances.

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