diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-947F448A-34D1-570F-9017-ED7B70674FBC.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-947F448A-34D1-570F-9017-ED7B70674FBC.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,50 @@ + + + + + +Implementing +TKey derived classesThis document describes how to implement TKey derived classes. +
Constructors

The constructors are used to set the +following information:

    +
  • the key offset

  • +
  • the type of comparison +to be made between keys

  • +
  • the length of the key +(for text type keys only).

  • +

For example:

TKeyDerived::TKeyDerived(TInt anOffset,TKeyCmpText aType) + : TKey(anOffset,aType) + {} + TKeyDerived::TKeyDerived(TInt anOffset,TKeyCmpText aType,TInt aLength) + : TKey(anOffset,aType,aLength) + {} + TKeyDerived::TKeyDerived(TInt anOffset,TKeyCmpNumeric aType) + : TKey(anOffset,aType) + {} +
+
Implementing the At() function

A typical implementation +of the virtual function At(), which gets a pointer to the +key of an element corresponding to a given index, might be structured:

TAny* TKeyDerived::At(TInt anIndex) const + { + if (anIndex==KIndexPtr) + { + return((TUint8 *)iPtr+iKeyOffset); + } + // + // code to return a pointer to the key in the appropriate element + // + } +

The derived class will need to have a pointer to the array +it represents. At the very least, the derived class will need a data member +for this pointer and, possibly, a member function to set it. This is needed +in order to implement the At() function.

TKey and +derived classes use untyped pointers, i.e. pointers of type TAny*. +It may be desirable to provide type safety by further deriving a templated +class.

+
\ No newline at end of file