|
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 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" ); |
|
13 _LIT( KText2,"hijk" ); |
|
14 _LIT( KText3,"lmnopqr" ); |
|
15 _LIT( KText4,"stuvwxyz" ); |
|
16 ... |
|
17 TBufC<8> buffer1( KText1 ); // a non-modifiable buffer descriptor |
|
18 TBuf<8> buffer2( Ktext2 ); // a modifiable buffer descriptor |
|
19 ... |
|
20 TPtrC ptr1( Ktext3 ); // a non-modifiable pointer descriptor |
|
21 TPtr ptr2; // a modifiable pointer descriptor |
|
22 ptr2 = buffer1.Des(); // pointing to the data in buffer1 |
|
23 ... |
|
24 HBufC* heapbuff = HBufC::NewL( 8 ); // a heap descriptor |
|
25 *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; |
|
26 ... |
|
27 descarray = new( ELeave ) CDesCArrayFlat( 5 ); |
|
28 ... |
|
29 descarray->AppendL( buffer1 ); |
|
30 descarray->AppendL( buffer2 ); |
|
31 descarray->AppendL( ptr1 ); |
|
32 descarray->AppendL( ptr2 ); |
|
33 descarray->AppendL( *heapbuff ); |
|
34 ... |
|
35 TInt len = descarray->MdcaPoint( 2 ).Length(); // information about |
|
36 // the third element |
|
37 ...</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; |
|
38 ... |
|
39 ptrcarray = new( ELeave ) CPtrCArray( 5 ); |
|
40 ... |
|
41 ptrcarray->AppendL( buffer1 ); |
|
42 ptrcarray->AppendL( buffer2 ); |
|
43 ptrcarray->AppendL( ptr1 ); |
|
44 ptrcarray->AppendL( ptr2 ); |
|
45 ptrcarray->AppendL( *heapbuff ); |
|
46 ... |
|
47 TInt len = ptrcarray->MdcaPoint( 2 ).Length(); // information about |
|
48 // the third element |
|
49 ...</codeblock> </li> </ol> </section> </conbody><related-links><link href="GUID-E8266924-FA52-5171-BD73-423A46227A74.dita"><linktext>Descriptor Arrays</linktext> </link> </related-links></concept> |