Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: cdbtemp.h
Link against: commdb.lib

Class CCommsDbTemplateRecord

CCommsDbTemplateRecord

Support

Supported from 5.0

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

CBaseBase class for all classes to be instantiated on the heap
CCommsDbTemplateRecordThe view on a template record of a specific table

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

Inherited from CBase:
operator new()


Allocation and construction


NewL()

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

Description

Allocates and constructs a view, which includes only the template record, on the table whose name is defined in the specified descriptor and which is in the specified communications database.

The view is restricted to the single template record in the table.

The communications database, pointed to by aDb should already have been opened.

Parameters

CCommsDatabase* aDb

A pointer to the communications database object. This pointer must not be NULL.

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

Return value

CCommsDbTemplateRecord*

A pointer to the view object which just includes the template record.

Leave codes

 

The function may leave for a number of reasons, for example, if the table does not exist or the named table does not support a template record. Not all tables support template records; if this function is called for a table which does not support template records, then it leaves with KErrNotSupported . If there is insufficient memory available to create the object, the function leaves. If allocation is successful, it returns a pointer to the new object.

[Top]


Destruction


~CCommsDbTemplateRecord()

~CCommsDbTemplateRecord();

Description

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

[Top]


Information about the template record


TemplateRecordExists()

TBool TemplateRecordExists();

Description

Tests whether a template record exists in this table.

Return value

TBool

true, if a template record exists; false, otherwise

[Top]


Making changes to the template record


Modify()

TInt Modify();

Description

Prepares to update the template record, if it exists. If the template record does not exist, it is created.

The function must be called before writing to any column.

Once all changes to the template record are complete, a call must be made to either StoreModifications() or CancelModifications() as appropriate.

Notes:

Return value

TInt

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


Delete()

TInt Delete();

Description

Deletes the template record.

Note:

Return value

TInt

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


StoreModifications()

TInt StoreModifications();

Description

Confirms changes made to the template record which were started by a call to Modify().

Note:

Return value

TInt

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


CancelModifications()

void CancelModifications();

Support

Supported from 6.0

Description

Abandons changes made to the template record which were started by a call to Modify().

Note:


CancelModifications()

TInt CancelModifications();

Support

Withdrawn in 6.0

Description

Abandons changes made to the template record which were started by a call to Modify().

Note:

Return value

TInt

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

[Top]


Reading data from a column


ReadTypeAttribL()

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 defined in d32dbms.h.

The column attributes are one or more of the valuesTDbCol::ENotNull andTDbCol::EAutoIncrementdefined in d32dbms.h.

Note:

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.

Leave codes

 

The function can leave for reasons defined by DBMS but it also leaves if the column name cannot be found. If the template record does not exist, then the function leaves with KErrNotFound .


ReadUintL()

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 descriptoraColumn.

Notes:

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 toModify()andStoreModifications().

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 (unsigned integer) value is to be read.

TUint32& aValue

A reference to an unsigned integer passed by the caller.

Leave codes

 

The function can leave for reasons defined by DBMS. It also leaves   — with KErrNotFound   — if the template record does not exist.


ReadBoolL()

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.

Notes:

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.

Leave codes

 

The function can leave for reasons defined by DBMS. It also leaves   — with KErrNotFound   — if the template record does not exist.


ReadTextL()

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 descriptoraColumn.

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

Notes:

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.

Leave codes

 

The function can leave for reasons defined by DBMS. It also leaves   — with KErrNotFound   — if the template record does not exist.


ReadTextL()

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 descriptoraColumn.

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

Notes:

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.

Leave codes

 

The function can leave for reasons defined by DBMS. It also leaves   — with KErrNotFound   — if the template record does not exist.


ReadColumnLengthL()

void ReadColumnLength(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.

Notes:

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 toModify()andStoreModifications().

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.

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.

Leave codes

 

The function can leave for reasons defined by DBMS. It also leaves   — with KErrNotFound   — if the template record does not exist.


ReadLongTextLC()

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 theReadTextL()functions is limited in length, there is no restriction on the length of long text.

Notes:

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.

Leave codes

 

The function can leave for reasons defined by DBMS. It also leaves   — with KErrNotFound   — if the template record does not exist.

[Top]


Writing data to a column


WriteUintL()

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.

Note:

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

 

The function can leave for reasons defined by DBMS.


WriteBoolL()

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 descriptoraColumn.

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

 

The function can leave for reasons defined by DBMS.


WriteTextL()

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 constantKCommsDbSvrMaxColumnNameLength  (defined in cdblen.h).


WriteTextL()

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 constantKCommsDbSvrMaxColumnNameLength  (defined in cdblen.h).


WriteLongTextL()

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

 

The function can leave for reasons defined by DBMS.

[Top]


Get name of the table


GetTableName()

void GetTableName(TDes& aTableName) const;

Description

Gets the name of the table associated with this view and copy it into the descriptor supplied by the caller.

Parameters

TDes& aTableName

A reference to a descriptor passed by the caller. On return from this function it contains the name of the table.