Member Functions | |||
append() buffer() |
entries() numberOfColumns() |
operator>>() operator=() |
operator[]() schema() |
#include <rw/db/multirow.h>
Class RWDBMultiRow provides a mechanism by which a collection of bindable objects can be used with the RWDBValue/RWDBRow interface. These bindable objects are subclasses of RWDBAbstractBuffer, typically RWDBTBuffers. They can be manually created and appended to the RWDBMultiRow, or the RWDBMultiRow can create appropriate RWDBAbstractBuffers when given an RWDBSchema.
Although the internals may differ, you can think of RWDBMultiRow as possessing the following attributes:
A collection of RWDBAbstractBuffers
A collection of ownership indicators, each with a one-to-one correspondence to an entry in the collection of RWDBAbstractBuffers. An ownership indicator is TRUE if the RWDBMultiRow is considered to own the corresponding RWDBAbstractBuffer.
An RWDBSchema containing metadata about each of the RWDBTBuffers, usually obtained in result processing that is internal to DBTools.h++
Please see Example 2 in the entry for RWDBOSql.
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(const RWDBMultiRow& rhs);
Copy constructor. Creates an RWDBMultiRow that shares an implementation with rhs.
RWDBMultiRow(RWDBSchema &s, size_t rows);
Creates an RWDBMultiRow and populates it with multiple RWDBTBuffers, 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();
Standard handle/body destructor. The destructor of the body object deletes all Type arrays that are owned by the RWDBMultiRow.
RWDBMultiRow& operator=(const RWDBMultiRow& r);
Assignment operator. Discards self's current implementation and shares that of r.
RWDBRow operator[](size_t i) const;
Returns an RWDBRow by value for the data in all the contained RWDBAbstractBuffers at row i. In debug mode libraries, bounds checking is performed on i. Note that changes made to the returned RWDBRow are not reflected in the RWDBAbstractBuffers held by the RWDBMultiRow.
RWDBMultiRow& operator>>(RWDBAbstractBuffer& b);
Appends b to the collection of RWDBAbstractBuffers. 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 0th result set, and the result data for INTCOL is fetched into aBuffer. Also see RWDBOSql::operator[](size_t).
void append(RWDBAbstractBuffer *p, RWBoolean ownership = TRUE);
Appends this bindable object to the collection of bindable objects, and appends ownership to the ownership indicator collection.
const RWDBAbstractBuffer& buffer(size_t n) const; RWDBAbstractBuffer& buffer(size_t n);
Returns a reference to the nth RWDBAbstractBuffer. Bounds checking is performed on n in debug versions of the library.
size_t 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 numberOfColumns() const;
Returns the number of columns in the RWDBMultiRow, that is, the number of bindable objects appended to it.
RWDBSchema 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 RWDBAbstractBuffers.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.