sl@0: /* sl@0: * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "appuidmap.h" sl@0: #include sl@0: sl@0: struct AppMapEntry sl@0: { sl@0: std::string iDef; sl@0: TInt32 iLastDefFileIndex; sl@0: }; sl@0: typedef std::map AppMap; sl@0: sl@0: // sl@0: // Local static vars. This avoids including map etc in the header sl@0: // sl@0: static AppMap sAppMap; sl@0: sl@0: bool AppUidMap::InsertUidDefinition(TInt32 aUid, const std::string &aDef, TInt32 aInputFileIndex, sl@0: TInt32 &aLastIndex, std::string &aFirstDef) sl@0: { sl@0: AppMapEntry val; sl@0: val.iDef = aDef; sl@0: val.iLastDefFileIndex = aInputFileIndex; sl@0: AppMap::value_type e(aUid, val); sl@0: std::pair result = sAppMap.insert(e); sl@0: if(result.second == true) sl@0: { sl@0: // Inserted new entry sl@0: return true; sl@0: } sl@0: // Duplicate. sl@0: // Save fileIndex of previous definition sl@0: aLastIndex = (result.first)->second.iLastDefFileIndex; sl@0: aFirstDef = (result.first)->second.iDef; sl@0: // Update location of last seen def sl@0: (result.first)->second.iLastDefFileIndex = aInputFileIndex; sl@0: sl@0: return false; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: static EnumEntry *sEnumEntries = 0; sl@0: sl@0: void AppUidMap::GenerateEnumEntries() sl@0: { sl@0: delete [] sEnumEntries; sl@0: sEnumEntries = new EnumEntry[sAppMap.size()+1]; sl@0: sEnumEntries[sAppMap.size()].iName=0; // Terminate array sl@0: sl@0: AppMap::const_iterator it = sAppMap.begin(); sl@0: for(TUint32 i=0; i < sAppMap.size(); ++i) sl@0: { sl@0: sEnumEntries[i].iName = (*it).second.iDef.c_str(); sl@0: sEnumEntries[i].iValue = (*it).first; sl@0: ++it; sl@0: } sl@0: } sl@0: sl@0: sl@0: EnumEntry *AppUidMap::EnumEntries() sl@0: { sl@0: BULLSEYE_OFF sl@0: if(sEnumEntries == 0) FatalError(); sl@0: BULLSEYE_RESTORE sl@0: return sEnumEntries; sl@0: } sl@0: sl@0: // End of file