SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWDBCheckConstraint Class Reference

Represents check constraints, used when creating a database table or fetching a database table schema. More...

#include <rw/db/checkconstr.h>

Inheritance diagram for RWDBCheckConstraint:
RWCollectable

Public Member Functions

 RWDBCheckConstraint ()
 
 RWDBCheckConstraint (const RWDBExpr &checkCond, const RWCString &constraintName="")
 
 RWDBCheckConstraint (const RWDBCheckConstraint &constr)
 
virtual ~RWDBCheckConstraint ()
 
RWCString asString (const RWDBPhraseBook &phrasebook) const
 
RWspace binaryStoreSize () const
 
RWDBCheckConstraintcheckCondition (const RWDBExpr &cond)
 
RWDBExpr checkCondition () const
 
RWDBCheckConstraint clone () const
 
RWDBColumn column (size_t index) const
 
RWDBColumn column (const RWCString &name) const
 
RWDBColumn column (const RWCString &name, RWCString::caseCompare cc) const
 
virtual int compareTo (const RWCollectable *c) const
 
RWDBCheckConstraintconstraintName (const RWCString &newName)
 
RWCString constraintName () const
 
virtual RWCollectablecopy () const
 
size_t entries () const
 
virtual unsigned hash () const
 
size_t index (const RWCString &name) const
 
size_t index (const RWCString &name, RWCString::caseCompare cc) const
 
size_t index (const RWDBColumn &column) const
 
virtual RWClassID isA () const
 
virtual bool isEqual (const RWCollectable *c) const
 
bool isValid () const
 
virtual RWCollectablenewSpecies () const
 
RWDBCheckConstraintoperator= (const RWDBCheckConstraint &constr)
 
bool operator== (const RWDBCheckConstraint &constraint) const
 
RWDBColumn operator[] (size_t index) const
 
RWDBColumn operator[] (const RWCString &name) const
 
virtual void restoreGuts (RWFile &file)
 
virtual void restoreGuts (RWvistream &stream)
 
virtual void saveGuts (RWFile &file) const
 
virtual void saveGuts (RWvostream &stream) const
 
- Public Member Functions inherited from RWCollectable
virtual ~RWCollectable ()
 
RWspace recursiveStoreSize () const
 
RWStringID stringID () const
 

Additional Inherited Members

- Static Public Member Functions inherited from RWCollectable
static RWClassID classID (const RWStringID &name)
 
static RWClassID classIsA ()
 
static bool isAtom (RWClassID id)
 
static RWspace nilStoreSize ()
 

Detailed Description

RWDBCheckConstraint represents a table's check constraint, used when building up an RWDBSchema in preparation for an RWDBDatabase::createTable() call. The check condition is the definition of the constraint. When creating a table, the instances of RWDBColumn, if any, are ignored.

RWDBCheckConstraint instances are also used as elements of lists that are returned from RWDBTable::checkConstraints(). If the table columns in the definition of the constraint can be obtained from the database, they will be available via the methods operator[]() and column() when the check constraints are fetched via RWDBTable::checkConstraints().

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

Constructor & Destructor Documentation

RWDBCheckConstraint::RWDBCheckConstraint ( )

Creates an empty RWDBCheckConstraint. Provided for convenience only.

RWDBCheckConstraint::RWDBCheckConstraint ( const RWDBExpr checkCond,
const RWCString constraintName = "" 
)

Constructs a check constraint with check condition checkCond and name constraintName. If constraintName is the empty string, no name will be used when creating the table.

RWDBCheckConstraint::RWDBCheckConstraint ( const RWDBCheckConstraint constr)

Copy constructor. Self shares an implementation with constr.

virtual RWDBCheckConstraint::~RWDBCheckConstraint ( )
virtual

Destructor.

Member Function Documentation

RWCString RWDBCheckConstraint::asString ( const RWDBPhraseBook phrasebook) const

Returns an RWCString representing self as a string based on the format found in phrasebook.

RWspace RWDBCheckConstraint::binaryStoreSize ( ) const
virtual

Returns the number of bytes used by the virtual function saveGuts(RWFile&) to store an object. Typically, this involves adding up the space required to store all primitives, plus the results of calling recursiveStoreSize() for all objects inheriting from RWCollectable. See the Essential Tools Module User's Guide for details.

Reimplemented from RWCollectable.

RWDBCheckConstraint& RWDBCheckConstraint::checkCondition ( const RWDBExpr cond)

Sets the check condition to cond. Returns a reference to self. To unset a check condition, pass an empty RWDBExpr created with the default constructor.

Note
This does not change the check condition of the check constraint on a table that already exists in the database.
RWDBExpr RWDBCheckConstraint::checkCondition ( ) const

Returns the check condition. If there is no check condition, returns an empty RWDBExpr.

RWDBCheckConstraint RWDBCheckConstraint::clone ( ) const

Returns a deep copy of self.

RWDBColumn RWDBCheckConstraint::column ( size_t  index) const

Returns a shallow copy of the column from self at the specified index. If the index is out of range, returns an RWDBColumn whose status is RWDBStatus::invalidPosition.

RWDBColumn RWDBCheckConstraint::column ( const RWCString name) const

Returns a shallow copy of the column from self whose name matches the given name. If there is no match, returns an RWDBColumn whose status is RWDBStatus::columnNotFound.

RWDBColumn RWDBCheckConstraint::column ( const RWCString name,
RWCString::caseCompare  cc 
) const

Returns a shallow copy of the column from self whose name matches the given name, according to cc. If there is no match, returns an RWDBColumn whose status is RWDBStatus::columnNotFound.

virtual int RWDBCheckConstraint::compareTo ( const RWCollectable c) const
virtual

If c points to an RWDBCheckConstraint, returns the result of asString().compareTo(c->asString()) using the default phrasebook, otherwise returns a nonzero value.

Reimplemented from RWCollectable.

RWDBCheckConstraint& RWDBCheckConstraint::constraintName ( const RWCString newName)

Sets the constraint name of self to newName. Returns a reference to self.

Note
This does not change the name of the check constraint on a table that already exists in the database.
RWCString RWDBCheckConstraint::constraintName ( ) const

Returns the constraint name of this check constraint.

virtual RWCollectable* RWDBCheckConstraint::copy ( ) const
virtual

Returns a new, copy-constructed object of the same type as self. The caller is responsible for deleting the object.

Reimplemented from RWCollectable.

size_t RWDBCheckConstraint::entries ( ) const

Returns the number of RWDBColumn instances in self.

virtual unsigned RWDBCheckConstraint::hash ( ) const
virtual

Returns asString().hash().

Reimplemented from RWCollectable.

size_t RWDBCheckConstraint::index ( const RWCString name) const

Returns the index of the first RWDBColumn in self with the given name. Returns RW_NPOS if no such column is found.

size_t RWDBCheckConstraint::index ( const RWCString name,
RWCString::caseCompare  cc 
) const

Returns the index of the first column from self whose name matches the given name, according to cc. If there is no match, returns RW_NPOS.

size_t RWDBCheckConstraint::index ( const RWDBColumn column) const

Returns the index of the first RWDBColumn in self with the same name as the name of the given column. Returns RW_NPOS if no such column is found.

virtual RWClassID RWDBCheckConstraint::isA ( ) const
virtual

Returns __RWDBCHECKCONSTRAINT.

Reimplemented from RWCollectable.

virtual bool RWDBCheckConstraint::isEqual ( const RWCollectable t) const
virtual

Behaves as if compareTo(t) was invoked, returning true if the result equals 0, false otherwise.

Reimplemented from RWCollectable.

bool RWDBCheckConstraint::isValid ( ) const

Returns true if self's check condition is set, otherwise returns false.

virtual RWCollectable* RWDBCheckConstraint::newSpecies ( ) const
virtual

Returns a new, default-constructed object of the same type as self. The caller is responsible for deleting the object.

Reimplemented from RWCollectable.

RWDBCheckConstraint& RWDBCheckConstraint::operator= ( const RWDBCheckConstraint constr)

Assignment operator. Self shares an implementation with constr. Returns a reference to self.

bool RWDBCheckConstraint::operator== ( const RWDBCheckConstraint constraint) const

Compares self to constraint. Returns true if constraint and self share the same implementation.

RWDBColumn RWDBCheckConstraint::operator[] ( size_t  index) const

Returns the RWDBColumn in self at position index. If the index is out of range, returns an RWDBColumn with a status of RWDBStatus::invalidPosition. Indexing into an empty RWDBCheckConstraint is treated as out of range. Note that the returned RWDBColumn is not a deep copy; modifications to RWDBColumn change the containing RWDBCheckConstraint.

RWDBColumn RWDBCheckConstraint::operator[] ( const RWCString name) const

Returns the first RWDBColumn in self with the given name. If no such column exists, returns an RWDBColumn with a status of RWDBStatus::columnNotFound. Note that the returned RWDBColumn is not a deep copy; modifications to RWDBColumn change the containing RWDBCheckConstraint.

virtual void RWDBCheckConstraint::restoreGuts ( RWFile )
virtual

Reads an object's state from a binary file, using class RWFile, replacing the previous state.

Reimplemented from RWCollectable.

virtual void RWDBCheckConstraint::restoreGuts ( RWvistream )
virtual

Reads an object's state from an input stream, replacing the previous state.

Reimplemented from RWCollectable.

virtual void RWDBCheckConstraint::saveGuts ( RWFile ) const
virtual

Writes an object's state to a binary file, using class RWFile.

Reimplemented from RWCollectable.

virtual void RWDBCheckConstraint::saveGuts ( RWvostream ) const
virtual

Writes an object's state to an output stream.

Reimplemented from RWCollectable.

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