sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef EMISC_H sl@0: #define EMISC_H sl@0: sl@0: #include sl@0: sl@0: /** sl@0: @file sl@0: sl@0: Miscellaneous utilities that can help make code more readable. sl@0: */ sl@0: sl@0: /** sl@0: A convenience postfix macro that is equivalent to wrapping the sl@0: preceding expression with User::LeaveIfError(). sl@0: sl@0: The code: sl@0: @code sl@0: fs.Connect() OR_LEAVE; sl@0: @endcode sl@0: sl@0: is equivalent to: sl@0: sl@0: @code sl@0: User::LeaveIfError(fs.Connect()); sl@0: @endcode sl@0: sl@0: The implementation happens to rely on overloading operator|| for sl@0: TLeave. However, this macro is not intended for use within general sl@0: expressions, just to guard individual calls to methods that may sl@0: return an error code. sl@0: */ sl@0: #define OR_LEAVE || ELeave sl@0: sl@0: /** sl@0: Enabling overload for OR_LEAVE. Should only be invoked via sl@0: OR_LEAVE, never directly. sl@0: */ sl@0: inline void operator||(TInt aStatus, TLeave /*aTag*/) sl@0: { sl@0: User::LeaveIfError(aStatus); sl@0: } sl@0: sl@0: #endif // !EMISC_H sl@0: