contentstorage/cautils/inc/caarraycleanup.inl
changeset 60 f62f87b200ec
equal deleted inserted replaced
4:1a2a00e78665 60:f62f87b200ec
       
     1 /*
       
     2  * Copyright (c) 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:  ?Description
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef CA_CLENAUPARRAY_
       
    19 #define CA_CLENAUPARRAY_
       
    20 
       
    21 /**
       
    22  * Cleanup support method. Call ResetAndDestroy() on the array.
       
    23  * @param RPointerArray* as TAny*
       
    24  */
       
    25 template<class T>
       
    26 inline void ArrayResetAndDestroy( TAny* aArray )
       
    27     {
       
    28     ( reinterpret_cast<RPointerArray<T>*> ( aArray ) )->ResetAndDestroy();
       
    29     }
       
    30 
       
    31 /**
       
    32  * Push a ResetAndDestroy() on the cleanup stack.
       
    33  * @param aArray Array.
       
    34  */
       
    35 template<class T>
       
    36 inline void CleanupResetAndDestroyPushL( RPointerArray<T>& aArray )
       
    37     {
       
    38     void(*pointerToFunction)( TAny* ) = ArrayResetAndDestroy<T>;
       
    39     TCleanupItem item( pointerToFunction,
       
    40             reinterpret_cast<TAny*> ( &aArray ) );
       
    41     CleanupStack::PushL( item );
       
    42     }
       
    43 
       
    44 #endif