menufw/hierarchynavigator/hnmetadatamodel/inc/hnhelper.inl
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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 "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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HNHELPER_H
       
    20 #define HNHELPER_H
       
    21 
       
    22 #include <e32hashtab.h>
       
    23 
       
    24 /**
       
    25  * Creates hash.
       
    26  * 
       
    27  * @param aBuf Descriptor.
       
    28  * @return Hash.
       
    29  */
       
    30 inline TUint32 HBuf16Hash( HBufC16* const &  aBuf )
       
    31     {
       
    32     return DefaultHash::Des16(*aBuf);
       
    33     }
       
    34     
       
    35 /**
       
    36  * Creates hash.
       
    37  * 
       
    38  * @param aBuf Descriptor.
       
    39  * @return Hash.
       
    40  */
       
    41 inline TUint32 TDesC16Hash( const TDesC16* const &  aBuf )
       
    42     {
       
    43     return DefaultHash::Des16(*aBuf);
       
    44     }
       
    45 
       
    46 /**
       
    47  * Checks for indentity.
       
    48  * 
       
    49  * @param aL Descriptor.
       
    50  * @param aR Descriptor.
       
    51  * @return Bool.
       
    52  */
       
    53 inline TBool HBuf16Ident( HBufC16* const & aL, HBufC16* const & aR )
       
    54     {
       
    55     return DefaultIdentity::Des16(*aL, *aR);
       
    56     }
       
    57 
       
    58 /**
       
    59  * Checks for indentity.
       
    60  * 
       
    61  * @param aL Descriptor.
       
    62  * @param aR Descriptor.
       
    63  * @return Bool.
       
    64  */
       
    65 inline TBool TDesC16Ident( const TDesC16* const & aL, const TDesC16* const & aR )
       
    66     {
       
    67     return DefaultIdentity::Des16(*aL, *aR);
       
    68     }
       
    69 
       
    70 /**
       
    71  * Destroys both key and value object of a hashmap.
       
    72  */
       
    73 template <class TKey, class TValue>
       
    74 void DestroyMapKeyAndValue( RHashMap< TKey*, TValue* > & aHashMap )
       
    75 	{
       
    76 	THashMapIter< TKey*, TValue* > iter( aHashMap );
       
    77 	while ( iter.NextKey() )
       
    78 		{
       
    79 		delete *(iter.CurrentKey());
       
    80 		delete *(iter.CurrentValue());
       
    81 		}
       
    82 	}
       
    83 
       
    84 /**
       
    85  * Destroys just value object of a hashmap.
       
    86  */
       
    87 template <class TKey, class TValue>
       
    88 void DestroyMapValue( RHashMap< TKey*, TValue* > & aHashMap )
       
    89 	{
       
    90 	THashMapIter< TKey*, TValue* > iter( aHashMap );
       
    91 	while ( iter.NextKey() )
       
    92 		{
       
    93 		delete *(iter.CurrentValue());
       
    94 		}
       
    95 	}
       
    96 
       
    97 #endif /* HNHELPER_H */