Symbian3/SDK/Source/GUID-685CF352-372F-5393-97AF-1FA17DC57BA8.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-685CF352-372F-5393-97AF-1FA17DC57BA8"><title>Constructing Descriptor Arrays</title><shortdesc>Descriptor arrays provide normal array operations for inserting, appending, deleting, and accessing elements. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody><section><title>Procedure</title> <p>Follow the steps listed below to construct descriptor arrays: </p> <ol id="GUID-4957F727-EC6C-5DFF-B970-44DD0AB5E69C"><li id="GUID-69B3273C-1552-5B9C-816D-1398BFF49A6B"><p>Construct a set of descriptors. </p> <p>The following code fragments illustrate how to construct a <xref href="GUID-29384669-FFCE-38FC-A005-61163D99401D.dita"><apiname>CDesCArrayFlat</apiname></xref> and a <xref href="GUID-FC3F3E4A-C86C-3DDB-B851-538BF20D5B27.dita"><apiname>CPtrCArray</apiname></xref>. Both array types can accept any type of descriptor as source when adding a new array element. </p> <codeblock id="GUID-AEE8ABB8-CCCE-5263-8EA4-AD2D8898F4D4" xml:space="preserve">_LIT( KText1,"abcdefg" );
_LIT( KText2,"hijk" );
_LIT( KText3,"lmnopqr" );
_LIT( KText4,"stuvwxyz" );
...
TBufC&lt;8&gt; buffer1( KText1 );  // a non-modifiable buffer descriptor
TBuf&lt;8&gt;  buffer2( Ktext2 );  // a modifiable buffer descriptor
...
TPtrC  ptr1( Ktext3 );       // a non-modifiable pointer descriptor
TPtr   ptr2;                 // a modifiable pointer descriptor 
ptr2 = buffer1.Des();        // pointing to the data in buffer1
...
HBufC* heapbuff = HBufC::NewL( 8 );  // a heap descriptor
*heapbuff = KText4;</codeblock> <p> <b>Note:</b> Constructing and using a <xref href="GUID-1B44227C-6F11-3A51-BE2C-8780319C6F72.dita"><apiname>CDesCArraySeg</apiname></xref> is same as using <xref href="GUID-29384669-FFCE-38FC-A005-61163D99401D.dita"><apiname>CDesCArrayFlat</apiname></xref>. </p> </li> <li id="GUID-8A1E403F-FBA4-5A60-AAC4-7296BA7B160F"><p>Add the five descriptors to <xref href="GUID-29384669-FFCE-38FC-A005-61163D99401D.dita"><apiname>CDesCArrayFlat</apiname></xref> as shown in the following code. </p> <codeblock id="GUID-6DE21030-1887-53D8-8D04-B9DB0F69F647" xml:space="preserve">CDesCArrayFlat* descarray;
...
descarray = new( ELeave ) CDesCArrayFlat( 5 );
...
descarray-&gt;AppendL( buffer1 );
descarray-&gt;AppendL( buffer2 );
descarray-&gt;AppendL( ptr1 );
descarray-&gt;AppendL( ptr2 );
descarray-&gt;AppendL( *heapbuff );
...
TInt len = descarray-&gt;MdcaPoint( 2 ).Length();  // information about
                                                // the third element
...</codeblock> </li> <li id="GUID-EE266B93-2899-5D35-A0BF-569694574D5C"><p>Add the five descriptors to <xref href="GUID-FC3F3E4A-C86C-3DDB-B851-538BF20D5B27.dita"><apiname>CPtrCArray</apiname></xref> as shown in the following code. </p> <codeblock id="GUID-90A51320-7B9E-5DAD-A041-77FD6B2C3A37" xml:space="preserve">CPtrCArray* ptrcarray;
...
ptrcarray = new( ELeave ) CPtrCArray( 5 );
...
ptrcarray-&gt;AppendL( buffer1 );
ptrcarray-&gt;AppendL( buffer2 );
ptrcarray-&gt;AppendL( ptr1 );
ptrcarray-&gt;AppendL( ptr2 );
ptrcarray-&gt;AppendL( *heapbuff );
...
TInt len = ptrcarray-&gt;MdcaPoint( 2 ).Length();  // information about
                                                // the third element
...</codeblock> </li> </ol> </section> </conbody><related-links><link href="GUID-E8266924-FA52-5171-BD73-423A46227A74.dita"><linktext>Descriptor Arrays</linktext> </link> </related-links></concept>