1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/emisc.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,59 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef EMISC_H
1.20 +#define EMISC_H
1.21 +
1.22 +#include <e32base.h>
1.23 +
1.24 +/**
1.25 + @file
1.26 +
1.27 + Miscellaneous utilities that can help make code more readable.
1.28 +*/
1.29 +
1.30 +/**
1.31 + A convenience postfix macro that is equivalent to wrapping the
1.32 + preceding expression with User::LeaveIfError().
1.33 +
1.34 + The code:
1.35 + @code
1.36 + fs.Connect() OR_LEAVE;
1.37 + @endcode
1.38 +
1.39 + is equivalent to:
1.40 +
1.41 + @code
1.42 + User::LeaveIfError(fs.Connect());
1.43 + @endcode
1.44 +
1.45 + The implementation happens to rely on overloading operator|| for
1.46 + TLeave. However, this macro is not intended for use within general
1.47 + expressions, just to guard individual calls to methods that may
1.48 + return an error code.
1.49 + */
1.50 +#define OR_LEAVE || ELeave
1.51 +
1.52 +/**
1.53 + Enabling overload for OR_LEAVE. Should only be invoked via
1.54 + OR_LEAVE, never directly.
1.55 + */
1.56 +inline void operator||(TInt aStatus, TLeave /*aTag*/)
1.57 + {
1.58 + User::LeaveIfError(aStatus);
1.59 + }
1.60 +
1.61 +#endif // !EMISC_H
1.62 +