SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWDBUniqueConstraint Class Reference

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

#include <rw/db/uniqueconstr.h>

Inheritance diagram for RWDBUniqueConstraint:
RWCollectable

Public Member Functions

 RWDBUniqueConstraint ()
 
 RWDBUniqueConstraint (const RWCString &constraintName)
 
 RWDBUniqueConstraint (const RWDBUniqueConstraint &constr)
 
virtual ~RWDBUniqueConstraint ()
 
RWDBColumn appendColumn (const RWDBColumn &col)
 
RWCString asString (const RWDBPhraseBook &phrasebook) const
 
RWspace binaryStoreSize () const
 
RWDBUniqueConstraint 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
 
RWDBUniqueConstraintconstraintName (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
 
RWDBUniqueConstraintoperator= (const RWDBUniqueConstraint &constr)
 
bool operator== (const RWDBUniqueConstraint &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

RWDBUniqueConstraint represents a table's unique constraints, used when building up an RWDBSchema in preparation for an RWDBDatabase::createTable() call. When creating a table, the instances of RWDBColumn are used to define the set of columns that make up a unique constraint.

RWDBUniqueConstraint instances are also used as elements of lists that are returned from RWDBTable::uniqueConstraints(). 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 unique constraints are fetched via RWDBTable::uniqueConstraints().

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

Constructor & Destructor Documentation

RWDBUniqueConstraint::RWDBUniqueConstraint ( )

Creates an empty RWDBUniqueConstraint. The object is not valid until it contains at least one column.

RWDBUniqueConstraint::RWDBUniqueConstraint ( const RWCString constraintName)

Constructs a unique constraint. If constraintName is the empty string, no name will be used when creating the table.

RWDBUniqueConstraint::RWDBUniqueConstraint ( const RWDBUniqueConstraint constr)

Copy constructor. Self shares an implementation with constr.

virtual RWDBUniqueConstraint::~RWDBUniqueConstraint ( )
virtual

Destructor.

Member Function Documentation

RWDBColumn RWDBUniqueConstraint::appendColumn ( const RWDBColumn col)

Creates a deep copy of the RWDBColumn col, using the RWDBColumn::clone() method. Appends the copied column to self, and returns it.

RWCString RWDBUniqueConstraint::asString ( const RWDBPhraseBook phrasebook) const

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

RWspace RWDBUniqueConstraint::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.

RWDBUniqueConstraint RWDBUniqueConstraint::clone ( ) const

Returns a deep copy of self.

RWDBColumn RWDBUniqueConstraint::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 RWDBUniqueConstraint::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 RWDBUniqueConstraint::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 RWDBUniqueConstraint::compareTo ( const RWCollectable c) const
virtual

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

Reimplemented from RWCollectable.

RWDBUniqueConstraint& RWDBUniqueConstraint::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 unique constraint on a table that already exists in the database.
RWCString RWDBUniqueConstraint::constraintName ( ) const

Returns the constraint name of this unique constraint.

virtual RWCollectable* RWDBUniqueConstraint::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 RWDBUniqueConstraint::entries ( ) const

Returns the number of RWDBColumn instances in self.

virtual unsigned RWDBUniqueConstraint::hash ( ) const
virtual

Returns asString().hash().

Reimplemented from RWCollectable.

size_t RWDBUniqueConstraint::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 RWDBUniqueConstraint::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 RWDBUniqueConstraint::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 RWDBUniqueConstraint::isA ( ) const
virtual

Returns __RWDBUNIQUECONSTRAINT.

Reimplemented from RWCollectable.

virtual bool RWDBUniqueConstraint::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 RWDBUniqueConstraint::isValid ( ) const

Returns false if self has no columns (i.e. entries() == 0), otherwise returns true.

virtual RWCollectable* RWDBUniqueConstraint::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.

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

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

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

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

RWDBColumn RWDBUniqueConstraint::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 RWDBUniqueConstraint is treated as out of range. Note that the returned RWDBColumn is not a deep copy; modifications to RWDBColumn change the containing RWDBUniqueConstraint.

RWDBColumn RWDBUniqueConstraint::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 RWDBUniqueConstraint.

virtual void RWDBUniqueConstraint::restoreGuts ( RWFile )
virtual

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

Reimplemented from RWCollectable.

virtual void RWDBUniqueConstraint::restoreGuts ( RWvistream )
virtual

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

Reimplemented from RWCollectable.

virtual void RWDBUniqueConstraint::saveGuts ( RWFile ) const
virtual

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

Reimplemented from RWCollectable.

virtual void RWDBUniqueConstraint::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.