SourcePro® API Reference Guide

 
List of all members | Public Member Functions

Represents a table of data that resides in program memory. More...

#include <rw/db/memtable.h>

Inheritance diagram for RWDBMemTable:
RWDBTable

Public Member Functions

 RWDBMemTable (size_t capacity=0)
 
 RWDBMemTable (const RWDBTable &table, size_t capacity=0)
 
 RWDBMemTable (const RWDBTable &table, const RWDBConnection &connection, size_t capacity=0)
 
 RWDBMemTable (const RWDBSelectorBase &sel, size_t capacity=0)
 
 RWDBMemTable (const RWDBSelectorBase &sel, const RWDBConnection &connection, size_t capacity=0)
 
 RWDBMemTable (RWDBReader &reader, size_t capacity=0)
 
 RWDBMemTable (const RWDBMemTable &table)
 
size_t entries () const
 
RWDBMemTableoperator= (const RWDBMemTable &table)
 
RWDBRowoperator[] (size_t index)
 
bool populate (RWDBReader &reader)
 
bool populate (const RWDBTable &table)
 
- Public Member Functions inherited from RWDBTable
 RWDBTable ()
 
 RWDBTable (const RWDBTable &table)
 
void acquire (void) const
 
RWDBStatus addColumn (const RWDBColumn &column)
 
RWDBStatus addColumn (const RWDBColumn &column, const RWDBConnection &connection)
 
RWDBStatus addColumn (const RWCString &name, RWDBValue::ValueType type=RWDBValue::NoType, long storageLength=0, int nativeType=-1, int precision=-1, int scale=-1, bool nullAllowed=true, RWDBColumn::ParamType paramType=RWDBColumn::notAParameter)
 
RWDBStatus addColumn (const RWCString &name, const RWDBConnection &connection, RWDBValue::ValueType type=RWDBValue::NoType, long storageLength=0, int nativeType=-1, int precision=-1, int scale=-1, bool nullAllowed=true, RWDBColumn::ParamType paramType=RWDBColumn::notAParameter)
 
RWDBStatus addConstraint (const RWDBPrimaryKey &pk)
 
RWDBStatus addConstraint (const RWDBPrimaryKey &pk, const RWDBConnection &connection)
 
RWDBStatus addConstraint (const RWDBForeignKey &fk)
 
RWDBStatus addConstraint (const RWDBForeignKey &fk, const RWDBConnection &connection)
 
RWDBStatus addConstraint (const RWDBCheckConstraint &cc)
 
RWDBStatus addConstraint (const RWDBCheckConstraint &cc, const RWDBConnection &connection)
 
RWDBStatus addConstraint (const RWDBUniqueConstraint &uc)
 
RWDBStatus addConstraint (const RWDBUniqueConstraint &uc, const RWDBConnection &connection)
 
RWDBBulkInserter bulkInserter (const RWDBConnection &conn) const
 
RWDBBulkReader bulkReader (const RWDBConnection &conn) const
 
RWDBStatus checkConstraints (const RWDBConnection &conn, const RWCString &constraintName, RWDBCheckConstraintList &list)
 
RWDBStatus checkConstraints (const RWCString &constraintName, RWDBCheckConstraintList &list)
 
void clearCache (CacheType cache=RWDBTable::Local)
 
RWDBColumn column (size_t index) const
 
RWDBColumn column (const RWCString &name) const
 
RWDBColumn column (const RWCString &name, RWCString::caseCompare caseCompare) const
 
RWDBStatus createIndex (const RWCString &name, const RWDBSchema &columns, bool unique=true, bool clustered=true)
 
RWDBStatus createIndex (const RWCString &name, const RWDBSchema &columns, const RWDBConnection &connection, bool unique=true, bool clustered=true)
 
RWDBCursor cursor (RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBCursor cursor (const RWDBConnection &connection, RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBCursor cursor (const RWDBSchema &updateCols, RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBCursor cursor (const RWDBSchema &updateCols, const RWDBConnection &connection, RWDBCursor::CursorType type=RWDBCursor::Sequential, RWDBCursor::CursorAccess access=RWDBCursor::Read) const
 
RWDBDatabase database () const
 
RWDBDeleter deleter () const
 
RWDBDeleter deleter (const RWDBCriterion &criterion) const
 
virtual RWDBSchema describe (Metadata md)
 
virtual RWDBSchema describe (Metadata md, const RWDBConnection &conn)
 
RWDBStatus drop ()
 
RWDBStatus drop (const RWDBConnection &connection)
 
RWDBStatus dropColumn (const RWDBColumn &column)
 
RWDBStatus dropColumn (const RWDBColumn &column, const RWDBConnection &connection)
 
RWDBStatus dropConstraint (const RWCString &constraintName)
 
RWDBStatus dropConstraint (const RWCString &constraintName, const RWDBConnection &connection)
 
RWDBStatus dropConstraint (const RWDBPrimaryKey &pk)
 
RWDBStatus dropConstraint (const RWDBPrimaryKey &pk, const RWDBConnection &connection)
 
RWDBStatus dropConstraint (const RWDBForeignKey &fk)
 
RWDBStatus dropConstraint (const RWDBForeignKey &fk, const RWDBConnection &connection)
 
RWDBStatus dropConstraint (const RWDBCheckConstraint &cc)
 
RWDBStatus dropConstraint (const RWDBCheckConstraint &cc, const RWDBConnection &connection)
 
RWDBStatus dropConstraint (const RWDBUniqueConstraint &uc)
 
RWDBStatus dropConstraint (const RWDBUniqueConstraint &uc, const RWDBConnection &connection)
 
RWDBStatus dropIndex (const RWCString &name)
 
RWDBStatus dropIndex (const RWCString &name, const RWDBConnection &connection)
 
RWDBStatus::ErrorHandler errorHandler () const
 
bool exists (bool forceLookup=false)
 
bool exists (const RWDBConnection &connection, bool forceLookup=false)
 
virtual bool fetchSchema ()
 
virtual bool fetchSchema (const RWDBConnection &connection)
 
RWDBStatus foreignKeys (const RWDBConnection &conn, const RWCString &refName, RWDBForeignKeyList &keyList)
 
RWDBStatus foreignKeys (const RWCString &refName, RWDBForeignKeyList &keyList)
 
RWDBStatus grant (const RWCString &priv, const RWCString &user)
 
RWDBStatus grant (const RWCString &priv, const RWCString &user, const RWDBConnection &connection)
 
RWDBStatus grant (const RWCString &priv, const RWDBSchema &colList, const RWCString &user)
 
RWDBStatus grant (const RWCString &priv, const RWDBSchema &colList, const RWCString &user, const RWDBConnection &connection)
 
RWDBColumn identityColumn () const
 
size_t index (const RWCString &name) const
 
size_t index (const RWCString &name, RWCString::caseCompare caseCompare) const
 
size_t index (const RWDBColumn &column) const
 
RWDBInserter inserter (size_t cache=0) const
 
RWDBInserter inserter (const RWDBSelector &selector) const
 
RWDBInserter inserter (const RWDBCompoundSelector &selector) const
 
RWDBInserter inserter (const RWDBSchema &columnList, size_t cache=0) const
 
RWDBInserter inserter (const RWDBSelector &selector, const RWDBSchema &columnList) const
 
RWDBInserter inserter (const RWDBCompoundSelector &selector, const RWDBSchema &columnList) const
 
bool isReady () const
 
bool isValid () const
 
bool isView () const
 
bool isView (const RWDBConnection &conn) const
 
RWCString name () const
 
RWDBTablename (const RWCString &name)
 
size_t numberOfColumns () const
 
RWDBTableoperator= (const RWDBTable &table)
 
RWDBColumn operator[] (const RWCString &name) const
 
RWDBColumn operator[] (size_t position) const
 
RWDBPrimaryKey primaryKey (const RWDBConnection &conn)
 
RWDBPrimaryKey primaryKey ()
 
RWDBReader reader (size_t cacheSize=0) const
 
RWDBReader reader (const RWDBConnection &connection, size_t cacheSize=0) const
 
RWDBStatus referredToBy (const RWDBConnection &conn, RWDBForeignKeyList &keyList)
 
RWDBStatus referredToBy (RWDBForeignKeyList &keyList)
 
void release (void) const
 
RWDBStatus revoke (const RWCString &privilege, const RWCString &user)
 
RWDBStatus revoke (const RWCString &privilege, const RWCString &user, const RWDBConnection &connection)
 
RWDBStatus revoke (const RWCString &privilege, const RWDBSchema &columnList, const RWCString &user)
 
RWDBStatus revoke (const RWCString &privilege, const RWDBSchema &columnList, const RWCString &user, const RWDBConnection &connection)
 
RWDBSchema schema () const
 
void setErrorHandler (RWDBStatus::ErrorHandler errorHandler)
 
RWDBStatus status () const
 
RWCString tag () const
 
RWDBTabletag (const RWCString &newtag)
 
RWDBStatus uniqueConstraints (const RWDBConnection &conn, const RWCString &constraintName, RWDBUniqueConstraintList &list)
 
RWDBStatus uniqueConstraints (const RWCString &constraintName, RWDBUniqueConstraintList &list)
 
RWDBUpdater updater () const
 
RWDBUpdater updater (const RWDBCriterion &criterion) const
 

Additional Inherited Members

- Public Types inherited from RWDBTable
enum  CacheType { Local, All }
 
enum  Metadata {
  None, ColumnList, DefaultValues, IdentityConstraint,
  PrimaryKey
}
 

Detailed Description

RWDBMemTable is a table of data that resides in program memory. After construction, an RWDBMemTable is no longer associated with a table in the database. An application can modify the data in an RWDBMemTable, but the changes are not propagated back to the database.

RWDBMemTable is designed around the Interface/Implementation paradigm. An RWDBMemTable instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation.

Because an RWDBMemTable resides in memory, it is possible to provide random access to its data. The DB Interface Module provides operator[] for indexing on RWDBMemTable, the result of which is a reference to RWDBRow. RWDBRow inherits indexing operator operator[] from the Essential Tools Module class RWOrdered. The net result is the ability to access RWDBMemTable data with double indexing, as if it were a two-dimensional C++ array.

There are limitations to using RWDBMemTable, as it lacks some of the functionality of an RWDBTable. The differences in functionality come from the lack of a server in memory for selecting, deleting, inserting, and updating memory tables through SQL constructs. This means that selectors, cursors, deleters, inserters, and updaters cannot be created using memory tables. Instead, the actual table in the database must be referenced.

However, an RWDBReader may be produced from RWDBMemTable, allowing access to each row within the memory table, rather than using the overloaded operator operator[] for indexing.

It should also be noted that since memory tables exist within memory, the normal data definition language (DDL) constructs that are associated with tables are also dysfunctional and return invalid results. These include grant(), revoke(), addColumn(), dropColumn(), and so on.

Synopsis
#include <rw/db/memtable.h>
RWDBMemTable myTable = myDbase.memTable("myTable");

Constructor & Destructor Documentation

RWDBMemTable::RWDBMemTable ( size_t  capacity = 0)

Constructs an empty RWDBMemTable with given capacity. A capacity of zero means there is no limit on the number of rows to be stored.

RWDBMemTable::RWDBMemTable ( const RWDBTable table,
size_t  capacity = 0 
)

Uses a default database connection to construct an RWDBMemTable and populate it with a maximum of capacity rows from table. A capacity of zero means there is no limit on the number of rows to be stored.

RWDBMemTable::RWDBMemTable ( const RWDBTable table,
const RWDBConnection connection,
size_t  capacity = 0 
)

Uses the supplied connection to construct an RWDBMemTable and populate it with a maximum of capacity rows from table. A capacity of zero means there is no limit on the number of rows to be stored.

RWDBMemTable::RWDBMemTable ( const RWDBSelectorBase sel,
size_t  capacity = 0 
)

Uses a default connection to construct an RWDBMemTable and populate it with the maximum of capacity rows from sel. A capacity of zero means there is no limit on the number of rows to be stored.

RWDBMemTable::RWDBMemTable ( const RWDBSelectorBase sel,
const RWDBConnection connection,
size_t  capacity = 0 
)

Uses the supplied connection to construct an RWDBMemTable and to populate it with the maximum of capacity rows from sel. A capacity of zero means there is no limit on the number of rows to be stored.

RWDBMemTable::RWDBMemTable ( RWDBReader reader,
size_t  capacity = 0 
)

Uses the supplied reader to construct an RWDBMemTable, populating it with a maximum of capacity rows copied from reader. A capacity of zero means there is no limit on the number of rows to be stored.

RWDBMemTable::RWDBMemTable ( const RWDBMemTable table)

Copy constructor. Self shares an implementation with table.

Member Function Documentation

size_t RWDBMemTable::entries ( ) const

Returns the number of rows in self.

RWDBMemTable& RWDBMemTable::operator= ( const RWDBMemTable table)

Assignment operator. Self shares an implementation with table.

RWDBRow& RWDBMemTable::operator[] ( size_t  index)

Returns a reference to the RWDBRow in self at position index. No bounds checking is done.

bool RWDBMemTable::populate ( RWDBReader reader)

Fills self to capacity, with rows fetched from reader. Rows existing in self before this call are discarded.

bool RWDBMemTable::populate ( const RWDBTable table)

Fills self to capacity, with rows fetched from table. Rows existing in self before this call are discarded.

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