diff -r 000000000000 -r 638b9c697799 apicompatanamdw/compatanalysercmd/headeranalyser/src/TChange.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apicompatanamdw/compatanalysercmd/headeranalyser/src/TChange.h Tue Jan 12 14:52:39 2010 +0530 @@ -0,0 +1,113 @@ +/* +* 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: +* +*/ + + +#ifndef __TCHANGE_H__ +#define __TCHANGE_H__ + +#include +#include +#include + +using namespace std; + +/** +* This template is used for making it a little easier to keep information about +* which files the value is associated, namely base and current files. +* At the moment used only in MacroAnalyser. +*/ +template class TChange +{ +public: + TChange(string aBase, KTvalue aValue); + TChange(string aBase, string aCurrent, KTvalue aValue); + ~TChange(void); + string GetBase(); + string GetCurrent(); + KTvalue& GetValue(); + void SetBase(string aBase); + void SetCurrent(string aCurrent); + void SetValue(KTvalue aValue); +private: + pair, KTvalue> iValue; +}; + +template TChange::TChange(string aBase, KTvalue aValue) +{ + iValue.first.push_back(aBase); + iValue.second = aValue; +} + +template TChange::TChange(string aBase, string aCurrent, KTvalue aValue) +{ + iValue.first.push_back(aBase); + iValue.first.push_back(aCurrent); + iValue.second = aValue; +} + +template TChange::~TChange(void) +{ +} + +template string TChange::GetBase() +{ + return iValue.first.front(); +} + +template string TChange::GetCurrent() +{ + string ret; + if (iValue.first.size() == 2) + { + ret = iValue.first.back(); + } else + { + ret = ""; + } + + return ret; +} + +template KTvalue& TChange::GetValue() +{ + return iValue.second; +} + +template void TChange::SetBase(string aBase) +{ + iValue.first.pop_front(); + iValue.first.push_front(aBase); +} + +template void TChange::SetCurrent(string aCurrent) +{ + if (iValue.first.size() == 2) + { + iValue.first.pop_back(); + iValue.first.push_back(aCurrent); + } else + { + iValue.first.push_back(aCurrent); + } +} + +template void TChange::SetValue(KTvalue aValue) +{ + iValue.second = aValue; +} + +#endif