diff -r 48780e181b38 -r 578be2adaf3e Symbian3/PDK/Source/GUID-947F448A-34D1-570F-9017-ED7B70674FBC.dita --- a/Symbian3/PDK/Source/GUID-947F448A-34D1-570F-9017-ED7B70674FBC.dita Tue Jul 20 12:00:49 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-947F448A-34D1-570F-9017-ED7B70674FBC.dita Fri Aug 13 16:47:46 2010 +0100 @@ -1,50 +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.

+ + + + + +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