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.
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
Public Member Functions | |
---|---|
IMPORT_C TBool | AtL(TInt, TDes8 &) |
IMPORT_C const TDesC8 & | AtL(TInt) |
IMPORT_C TInt | Count() |
void | ExternalizeL(RWriteStream &) |
IMPORT_C TBool | FindL(const TDesC8 &, TLiwVariant &) |
IMPORT_C void | InsertL(const TDesC8 &, const TLiwVariant &) |
IMPORT_C CLiwDefaultMap * | NewL() |
IMPORT_C CLiwDefaultMap * | NewLC() |
IMPORT_C CLiwDefaultMap * | NewLC(RReadStream &) |
IMPORT_C void | Remove(const TDesC8 &) |
IMPORT_C TInt | Size() |
Private Member Functions | |
---|---|
CLiwDefaultMap(CLiwGenericParamList *) | |
~CLiwDefaultMap() |
Private Attributes | |
---|---|
CLiwGenericParamList * | iMap |
CLiwDefaultMap | ( | CLiwGenericParamList * | aMap | ) | [private, inline] |
CLiwGenericParamList * aMap |
IMPORT_C TBool | AtL | ( | TInt | aIndex, |
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(); }
IMPORT_C const TDesC8 & | AtL | ( | TInt | aIndex | ) | 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(); }
TInt aIndex | the index of the key to be found |
IMPORT_C TInt | Count | ( | ) | const [virtual] |
Returns the number of key-value pair stored in the map collection.
void | ExternalizeL | ( | RWriteStream & | aOutputStream | ) | const [virtual] |
The container managed data values can be serialized to an output stream.
RWiteStream
RWriteStream & aOutputStream | the output stream to which the data will be streamed |
IMPORT_C TBool | FindL | ( | 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); }
const TDesC8 & aKey | the key to be searched |
TLiwVariant & aValue |
IMPORT_C void | InsertL | ( | 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(); } *
const TDesC8 & aKey | the key to be stored |
const TLiwVariant & aValue | the value associated with the key to be stored |
IMPORT_C CLiwDefaultMap * | NewLC | ( | RReadStream & | aInputStream | ) | [static] |
RReadStream & aInputStream |
IMPORT_C void | Remove | ( | 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(); }
const TDesC8 & aKey | the key to be removed from the map |
IMPORT_C TInt | Size | ( | ) | 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
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.