Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-FC24C65C-0DCB-5E07-9A68-9001D34664DD"><title>OR_LEAVE MACRO</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The <xref href="GUID-7EB97E3A-90F5-3536-B7AC-F6F55023E2F3.dita"><apiname>OR_LEAVE</apiname></xref> macro is a convenient macro that allows the application developer to de-emphasize auxiliary error checking code in most cases. It is a postfix macro which implements <xref href="GUID-C197C9A7-EA05-3F24-9854-542E984C612D.dita#GUID-C197C9A7-EA05-3F24-9854-542E984C612D/GUID-80E99D34-F4A1-36EA-AD64-E14ACAEC99B0"><apiname>User::LeaveIfError</apiname></xref> on an integer return type. This means that there is less focus on the error handling code and makes the code easier to read. </p> <section><title>Need for OR_Leave Macro</title> <p>Motive behind using a <xref href="GUID-7EB97E3A-90F5-3536-B7AC-F6F55023E2F3.dita"><apiname>OR_LEAVE</apiname></xref> macro is that it should not return an integer value. It is intended for use as a postfix macro at the end of a statement. If OR_LEAVE was to return an integer value, it would encourage its use in the middle of expressions negating its intended purpose which is to reduce the focus on error checking code. </p> </section> <example><title>Defining OR_Leave Macro</title> <p>The OR_LEAVE macro is defined as a postfix operator as shown below: </p> <codeblock id="GUID-DDB19E73-7D96-5D06-8EF9-AEC1248E8644" xml:space="preserve">
#define OR_LEAVE || ELeave
inline void operator||(TInt aStatus, TLeave /*aTag*/)
{
User::LeaveIfError(aStatus);
}
</codeblock> </example> <section><title>See Also</title> <p><xref href="GUID-B007634D-4D55-528A-8B85-6120C633AC8B.dita">EUser High Level Library Overview</xref> </p> <p><xref href="GUID-D33EB877-CCCB-527B-8AFC-4A8385C55E78.dita">EUser High Level Library Tutorials</xref> </p> </section> </conbody></concept>