CLiwDefaultMap Class Reference

class CLiwDefaultMap : public CLiwMap

An associative array or dictionary class. The collection key entries are of type string (Descriptor type) and their associated values can be an variant type.

CLiwDefaultMap provides default map implementation to
  • insert a key-value pair

  • find a stored value based on a key

  • get a key based on an index

  • remove a key-value pair based on a key

  • get the total number of stored key-value pairs

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 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::PushLTLiwVariant CLiwMap

Inherits from

Constructor & Destructor Documentation

CLiwDefaultMap(CLiwGenericParamList *)

CLiwDefaultMap(CLiwGenericParamList *aMap)[private, inline]

Parameters

CLiwGenericParamList * aMap

~CLiwDefaultMap()

IMPORT_C~CLiwDefaultMap()[private, virtual]

Member Functions Documentation

AtL(TInt, TDes8 &)

IMPORT_C TBoolAtL(TIntaIndex,
TDes8 &aFndKey
)const [virtual]

Returns the key stored at a specified index.

 void FindAnEntryL()
 {
 	_LIT8(KKey,"firstName");
 	TBuf8<128> pbkFieldKeyVal(KKey);
   
 	TInt nIndex=0;
	CLiwDefaultMap* pMap = CLiwDefaultMap::NewL();
	pMap->PushL();

	if(EFalse!=pMap->AtL(nIndex, pbkFieldKeyVal))
   {
			//key value has been found
   }

	CleanupStack::Pop(pMap); 
	pMap->DecRef(); 
 }			

Parameters

TInt aIndexthe index of the key to be found
TDes8 & aFndKeythe key found at the passed index

AtL(TInt)

IMPORT_C const TDesC8 &AtL(TIntaIndex)const

Returns the key stored at a specified index.

 void FindAnEntryL()
 {
 	_LIT8(KKey,"firstName");
 	TBuf8<128> pbkFieldKeyVal(KKey);
   
 	TInt nIndex=0;
	CLiwDefaultMap* pMap = CLiwDefaultMap::NewL();
	pMap->PushL();

	pbkFieldKeyVal = pMap->AtL(nIndex);
	if(pbkFieldKeyVal)			
   {
		//key value has been found
  	}

	CleanupStack::Pop(pMap); 
	pMap->DecRef(); 
 }			

Parameters

TInt aIndexthe index of the key to be found

Count()

IMPORT_C TIntCount()const [virtual]

Returns the number of key-value pair stored in the map collection.

ExternalizeL(RWriteStream &)

voidExternalizeL(RWriteStream &aOutputStream)const [virtual]

The container managed data values can be serialized to an output stream.

RWiteStream

Parameters

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

FindL(const TDesC8 &, TLiwVariant &)

IMPORT_C TBoolFindL(const TDesC8 &aKey,
TLiwVariant &aValue
)const [virtual]

Finds a value stored in the map collection based on the key.

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

This is a copy of the value present in the map for the particular key. To ensure proper cleanup TLiwVariant::PushL method should be called beforehand.

 void FindAnEntryL()
 {
 	_LIT8(KKey,"firstName");
 	TBuf8<128> pbkFieldKey(KKey);
   TLiwVariant firstNameVal;
	firstNameVal.PushL();

	CLiwDefaultMap* pMap = CLiwDefaultMap::NewL();
	pMap->PushL();
 	if(EFalse!=pMap->FindL(pbkFieldKey, firstNameVal))
   {
			//key value has been found
   }  
	
	CleanupStack::PopAndDestroy(pMap);
	CleanupStack::PopAndDestroy(firstNameVal);
 }			

TLiwVariant::PushL

Parameters

const TDesC8 & aKeythe key to be searched
TLiwVariant & aValue

InsertL(const TDesC8 &, const TLiwVariant &)

IMPORT_C voidInsertL(const TDesC8 &aKey,
const TLiwVariant &aValue
)[virtual]

Inserts a key-value pair element to the map collection. If the specified key already exists, it will be removed from the collection and the new key-value pair will be added to the map.

 void AddMapEntryL(const TDesC* ptrFirstNameVal)
 {
 	_LIT8(KKey,"firstName");
 	TBuf8<128> pbkFieldKey(KKey);

	CLiwDefaultMap* pMap = CLiwDefaultMap::NewL();
   pMap->PushL();	//pushes the map into cleanupstack using CleanupClosePushL
 	pMap->InsertL(pbkFieldKey, TLiwVariant(*ptrFirstNameVal));  
   CleanupStack::Pop(pMap);
	pMap->DecRef();
 }			
    *

Parameters

const TDesC8 & aKeythe key to be stored
const TLiwVariant & aValuethe value associated with the key to be stored

NewL()

IMPORT_C CLiwDefaultMap *NewL()[static]

NewLC()

IMPORT_C CLiwDefaultMap *NewLC()[static]

NewLC(RReadStream &)

IMPORT_C CLiwDefaultMap *NewLC(RReadStream &aInputStream)[static]

Parameters

RReadStream & aInputStream

Remove(const TDesC8 &)

IMPORT_C voidRemove(const TDesC8 &aKey)[virtual]

Removes a key from the map collection.

 void RemoveMapEntryL(const TDesC* ptrFirstNameVal)
 {
 	_LIT8(KKey,"firstName");
 	TBuf8<128> pbkFieldKey(KKey);
	CLiwDefaultMap* pMap = CLiwDefaultMap::NewL();
	pMap->PushL();

 	pMap->InsertL(pbkFieldKey, TLiwVariant(*ptrFirstNameVal));  
	pMap->Remove(pbkFieldKey);

	if(0==pMap->Count())
	{
		//no entries stored; removal successful
	}
	
	CleanupStack::Pop(pMap);
	pMap->DecRef();
 }			

Parameters

const TDesC8 & aKeythe key to be removed from the map

Size()

IMPORT_C TIntSize()const [virtual]

Returns the size of the collection. The size is calculated based on the total numer of key-value elements and the size of each pair in the collection

Member Data Documentation

CLiwGenericParamList * iMap

CLiwGenericParamList *iMap[private]