webengine/wmlengine/src/utils/include/TKeyArrayPtr.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Key class for use with pointer-based Symbian array classes.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TKEYARRAYPTR_H
       
    20 #define TKEYARRAYPTR_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "nwx_string.h"
       
    25 
       
    26 // CLASS DECLARATION
       
    27 
       
    28 /**
       
    29 *   Numeric key class for use with pointer-based Symbian array classes.
       
    30 *   See the following link from Symbian:
       
    31 *     http://www3.symbian.com/faq.nsf/f6fbf5deaf4cca7080256a64005ac61e/defdb21d5e976aee80256a570051b8d9?OpenDocument&Highlight=2,TKeyArrayFix
       
    32 *   @lib lmgr.lib
       
    33 *   @since 2.1
       
    34 */
       
    35 class TNumKeyArrayPtr : public TKeyArrayFix
       
    36     {
       
    37     public:  // Constructors and destructor
       
    38 
       
    39         /**
       
    40         * Constructor.
       
    41         */
       
    42         inline TNumKeyArrayPtr(TInt aOffset, TKeyCmpNumeric aType) : TKeyArrayFix(aOffset, aType) {}
       
    43 
       
    44 
       
    45     public: // NEW FUNCTIONS
       
    46 
       
    47         /**
       
    48         * Gets pointer to array entry at specified index.
       
    49         * @since 2.1
       
    50         * @param aIndex Index within the array of desired entry.
       
    51         * @return Pointer to entry.
       
    52         */
       
    53         virtual TAny* At(TInt aIndex) const
       
    54             {
       
    55             if (aIndex == KIndexPtr)
       
    56                 {
       
    57                     return *(TUint8**)iPtr + iKeyOffset;
       
    58                 }
       
    59             return *(TUint8**)iBase->Ptr(aIndex * sizeof(TUint8**)).Ptr() + iKeyOffset;
       
    60             }
       
    61     };
       
    62 
       
    63 /**
       
    64 *   Textual (string) key class for use with pointer-based Symbian array classes.
       
    65 *   See the following link from Symbian:
       
    66 *     http://www3.symbian.com/faq.nsf/f6fbf5deaf4cca7080256a64005ac61e/defdb21d5e976aee80256a570051b8d9?OpenDocument&Highlight=2,TKeyArrayFix
       
    67 *   @lib lmgr.lib
       
    68 *   @since 2.1
       
    69 */
       
    70 class TTextKeyArrayPtr : public TKeyArrayFix
       
    71     {
       
    72     public:  // Constructors and destructor
       
    73 
       
    74         /**
       
    75         * Constructor.
       
    76         */
       
    77         inline TTextKeyArrayPtr(TInt aOffset, TKeyCmpText aType) : TKeyArrayFix(aOffset, aType) {}
       
    78 
       
    79 
       
    80     public: // NEW FUNCTIONS
       
    81 
       
    82         /**
       
    83         * Gets pointer to array entry at specified index.
       
    84         * @since 2.1
       
    85         * @param aIndex Index within the array of desired entry.
       
    86         * @return Pointer to entry.
       
    87         */
       
    88         virtual TAny* At(TInt aIndex) const
       
    89             {
       
    90             if (aIndex == KIndexPtr)
       
    91                 {
       
    92                     return *(TUint8**)iPtr + iKeyOffset;
       
    93                 }
       
    94             return *(TUint8**)iBase->Ptr(aIndex * sizeof(TUint8**)).Ptr() + iKeyOffset;
       
    95             }
       
    96 
       
    97         virtual TInt Compare(TInt aLeft, TInt aRight) const
       
    98             {
       
    99             NW_Ucs2* l=(*(NW_Ucs2**)At(aLeft));
       
   100             NW_Ucs2* r=(*(NW_Ucs2**)At(aRight));
       
   101             return( NW_Str_Strcmp( l, r ) );
       
   102             }
       
   103 
       
   104     };
       
   105 #endif // TKEYARRAYPTR_H   
       
   106             
       
   107 // End of File