Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: CDBTEMP.H
Link against: commdb.lib

Class CCommsDbTemplateRecord

class CCommsDbTemplateRecord : public CBase;

Description

The view on a template record of a specific table.

The view contains only the template record and therefore, unlike the more general CCommsDbTableView class, does not contain any navigation functions.

This class does, however, contain the necessary member functions for reading and writing to columns.

Derivation

Members

Defined in CCommsDbTemplateRecord:
CancelModifications(), Delete(), GetTableName(), InsertCopy(), Modify(), NewL(), ReadBoolL(), ReadColumnLengthL(), ReadLongTextLC(), ReadTextL(), ReadTextL(), ReadTypeAttribL(), ReadUintL(), StoreModifications(), TemplateRecordExists(), WriteBoolL(), WriteLongTextL(), WriteTextL(), WriteTextL(), WriteUintL(), ~CCommsDbTemplateRecord()

Inherited from CBase:
Extension_(), operator new()


Construction and destruction


NewL()

static IMPORT_C CCommsDbTemplateRecord *NewL(CCommsDatabaseBase *aDb, const TDesC &aTableName);

Description

Creates a new template view on the database and table specified.

Parameters

CCommsDatabaseBase *aDb

const TDesC &aTableName

Return value

CCommsDbTemplateRecord *


~CCommsDbTemplateRecord()

IMPORT_C ~CCommsDbTemplateRecord();

Description

Frees all resources owned by this object, prior to its destruction. Specifically, it closes the view.

[Top]


Member functions


Modify()

IMPORT_C TInt Modify();

Description

Modifies the existing template record if there is no template create one. StoreModifications() is called to complete the transaction.

Return value

TInt


Delete()

IMPORT_C TInt Delete();

Description

Removes the template from the table.

Return value

TInt


StoreModifications()

IMPORT_C TInt StoreModifications();

Description

Stores an new or updated template back to the database.

Return value

TInt

See also


CancelModifications()

IMPORT_C void CancelModifications();

Description

Cancels pending changes since `Modify()`.


ReadTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadTextL(const TDesC &aColumn, TDes8 &aValue);

Description

Reads narrow (ASCII) text located in a specific column within the template record and copies it to the specified 8 bit modifiable descriptor. The column is identified by the name supplied in the descriptor aColumn.

The maximum length of text expected by this function is the value of the constant KCommsDbSvrMaxColumnNameLength. The maximum length of aValue supplied by the caller can, therefore, be the same.

If the template record does not exist, this function will just return with an empty aValue desciptor.

This read operation must not occur if any of the operations involved in changing the template record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to Modify() and StoreModifications().

The CommsDbServer 10 panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the template record whose (narrow text) value is to be read.

TDes8 &aValue

A reference to an 8 bit descriptor passed by the caller.


ReadTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadTextL(const TDesC &aColumn, TDes16 &aValue);

Description

Reads wide (UNICODE) text located in a specific column within the template record and copies it to the specified 16 bit modifiable descriptor. The column is identified by the name supplied in the descriptor aColumn.

The maximum length of text expected by this function is the value of the constant KCommsDbSvrMaxColumnNameLength. The maximum length of aValue supplied by the caller can, therefore, be the same.

This read operation must not occur if any of the operations involved in changing the template record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to Modify() and StoreModifications().

The CommsDbServer 10 panic is also raised if this function is called after the view has been closed.

If the template record does not exist, this function will just return with an empty aValue desciptor.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the template record whose (wide text) value is to be read.

TDes16 &aValue

A reference to a 16 bit descriptor passed by the caller.


ReadLongTextLC()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C HBufC *ReadLongTextLC(const TDesC &aColumn);

Description

Reads the long text located in a specific column within the template record and copies this text to a heap descriptor. The heap descriptor is allocated and its pointer returned by this function. The column is identified by the name supplied in the descriptor aColumn.

While the text in columns retrieved by the ReadTextL() functions is limited in length, there is no restriction on the length of long text.

If the template record does not exist, this function will just return an empty desciptor. Also in this case, the caller is still responsible for removing this object from the cleanup stack.

This read operation must not occur if any of the operations involved in changing a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to Modify() and StoreModifications().

The CommsDbServer 10 panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the template record.

Return value

HBufC *

Pointer to a heap descriptor containing the long text.


ReadUintL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadUintL(const TDesC &aColumn, TUint32 &aValue);

Description

Reads an unsigned integer value located in a specific column within the template record and copies it into the specified unsigned integer. The column is identified by the name supplied in the descriptor aColumn.

This read operation must not occur if any of the operations involved in changing the template record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to Modify() and StoreModifications().

The CommsDbServer 10 panic is also raised if this function is called after the view has been closed.

If the template record does not exist then the function leaves with KErrUnknown.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the template record whose (unsigned integer) value is to be read.

TUint32 &aValue

A reference to an unsigned integer passed by the caller.


ReadBoolL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadBoolL(const TDesC &aColumn, TBool &aValue);

Description

Reads a boolean value located in a specific column within the template record and copies it into the specified descriptor. The column is identified by the name supplied in the descriptor aColumn.

This read operation must not occur if any of the operations involved in changing the template record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to Modify() and StoreModifications().

The CommsDbServer 10 panic is also raised if this function is called after the view has been closed.

If the template record does not exist then the function leaves with KErrUnknown.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the template record whose (boolean) value is to be read.

TBool &aValue

A reference to a TBool passed by the caller.


ReadTypeAttribL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadTypeAttribL(const TDesC &aColumn, TDbColType &aColType, TUint32 &aAttrib);

Description

Gets the type and the attributes of a specific column within the template record and puts them into a reference to an object and a reference to an unsigned integer respectively. The column is identified by the name supplied in the descriptor aColumn.

The column type is described by the TDbColType enumerator.

The column attributes are one or more of the values TDbCol::ENotNull and TDbCol::EAutoIncrement.

This function must not be called if any of the operations involved in changing the template record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to Modify() and StoreModifications().

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the template record whose type and attributes are to be fetched.

TDbColType &aColType

A reference to a TDbColType object passed by the caller. On successful return from this function, contains a copy of the column type.

TUint32 &aAttrib

A reference to an unsigned integer passed by the caller. On successful return from this function, contains a copy of the column attributes.


ReadColumnLengthL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadColumnLengthL(const TDesC &aColumn, TInt &aLength);

Description

Gets the length of a specific column within the template record and copies it to an integer passed by the caller. The column is identified by the name supplied in the descriptor aColumn.

This read operation must not occur if any of the operations involved in changing a template record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to Modify() and StoreModifications().

The CommsDbServer 10 panic is also raised if this function is called after the view has been closed.

If the template record does not exist, this function will just return with aLength set to zero.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the template record.

TInt &aLength

A reference to an integer passed by the caller. On successful return from this function, contains a copy of the length of the column.


WriteTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteTextL(const TDesC &aColumn, const TDesC8 &aValue);

Description

Writes the narrow (ASCII) text from the specified 8 bit descriptor to a specific column within the template record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to Modify() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the template record.

const TDesC8 &aValue

A reference to an 8 bit descriptor containing the narrow text to be written into the column.

Leave codes

The

function can leave for reasons defined by DBMS. It will also leave if the length of the text is greater than the maximum permitted - equal to the value of the constant KCommsDbSvrMaxColumnNameLength. KErrNotFound The column name does not exist.


WriteTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteTextL(const TDesC &aColumn, const TDesC16 &aValue);

Description

Writes the wide (Unicode) text from the specified 16 bit descriptor to a specific column within the template record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to Modify() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic.

The CommsDbServer 12 panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

const TDesC16 &aValue

A reference to a 16 bit descriptor containing the wide text to be written into the column.

Leave codes

The

function can leave for reasons defined by DBMS. It will also leave if the length of the text is greater than the maximum permitted - equal to the value of the constant KCommsDbSvrMaxColumnNameLength. KErrNotFound The column name does not exist.


WriteLongTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteLongTextL(const TDesC &aColumn, const TDesC &aValue);

Description

Writes the long text from a specified descriptor to a specific column within the template record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to Modify() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic.

The CommsDbServer 12 panic is also raised if this function is called after the view has been closed.

While the text written by WriteTextL() functions is limited in length, there is no restriction on the length of long text.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the template record.

const TDesC &aValue

A reference to a descriptor containing the long text to be written into the column.

Leave codes

KErrNotFound

The column name does not exist.


WriteUintL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteUintL(const TDesC &aColumn, const TUint32 &aValue);

Description

Writes a specified unsigned integer value to a specific column within the template record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to Modify() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic.

The CommsDbServer 12 panic is also raised if this function is called after the view has been closed.

The column being changed must not be the Id column (symbolic name COMMDB_ID) otherwise the function raises a CommsDbServer 13 panic.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the template record.

const TUint32 &aValue

A reference to an unsigned integer containing the value to be written into the column.

Leave codes

KErrNotFound

The column name does not exist.


WriteBoolL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteBoolL(const TDesC &aColumn, const TBool &aValue);

Description

Writes a specified boolean value to a specific column within the template record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to Modify() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic.

The CommsDbServer 12 panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the template record.

const TBool &aValue

A reference to TBool containing the value to be written into the column.

Leave codes

KErrNotFound

The column name does not exist.


GetTableName()

IMPORT_C void GetTableName(TDes &aTableName) const;

Description

The name of the table that this template belongs to.

Parameters

TDes &aTableName


TemplateRecordExists()

IMPORT_C TBool TemplateRecordExists();

Description

True if a template exists.

Return value

TBool


InsertCopy()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C TInt InsertCopy(TUint32 &aId);

Description

Creates a new record based on the contents of the template record

Parameters

TUint32 &aId

On return contains the unique Id associated with this new record.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.