lowlevellibsandfws/genericusabilitylib/inc/emisc.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef EMISC_H
       
    17 #define EMISC_H
       
    18 
       
    19 #include <e32base.h>
       
    20 
       
    21 /**
       
    22 	@file
       
    23 
       
    24 	Miscellaneous utilities that can help make code more readable.
       
    25 */
       
    26 
       
    27 /**
       
    28    A convenience postfix macro that is equivalent to wrapping the
       
    29    preceding expression with User::LeaveIfError().
       
    30 
       
    31    The code:
       
    32    @code
       
    33    fs.Connect() OR_LEAVE;
       
    34    @endcode
       
    35 
       
    36    is equivalent to:
       
    37 
       
    38    @code
       
    39    User::LeaveIfError(fs.Connect());
       
    40    @endcode
       
    41 
       
    42    The implementation happens to rely on overloading operator|| for
       
    43    TLeave. However, this macro is not intended for use within general
       
    44    expressions, just to guard individual calls to methods that may
       
    45    return an error code.
       
    46  */
       
    47 #define OR_LEAVE || ELeave
       
    48 
       
    49 /**
       
    50    Enabling overload for OR_LEAVE. Should only be invoked via
       
    51    OR_LEAVE, never directly.
       
    52  */
       
    53 inline void operator||(TInt aStatus, TLeave /*aTag*/)
       
    54 	{
       
    55 	User::LeaveIfError(aStatus);
       
    56 	}
       
    57 
       
    58 #endif // !EMISC_H
       
    59