Descriptor arrays provide normal array operations for inserting, appending, deleting, and accessing elements.
Follow the steps listed below to construct descriptor arrays:
Construct a set of descriptors.
The following code fragments illustrate how to construct a CDesCArrayFlat and a CPtrCArray . Both array types can accept any type of descriptor as source when adding a new array element.
_LIT( KText1,"abcdefg" );
_LIT( KText2,"hijk" );
_LIT( KText3,"lmnopqr" );
_LIT( KText4,"stuvwxyz" );
...
TBufC<8> buffer1( KText1 ); // a non-modifiable buffer descriptor
TBuf<8> 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;
Note: Constructing and using a CDesCArraySeg is same as using CDesCArrayFlat .
Add the five descriptors to CDesCArrayFlat as shown in the following code.
CDesCArrayFlat* descarray;
...
descarray = new( ELeave ) CDesCArrayFlat( 5 );
...
descarray->AppendL( buffer1 );
descarray->AppendL( buffer2 );
descarray->AppendL( ptr1 );
descarray->AppendL( ptr2 );
descarray->AppendL( *heapbuff );
...
TInt len = descarray->MdcaPoint( 2 ).Length(); // information about
// the third element
...
Add the five descriptors to CPtrCArray as shown in the following code.
CPtrCArray* ptrcarray;
...
ptrcarray = new( ELeave ) CPtrCArray( 5 );
...
ptrcarray->AppendL( buffer1 );
ptrcarray->AppendL( buffer2 );
ptrcarray->AppendL( ptr1 );
ptrcarray->AppendL( ptr2 );
ptrcarray->AppendL( *heapbuff );
...
TInt len = ptrcarray->MdcaPoint( 2 ).Length(); // information about
// the third element
...
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.