Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"
<?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 id="GUID-F3090A98-267F-5310-83F4-93FD5CB760D6" xml:lang="en"><title>Using
CCirBuf</title><shortdesc>This document describes how to use CCirBuf.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-92DAE8AD-1D5A-40CA-AA36-C1E0A3648D77"><title>Before adding/removing objects</title> <p>The buffer itself
is not allocated until <xref href="GUID-FA17C8AD-BF8C-3FD4-98AE-43AF55A9D318.dita#GUID-FA17C8AD-BF8C-3FD4-98AE-43AF55A9D318/GUID-4658AA47-E3E6-3325-A4DF-FACADFA5BBB2"><apiname>CCirBufBase::SetLengthL()</apiname></xref> is called.
Therefore, the first steps must always be to construct the <xref href="GUID-1D73835F-4361-3216-8EFC-669364E3F5E7.dita"><apiname>CCirBuf</apiname></xref> object
and then call its <codeph>CCirBufBase::SetLengthL()</codeph> member function.</p> <p>Also
note that <codeph>SetLengthL()</codeph> can leave so it's useful to call it
under a trap harness.</p> <codeblock id="GUID-FED3E087-48D8-53EC-911D-12475D2B8905" xml:space="preserve">class Test
{
public:
Test(){a=b=0;}
Test(TInt anInt){a=b=anInt;}
private
TInt a;
TInt b;
};</codeblock> <codeblock id="GUID-3AAF1D67-BB67-5019-9D11-AB17E18254A3" xml:space="preserve">
CCirBuf<Test>* cbInt=new CCirBuf<Test>;
TRAPD(ret,cbInt->SetLengthL(3)); // max capacity is 3
// and allocates buffer
Test one(1);
Test two(2);
...
cbInt->Add(&one); // Can now start adding/removing objects
...
delete cbInt;</codeblock> </section>
</conbody></concept>