Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: d32dbms.h
Link against: edbms.lib

Class CDbKey

CDbKey

Support

Supported from 5.0

Description

Represents the definition of an index. The key may be unique or primary, it can specify the sort of comparison which is made for Text columns, and it has a list of columns which make up the key. The class is used to construct and interrogate index keys.

This class is not intended for user derivation.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CDbKeyRepresents the definition of an index

Defined in CDbKey:
AddL(), CDbKey(), Clear(), Comparison(), Count(), IsPrimary(), IsUnique(), MakeUnique(), NewL(), NewLC(), Remove(), SetComparison(), operator[](), ~CDbKey()

Inherited from CBase:
operator new()


Construction and destruction


CDbKey()

CDbKey();

Description

Constructs an empty key. It is initialised to non-unique, non-primary and normal text comparison.


NewL()

static CDbKey* NewL();

Description

Constructs and returns a pointer to a new empty key.

Return value

CDbKey*

A pointer to the key object.

Leave codes

 

The function leaves with KErrNoMemory if there is not enough memory to perform this operation.


NewLC()

static CDbKey* NewLC();

Description

Constructs and returns a new empty key and return a pointer to it — leaving a pointer to the key object on the cleanup stack. This allows the key object and allocated resources to be cleaned up if a subsequent leave occurs.

Return value

CDbKey*

A pointer to the key object.

Leave codes

 

The function leaves with KErrNoMemory if there is not enough memory to perform this operation.


~CDbKey()

~CDbKey();

Description

Frees resources owned by the object.

[Top]


Resetting


Clear()

void Clear();

Description

Resets the key to its initial empty state.

[Top]


Adding and removing key columns


AddL()

CDbKey& AddL(const TDbKeyCol& aKeyCol);

Description

Adds a key column to the end of the key.

Parameters

const TDbKeyCol& aKeyCol

The key column to add to the key.

Return value

CDbKey&

A reference to this object.

Leave codes

 

The function leaves with KErrNoMemory if there is not enough memory to perform this operation.


Remove()

void Remove(const TDesC& aColName);

Description

Removes the named column from the key.

Parameters

const TDesC& aColName

The name of the column to remove from the key.

[Top]


Enumerating key columns


Count()

TInt Count() const;

Description

Returns the number of key columns in the key.

Return value

TInt

The number of key columns in the key.


operator[]()

const TDbKeyCol& operator[](TInt aCol) const;

Description

Returns a key column by its position in the key.

Parameters

TInt aCol

The position of the column in the key. These are numbered from 0 to Count()-1.

Return value

TDbKeyCol&

The key column requested.

[Top]


Setting the key attributes


MakeUnique()

void MakeUnique();

Description

Makes the key unique. This ensures that every key value in the index is distinct from every other.


SetComparison()

void SetComparison(TDbTextComparison aComparison);

Description

Sets the way in which Text columns are compared for the key. All Text columns in the key are compared in the same way.

Parameters

TDbTextComparison aComparison

The comparison type to use.

[Top]


Fetching the key attributes


Comparison()

TDbTextComparison Comparison() const;

Description

Returns the method used to compare Text columns in this key.

Return value

TDbTextComparison

The comparison type used for the key.


IsPrimary()

TBool IsPrimary() const;

Description

Tests whether the key is the primary key.

Return value

TBool

True, if the key is unique; false, otherwise.


IsUnique()

TBool IsUnique() const;

Description

Tests whether the key is unique.

Return value

TBool

True, if the key is unique; false, otherwise.