Symbian3/PDK/Source/GUID-F3090A98-267F-5310-83F4-93FD5CB760D6.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-F3090A98-267F-5310-83F4-93FD5CB760D6" xml:lang="en"><title>Using
       
    13 CCirBuf</title><shortdesc>This document describes how to use CCirBuf.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <section id="GUID-92DAE8AD-1D5A-40CA-AA36-C1E0A3648D77"><title>Before adding/removing objects</title> <p>The buffer itself
       
    15 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.
       
    16 Therefore, the first steps must always be to construct the <xref href="GUID-1D73835F-4361-3216-8EFC-669364E3F5E7.dita"><apiname>CCirBuf</apiname></xref> object
       
    17 and then call its <codeph>CCirBufBase::SetLengthL()</codeph> member function.</p> <p>Also
       
    18 note that <codeph>SetLengthL()</codeph> can leave so it's useful to call it
       
    19 under a trap harness.</p> <codeblock id="GUID-FED3E087-48D8-53EC-911D-12475D2B8905" xml:space="preserve">class Test
       
    20  {
       
    21 public:
       
    22  Test(){a=b=0;}
       
    23  Test(TInt anInt){a=b=anInt;}
       
    24 private
       
    25  TInt a;
       
    26  TInt b;
       
    27  };</codeblock> <codeblock id="GUID-3AAF1D67-BB67-5019-9D11-AB17E18254A3" xml:space="preserve">
       
    28 CCirBuf&lt;Test&gt;* cbInt=new CCirBuf&lt;Test&gt;;
       
    29 TRAPD(ret,cbInt-&gt;SetLengthL(3));            // max capacity is 3
       
    30                                             // and allocates buffer
       
    31 Test one(1);
       
    32 Test two(2);
       
    33 ...
       
    34 cbInt-&gt;Add(&amp;one);     // Can now start adding/removing objects
       
    35 ...
       
    36 delete cbInt;</codeblock> </section>
       
    37 </conbody></concept>