CLiwDefaultList Class Reference

class CLiwDefaultList : public CLiwList

An ordered collection or sequence. CLiwDefaultList providers a default implementation for CLiwList. The collection entries are typically of type TLiwVarian.

This class provides concrete implementation to:
  • access elements based on index

  • remove an element

  • append an element to the end of the list collection

  • get the total number of elements stored in the list collection

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Since container objects are reference counted, they cannot go with CleanupStack::PushL. The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. Hence CLiwContainer::Close method is introduced common to all container objects.

This implies that the object of this concrete implementation class being created should be pushed into the CleanupStack using CLiwContainer::PushL.

ServiceHandler.lib

CLiwContainer CLiwContainer::Close CLiwContainer::PushLCLiwList TLiwVariant

Inherits from

Constructor & Destructor Documentation

CLiwDefaultList(CLiwGenericParamList *)

CLiwDefaultList(CLiwGenericParamList *aList)[private, inline]

Parameters

CLiwGenericParamList * aList

~CLiwDefaultList()

IMPORT_C~CLiwDefaultList()[private, virtual]

Member Functions Documentation

AppendL(const TLiwVariant &)

IMPORT_C voidAppendL(const TLiwVariant &aEntry)[virtual]

Appends an entry to the end of the collection. The entry to be added is of type TLiwVariant.

A string content being added to the end of the collection

 _LIT8(KLitPbkService,"PhoneBookService");
 CLiwDefaultList* pList = CLiwDefaultList::NewL();
 pList->PushL();
 pList->AppendL(TLiwVariant(KLitPbkService));
 CleanupStack::Pop(pList);
 pList->DecRef();

An integer value being added to the end of the collection

 CLiwDefaultList* pList = CLiwDefaultList::NewL();
 pList->PushL();
 TInt intVal=0; 
 pList->AppendL(TLiwVariant(intVal));
 CleanupStack::Pop(pList);
 pList->DecRef();

Parameters

const TLiwVariant & aEntryan Element to be added to the end of the collection

AtL(TInt, TLiwVariant &)

IMPORT_C TBoolAtL(TIntaIndex,
TLiwVariant &aEntry
)const [virtual]

Gets an entry from the collection based on an integeral index.

!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

This is a copy of the value present in the list at the particular index. To ensure proper cleanup TLiwVariant::PushL method should be called beforehand.

An integral value being retrieved from the collection

 CLiwDefaultList* pList = CLiwDefaultList::NewL();
 pList->PushL();
 TInt intVal=1100; //some magic number
 pList->AppendL(TLiwVariant(intVal));

 TInt nIndex=0; //only one entry is stored..
 TLiwVariant valFnd;
 valFnd.PushL(); //Pushes the TLiwVariant into the CleanupStack using TCleanupItem
 if(EFalse!=pList->AtL(nIndex,valFnd))
 {
 	TInt intValFnd=-1;
   valFnd.Get(intValFnd);
 }
 
 CleanupStack::PopAndDestroy(valFnd); //Pops and Destroys the TLiwVariant object
 CleanupStack::Pop(pList);
 pList->DecRef();

TLiwVariant::PushL

Parameters

TInt aIndexto get an entry from the collection
TLiwVariant & aEntrythe returned element from the collection

Count()

IMPORT_C TIntCount()const [virtual]

Returns the number of elements present in the collection.

ExternalizeL(RWriteStream &)

IMPORT_C voidExternalizeL(RWriteStream &aOutputStream)const [virtual]

Serializes the collection data entries to an output stream.

RWiteStream

Parameters

RWriteStream & aOutputStreamthe output stream to which the data will be streamed

NewL()

IMPORT_C CLiwDefaultList *NewL()[static]

Creates and returns a new instace of CLiwDefaultList

 void CreateListL()
 {
 	CLiwDefaultList* pList = CLiwDefaultList::NewL();
   pList->PushL();	//pushes the List into cleanupstack using CleanupClosePushL
 	
	CleanupStack::Pop(pList);
	pList->DecRef();
 }			

@ see PushL @ see Close

NewLC()

IMPORT_C CLiwDefaultList *NewLC()[static]

Creates and returns a new instace of CLiwDefaultList

 void CreateListL()
 {
 	CLiwDefaultList* pList = CLiwDefaultList::NewLC(); //pushes the List into cleanupstack using CleanupClosePushL
   
	CleanupStack::Pop(pList);
	pList->DecRef();
 }			

@ see PushL @ see Close

NewLC(RReadStream &)

CLiwDefaultList *NewLC(RReadStream &aInputStream)[static]

Creates and returns a new instace of CLiwDefaultList. The collection elements will be generated from the data values read from the input stream. This method leaves the created instance in the cleanup stack.

Parameters

RReadStream & aInputStreamthe input stream containing the data values to append to the list collection

Remove(TInt)

IMPORT_C voidRemove(TIntaIndex)[virtual]

Removes an element located at the passed index from the collection.

An element being removed from the collection

 CLiwDefaultList* pList = CLiwDefaultList::NewL();
 pList->PushL();
 TInt intVal=1100; //some magic number
 pList->AppendL(TLiwVariant(intVal));

 TInt nIndex=0; //only one entry is stored..
 pList->Remove(nIndex);

 if(0==pList->Count())
 {
 	//should be zero
 }
  
 CleanupStack::Pop(pList);
 pList->DecRef();

Parameters

TInt aIndexthe index of the element to be removed from the collection

Size()

IMPORT_C TIntSize()const [virtual]

Returns the size of the collection. The size is calculated based on the total numer of elements and the size of each element in the collection

Member Data Documentation

CLiwGenericParamList * iList

CLiwGenericParamList *iList[private]