diff -r 000000000000 -r 638b9c697799 apicompatanamdw/compatanalysercmd/headeranalyser/src/AnalyserParams.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apicompatanamdw/compatanalysercmd/headeranalyser/src/AnalyserParams.cpp Tue Jan 12 14:52:39 2010 +0530 @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "CmdGlobals.h" +#ifdef __WIN__ +#pragma warning(disable:4786) +#endif + +#include +#include +#include "HAException.h" +#include "AnalyserParams.h" + + +using namespace std; + + +// ---------------------------------------------------------------------------- +// AnalyserParams::parameterExists +// Return true, if the parameter parameter is given +// ---------------------------------------------------------------------------- +// +bool AnalyserParams::parameterExists(const string& aParm) +{ + bool ret = false; + map >::iterator mapitem = iParameters.find(aParm); + if (mapitem != iParameters.end()) + { + ret = true; + } + return ret; +} + +// ---------------------------------------------------------------------------- +// AnalyserParams::givenParameter +// Return true, if the parameter parameter is given +// ---------------------------------------------------------------------------- +// +bool AnalyserParams::givenParameter(const string& aParm) +{ + bool ret = false; + map >::iterator mapitem = iParameters.find(aParm); + if (mapitem != iParameters.end()) + { + ret = mapitem->second.second; + } + return ret; +} + +// ---------------------------------------------------------------------------- +// AnalyserParams::storeParameter +// Store given parameter to parameter map +// ---------------------------------------------------------------------------- +// +void AnalyserParams::storeParameter(string aParm, string aVal, bool aFromCmdline) +{ + pair >parameter(aParm,pair(aVal,aFromCmdline)); + map >::iterator mapitem = iParameters.find(aParm); + bool isValidParm = mapitem == iParameters.end() ? false : true; + if (!isValidParm) + { + iParameters.insert(parameter); + } + else + { + if (((*mapitem).second).second == true) + { + (*mapitem).second = pair(aVal,true); + } + else + { + (*mapitem).second = pair(aVal,aFromCmdline); + } + } +} + +// ---------------------------------------------------------------------------- +// AnalyserParams::getParameter +// Store given parameter value +// ---------------------------------------------------------------------------- +// +string AnalyserParams::getParameter(const string& aParm) +{ + map >::iterator mapitem = iParameters.find(aParm); + bool isValidParm = mapitem == iParameters.end() ? false : true; + if (!isValidParm) + { + string excstr = "No such parameter: "; + excstr += aParm; + throw HAException(excstr); + } + return (mapitem->second).first; +} + +// ---------------------------------------------------------------------------- +// AnalyserParams::getGivenParameters +// ---------------------------------------------------------------------------- +// +const map AnalyserParams::getGivenParameters() +{ + map givenparams; + map >::iterator begin = iParameters.begin(); + map >::iterator end = iParameters.end(); + map >::iterator find; + map >::iterator endfind = iParameters.end(); + while(begin != end) + { + string param = (*begin).first; + pair values = (*begin).second; + string val; + if(values.second == true) + { + val = values.first; + if (param == BASELINEDIR) + { + find = iParameters.find(BASELINE); + if (find != iParameters.end()) + { + val += DIR_SEPARATOR; + val += ((*find).second).first; + } + } + if (param == BASELINE) + { + find = iParameters.find(BASELINEDIR); + val = ((*find).second).first; + val += DIR_SEPARATOR; + val += values.first; + } + if (param == CURRENT) + { + find = iParameters.find(CURRENTDIR); + val = ((*find).second).first; + val += DIR_SEPARATOR; + val += values.first; + } + givenparams.insert(pair(param,val)); + } + ++begin; + } + return givenparams; +}