git repos / blockattack-game

blame: source/code/common.cpp

normal view · raw

89c4a3a6 sago007 2008-08-29 14:32 1
/*
c53e6443 sago007 2012-04-17 11:04 2
===========================================================================
c53e6443 sago007 2012-04-17 11:04 3
blockattack - Block Attack - Rise of the Blocks
c53e6443 sago007 2012-04-17 11:04 4
Copyright (C) 2005-2012 Poul Sander
c53e6443 sago007 2012-04-17 11:04 5
c53e6443 sago007 2012-04-17 11:04 6
This program is free software: you can redistribute it and/or modify
c53e6443 sago007 2012-04-17 11:04 7
it under the terms of the GNU General Public License as published by
c53e6443 sago007 2012-04-17 11:04 8
the Free Software Foundation, either version 2 of the License, or
c53e6443 sago007 2012-04-17 11:04 9
(at your option) any later version.
c53e6443 sago007 2012-04-17 11:04 10
c53e6443 sago007 2012-04-17 11:04 11
This program is distributed in the hope that it will be useful,
c53e6443 sago007 2012-04-17 11:04 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
c53e6443 sago007 2012-04-17 11:04 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c53e6443 sago007 2012-04-17 11:04 14
GNU General Public License for more details.
c53e6443 sago007 2012-04-17 11:04 15
c53e6443 sago007 2012-04-17 11:04 16
You should have received a copy of the GNU General Public License
c53e6443 sago007 2012-04-17 11:04 17
along with this program.  If not, see http://www.gnu.org/licenses/
c53e6443 sago007 2012-04-17 11:04 18
c53e6443 sago007 2012-04-17 11:04 19
Source information and contacts persons can be found at
c53e6443 sago007 2012-04-17 11:04 20
http://blockattack.sf.net
c53e6443 sago007 2012-04-17 11:04 21
===========================================================================
89c4a3a6 sago007 2008-08-29 14:32 22
*/
89c4a3a6 sago007 2008-08-29 14:32 23
89c4a3a6 sago007 2008-08-29 14:32 24
#include "common.h"
769a41a0 sago007 2008-09-24 12:54 25
#include <sstream>
769a41a0 sago007 2008-09-24 12:54 26
444cec07 sago007 2012-05-05 16:42 27
static stringstream converter;
444cec07 sago007 2012-05-05 16:42 28
769a41a0 sago007 2008-09-24 12:54 29
//Function to convert numbers to string
769a41a0 sago007 2008-09-24 12:54 30
string itoa(int num)
769a41a0 sago007 2008-09-24 12:54 31
{
444cec07 sago007 2012-05-05 16:42 32
	converter.str(std::string());
444cec07 sago007 2012-05-05 16:42 33
	converter.clear();
c53e6443 sago007 2012-04-17 11:04 34
	converter << num;
c53e6443 sago007 2012-04-17 11:04 35
	return converter.str();
769a41a0 sago007 2008-09-24 12:54 36
}
769a41a0 sago007 2008-09-24 12:54 37
769a41a0 sago007 2008-09-24 12:54 38
string double2str(double num)
769a41a0 sago007 2008-09-24 12:54 39
{
444cec07 sago007 2012-05-05 16:42 40
	converter.str(std::string());
444cec07 sago007 2012-05-05 16:42 41
	converter.clear();
c53e6443 sago007 2012-04-17 11:04 42
	converter << num;
c53e6443 sago007 2012-04-17 11:04 43
	return converter.str();
c53e6443 sago007 2012-04-17 11:04 44
}
769a41a0 sago007 2008-09-24 12:54 45
d07b805e sago007 2009-01-27 13:15 46
/**
d07b805e sago007 2009-01-27 13:15 47
 * str2double parses a string and returns a double with the value of the string.
fcd5a134 sago007 2008-12-19 01:11 48
 * if the string is not a double then 0.0 is returned instead of throing an error
fcd5a134 sago007 2008-12-19 01:11 49
 * in that way this function will always return a useable value.
fcd5a134 sago007 2008-12-19 01:11 50
 */
af35c39d sago007 2013-11-16 16:37 51
double str2double(const string &str2parse)
769a41a0 sago007 2008-09-24 12:54 52
{
c53e6443 sago007 2012-04-17 11:04 53
	try
c53e6443 sago007 2012-04-17 11:04 54
	{
444cec07 sago007 2012-05-05 16:42 55
		converter.clear();
444cec07 sago007 2012-05-05 16:42 56
		converter.str(str2parse);
c53e6443 sago007 2012-04-17 11:04 57
		double val = 0.0;
c53e6443 sago007 2012-04-17 11:04 58
		converter >> val;
c53e6443 sago007 2012-04-17 11:04 59
		return val;
c53e6443 sago007 2012-04-17 11:04 60
	}
af35c39d sago007 2013-11-16 16:37 61
	catch(ios_base::failure &f)
c53e6443 sago007 2012-04-17 11:04 62
	{
c53e6443 sago007 2012-04-17 11:04 63
		return 0.0;
c53e6443 sago007 2012-04-17 11:04 64
	}
769a41a0 sago007 2008-09-24 12:54 65
}
769a41a0 sago007 2008-09-24 12:54 66
d07b805e sago007 2009-01-27 13:15 67
/**
d07b805e sago007 2009-01-27 13:15 68
 * str2int parses a string and returns an int with the value of the string.
fcd5a134 sago007 2008-12-19 01:11 69
 * if the string is not an int then 0 is returned instead of throing an error
fcd5a134 sago007 2008-12-19 01:11 70
 * in that way this function will always return a useable value.
fcd5a134 sago007 2008-12-19 01:11 71
 */
af35c39d sago007 2013-11-16 16:37 72
int str2int(const string &str2parse)
769a41a0 sago007 2008-09-24 12:54 73
{
c53e6443 sago007 2012-04-17 11:04 74
	try
c53e6443 sago007 2012-04-17 11:04 75
	{
444cec07 sago007 2012-05-05 16:42 76
		converter.clear();
444cec07 sago007 2012-05-05 16:42 77
		converter.str(str2parse);
c53e6443 sago007 2012-04-17 11:04 78
		int val = 0;
c53e6443 sago007 2012-04-17 11:04 79
		converter >> val;
c53e6443 sago007 2012-04-17 11:04 80
		return val;
c53e6443 sago007 2012-04-17 11:04 81
	}
af35c39d sago007 2013-11-16 16:37 82
	catch(ios_base::failure &f)
c53e6443 sago007 2012-04-17 11:04 83
	{
c53e6443 sago007 2012-04-17 11:04 84
		return 0;
c53e6443 sago007 2012-04-17 11:04 85
	}
769a41a0 sago007 2008-09-24 12:54 86
}
89c4a3a6 sago007 2008-08-29 14:32 87
89c4a3a6 sago007 2008-08-29 14:32 88
#ifdef WIN32
89c4a3a6 sago007 2008-08-29 14:32 89
//Returns path to "my Documents" in windows:
89c4a3a6 sago007 2008-08-29 14:32 90
string getMyDocumentsPath()
89c4a3a6 sago007 2008-08-29 14:32 91
{
c53e6443 sago007 2012-04-17 11:04 92
	TCHAR pszPath[MAX_PATH];
c53e6443 sago007 2012-04-17 11:04 93
	//if (SUCCEEDED(SHGetSpecialFolderPath(NULL, pszPath, CSIDL_PERSONAL, FALSE))) {
c53e6443 sago007 2012-04-17 11:04 94
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, pszPath)))
c53e6443 sago007 2012-04-17 11:04 95
	{
c53e6443 sago007 2012-04-17 11:04 96
		// pszPath is now the path that you want
724439a5 sago007 2008-09-11 15:52 97
#if DEBUG
c53e6443 sago007 2012-04-17 11:04 98
		cout << "MyDocuments Located: " << pszPath << endl;
89c4a3a6 sago007 2008-08-29 14:32 99
#endif
c53e6443 sago007 2012-04-17 11:04 100
		string theResult= pszPath;
c53e6443 sago007 2012-04-17 11:04 101
		return theResult;
c53e6443 sago007 2012-04-17 11:04 102
	}
c53e6443 sago007 2012-04-17 11:04 103
	else
c53e6443 sago007 2012-04-17 11:04 104
	{
c53e6443 sago007 2012-04-17 11:04 105
		cout << "Warning: My Documents not found!" << endl;
c53e6443 sago007 2012-04-17 11:04 106
		string theResult ="";
c53e6443 sago007 2012-04-17 11:04 107
		return theResult;
c53e6443 sago007 2012-04-17 11:04 108
	}
89c4a3a6 sago007 2008-08-29 14:32 109
}
89c4a3a6 sago007 2008-08-29 14:32 110
89c4a3a6 sago007 2008-08-29 14:32 111
#endif
89c4a3a6 sago007 2008-08-29 14:32 112
d07b805e sago007 2009-01-27 13:15 113
/**
d07b805e sago007 2009-01-27 13:15 114
 * Returns the path to where all settings must be saved.
d07b805e sago007 2009-01-27 13:15 115
 * On unix-like systems this is the home-folder under: ~/.gamesaves/GAMENAME
d07b805e sago007 2009-01-27 13:15 116
 * In Windows it is My Documents/My Games
d07b805e sago007 2009-01-27 13:15 117
 * Consider changing this for Vista that has a special save games folder
d07b805e sago007 2009-01-27 13:15 118
 */
89c4a3a6 sago007 2008-08-29 14:32 119
string getPathToSaveFiles()
89c4a3a6 sago007 2008-08-29 14:32 120
{
89c4a3a6 sago007 2008-08-29 14:32 121
#ifdef __unix__
c53e6443 sago007 2012-04-17 11:04 122
	return (string)getenv("HOME")+(string)"/.gamesaves/"+GAMENAME;
89c4a3a6 sago007 2008-08-29 14:32 123
#elif WIN32
c53e6443 sago007 2012-04-17 11:04 124
	return getMyDocumentsPath()+(string)"/My Games/"+GAMENAME;
89c4a3a6 sago007 2008-08-29 14:32 125
#else
c53e6443 sago007 2012-04-17 11:04 126
	return ".";
89c4a3a6 sago007 2008-08-29 14:32 127
#endif
89c4a3a6 sago007 2008-08-29 14:32 128
}
89c4a3a6 sago007 2008-08-29 14:32 129
d07b805e sago007 2009-01-27 13:15 130
/**
d07b805e sago007 2009-01-27 13:15 131
 * Takes a number of milliseconds and returns the value in commonTime format.
d07b805e sago007 2009-01-27 13:15 132
 */
cd12e0fe sago007 2009-01-29 08:47 133
commonTime TimeHandler::ms2ct(unsigned int milliseconds)
c09d0e4f sago007 2009-01-27 01:15 134
{
c53e6443 sago007 2012-04-17 11:04 135
	commonTime ct;
c53e6443 sago007 2012-04-17 11:04 136
	ct.days = 0;
c53e6443 sago007 2012-04-17 11:04 137
	unsigned int time = milliseconds;
c53e6443 sago007 2012-04-17 11:04 138
	ct.hours = time/(1000*60*60);
c53e6443 sago007 2012-04-17 11:04 139
	time = time % (1000*60*60);
c53e6443 sago007 2012-04-17 11:04 140
	ct.minutes = time/(1000*60);
c53e6443 sago007 2012-04-17 11:04 141
	time = time % (1000*60);
c53e6443 sago007 2012-04-17 11:04 142
	ct.seconds = time/1000;
c53e6443 sago007 2012-04-17 11:04 143
	return ct;
c09d0e4f sago007 2009-01-27 01:15 144
}
89c4a3a6 sago007 2008-08-29 14:32 145
af35c39d sago007 2013-11-16 16:37 146
commonTime TimeHandler::getTime(const string &name)
89c4a3a6 sago007 2008-08-29 14:32 147
{
c53e6443 sago007 2012-04-17 11:04 148
	commonTime ct;
c53e6443 sago007 2012-04-17 11:04 149
	ct.days = Config::getInstance()->getInt(name+"Days");
c53e6443 sago007 2012-04-17 11:04 150
	ct.hours = Config::getInstance()->getInt(name+"Hours");
c53e6443 sago007 2012-04-17 11:04 151
	ct.minutes = Config::getInstance()->getInt(name+"Minutes");
c53e6443 sago007 2012-04-17 11:04 152
	ct.seconds = Config::getInstance()->getInt(name+"Seconds");
c53e6443 sago007 2012-04-17 11:04 153
	return ct;
89c4a3a6 sago007 2008-08-29 14:32 154
}
89c4a3a6 sago007 2008-08-29 14:32 155
d07b805e sago007 2009-01-27 13:15 156
/**
c53e6443 sago007 2012-04-17 11:04 157
 * Returns the total runtime with toAdd added but without writing it to config file.
d07b805e sago007 2009-01-27 13:15 158
 * Used for stats
c09d0e4f sago007 2009-01-27 01:15 159
 */
af35c39d sago007 2013-11-16 16:37 160
commonTime TimeHandler::peekTime(const string &name, const commonTime &toAdd)
89c4a3a6 sago007 2008-08-29 14:32 161
{
c53e6443 sago007 2012-04-17 11:04 162
	commonTime ct = getTime(name);
c09d0e4f sago007 2009-01-27 01:15 163
c53e6443 sago007 2012-04-17 11:04 164
	ct.seconds +=toAdd.seconds;
c53e6443 sago007 2012-04-17 11:04 165
	ct.minutes +=ct.seconds/60;
c53e6443 sago007 2012-04-17 11:04 166
	ct.seconds = ct.seconds%60;
c09d0e4f sago007 2009-01-27 01:15 167
c53e6443 sago007 2012-04-17 11:04 168
	ct.minutes += toAdd.minutes;
c53e6443 sago007 2012-04-17 11:04 169
	ct.hours += ct.minutes/60;
c53e6443 sago007 2012-04-17 11:04 170
	ct.minutes = ct.minutes%60;
c09d0e4f sago007 2009-01-27 01:15 171
c53e6443 sago007 2012-04-17 11:04 172
	ct.hours += toAdd.hours;
c53e6443 sago007 2012-04-17 11:04 173
	ct.days += ct.hours/24;
c53e6443 sago007 2012-04-17 11:04 174
	ct.hours = ct.hours%24;
c09d0e4f sago007 2009-01-27 01:15 175
c53e6443 sago007 2012-04-17 11:04 176
	ct.days += toAdd.days;
c53e6443 sago007 2012-04-17 11:04 177
	return ct;
c09d0e4f sago007 2009-01-27 01:15 178
}
c09d0e4f sago007 2009-01-27 01:15 179
d07b805e sago007 2009-01-27 13:15 180
/**
c09d0e4f sago007 2009-01-27 01:15 181
 * Same as peekTotalTime but writes the time to the config file.
d07b805e sago007 2009-01-27 13:15 182
 * Should only be called only once! when the program shuts down
c09d0e4f sago007 2009-01-27 01:15 183
 */
af35c39d sago007 2013-11-16 16:37 184
commonTime TimeHandler::addTime(const string &name, const commonTime &toAdd)
c09d0e4f sago007 2009-01-27 01:15 185
{
c53e6443 sago007 2012-04-17 11:04 186
	commonTime ct = peekTime(name,toAdd);
c53e6443 sago007 2012-04-17 11:04 187
c53e6443 sago007 2012-04-17 11:04 188
	Config::getInstance()->setInt(name+"Days",ct.days);
c53e6443 sago007 2012-04-17 11:04 189
	Config::getInstance()->setInt(name+"Hours",ct.hours);
c53e6443 sago007 2012-04-17 11:04 190
	Config::getInstance()->setInt(name+"Minutes",ct.minutes);
c53e6443 sago007 2012-04-17 11:04 191
	Config::getInstance()->setInt(name+"Seconds",ct.seconds);
c53e6443 sago007 2012-04-17 11:04 192
	return ct;
89c4a3a6 sago007 2008-08-29 14:32 193
}
769a41a0 sago007 2008-09-24 12:54 194
769a41a0 sago007 2008-09-24 12:54 195
Config* Config::instance = 0;
769a41a0 sago007 2008-09-24 12:54 196
769a41a0 sago007 2008-09-24 12:54 197
Config::Config()
769a41a0 sago007 2008-09-24 12:54 198
{
c53e6443 sago007 2012-04-17 11:04 199
	configMap.clear();
c53e6443 sago007 2012-04-17 11:04 200
	load();
c53e6443 sago007 2012-04-17 11:04 201
	shuttingDown = 0; // Not shutting down
769a41a0 sago007 2008-09-24 12:54 202
}
769a41a0 sago007 2008-09-24 12:54 203
769a41a0 sago007 2008-09-24 12:54 204
void Config::load()
769a41a0 sago007 2008-09-24 12:54 205
{
c53e6443 sago007 2012-04-17 11:04 206
	string filename = getPathToSaveFiles()+"/configFile";
c53e6443 sago007 2012-04-17 11:04 207
	ifstream inFile(filename.c_str());
c53e6443 sago007 2012-04-17 11:04 208
	string key;
c53e6443 sago007 2012-04-17 11:04 209
	string previuskey;
c53e6443 sago007 2012-04-17 11:04 210
	char value[MAX_VAR_LENGTH];
c53e6443 sago007 2012-04-17 11:04 211
	if(inFile)
c53e6443 sago007 2012-04-17 11:04 212
	{
c53e6443 sago007 2012-04-17 11:04 213
		while(!inFile.eof())
c53e6443 sago007 2012-04-17 11:04 214
		{
c53e6443 sago007 2012-04-17 11:04 215
			inFile >> key;
c53e6443 sago007 2012-04-17 11:04 216
			if(key==previuskey) //the last entry will be read 2 times if a linebreak is missing in the end
c53e6443 sago007 2012-04-17 11:04 217
				continue;
c53e6443 sago007 2012-04-17 11:04 218
			previuskey = key;
c53e6443 sago007 2012-04-17 11:04 219
			inFile.get(); //Read the space between the key and the content
c53e6443 sago007 2012-04-17 11:04 220
			inFile.getline(value,MAX_VAR_LENGTH);
c53e6443 sago007 2012-04-17 11:04 221
#if DEBUG
c53e6443 sago007 2012-04-17 11:04 222
			cout << "Config "<< "read: " << key << " with:\"" << value << "\"" << endl;
c53e6443 sago007 2012-04-17 11:04 223
#endif
c53e6443 sago007 2012-04-17 11:04 224
			configMap[key] = (string)value;
c53e6443 sago007 2012-04-17 11:04 225
		}
c53e6443 sago007 2012-04-17 11:04 226
		inFile.close();
c53e6443 sago007 2012-04-17 11:04 227
	}
769a41a0 sago007 2008-09-24 12:54 228
}
769a41a0 sago007 2008-09-24 12:54 229
769a41a0 sago007 2008-09-24 12:54 230
Config* Config::getInstance()
769a41a0 sago007 2008-09-24 12:54 231
{
c53e6443 sago007 2012-04-17 11:04 232
	if(Config::instance==0)
c53e6443 sago007 2012-04-17 11:04 233
	{
c53e6443 sago007 2012-04-17 11:04 234
		Config::instance = new Config();
c53e6443 sago007 2012-04-17 11:04 235
c53e6443 sago007 2012-04-17 11:04 236
	}
c53e6443 sago007 2012-04-17 11:04 237
	return Config::instance;
769a41a0 sago007 2008-09-24 12:54 238
}
769a41a0 sago007 2008-09-24 12:54 239
769a41a0 sago007 2008-09-24 12:54 240
void Config::save()
769a41a0 sago007 2008-09-24 12:54 241
{
c53e6443 sago007 2012-04-17 11:04 242
	string filename = getPathToSaveFiles()+"/configFile";
c53e6443 sago007 2012-04-17 11:04 243
	ofstream outFile(filename.c_str(),ios::trunc);
c53e6443 sago007 2012-04-17 11:04 244
c53e6443 sago007 2012-04-17 11:04 245
	if(outFile)
c53e6443 sago007 2012-04-17 11:04 246
	{
c53e6443 sago007 2012-04-17 11:04 247
		map<string,string>::iterator iter;
c53e6443 sago007 2012-04-17 11:04 248
		for(iter = configMap.begin(); iter != configMap.end(); iter++)
c53e6443 sago007 2012-04-17 11:04 249
		{
c53e6443 sago007 2012-04-17 11:04 250
			outFile << iter->first << " " << iter->second << endl;
c53e6443 sago007 2012-04-17 11:04 251
		}
c53e6443 sago007 2012-04-17 11:04 252
		outFile << "\n"; //The last entry in the file will be read double if a linebreak is missing
c53e6443 sago007 2012-04-17 11:04 253
		//This is checked on load too in case a user changes it himself.
c53e6443 sago007 2012-04-17 11:04 254
	}
c53e6443 sago007 2012-04-17 11:04 255
	outFile.close();
769a41a0 sago007 2008-09-24 12:54 256
}
769a41a0 sago007 2008-09-24 12:54 257
af35c39d sago007 2013-11-16 16:37 258
bool Config::exists(const string &varName) const
769a41a0 sago007 2008-09-24 12:54 259
{
c53e6443 sago007 2012-04-17 11:04 260
	//Using that find returns an iterator to the end of the map if not found
c53e6443 sago007 2012-04-17 11:04 261
	return configMap.find(varName) != configMap.end();
769a41a0 sago007 2008-09-24 12:54 262
}
769a41a0 sago007 2008-09-24 12:54 263
af35c39d sago007 2013-11-16 16:37 264
void Config::setDefault(const string &varName,const string &content)
42f8ed5f sago007 2009-03-05 11:47 265
{
c53e6443 sago007 2012-04-17 11:04 266
	if(exists(varName))
c53e6443 sago007 2012-04-17 11:04 267
		return; //Already exists do not change
c53e6443 sago007 2012-04-17 11:04 268
	setString(varName,content);
42f8ed5f sago007 2009-03-05 11:47 269
}
42f8ed5f sago007 2009-03-05 11:47 270
c53e6443 sago007 2012-04-17 11:04 271
void Config::setShuttingDown(long shuttingDown)
c53e6443 sago007 2012-04-17 11:04 272
{
c53e6443 sago007 2012-04-17 11:04 273
	this->shuttingDown = shuttingDown;
cc3ef158 sago007 2011-07-03 16:13 274
}
cc3ef158 sago007 2011-07-03 16:13 275
c53e6443 sago007 2012-04-17 11:04 276
long Config::isShuttingDown() const
c53e6443 sago007 2012-04-17 11:04 277
{
c53e6443 sago007 2012-04-17 11:04 278
	return shuttingDown;
cc3ef158 sago007 2011-07-03 16:13 279
}
cc3ef158 sago007 2011-07-03 16:13 280
af35c39d sago007 2013-11-16 16:37 281
void Config::setString(const string &varName, const string &content)
769a41a0 sago007 2008-09-24 12:54 282
{
c53e6443 sago007 2012-04-17 11:04 283
	configMap[varName] = content;
769a41a0 sago007 2008-09-24 12:54 284
}
769a41a0 sago007 2008-09-24 12:54 285
af35c39d sago007 2013-11-16 16:37 286
void Config::setInt(const string &varName, int content)
769a41a0 sago007 2008-09-24 12:54 287
{
c53e6443 sago007 2012-04-17 11:04 288
	configMap[varName] = itoa(content);
769a41a0 sago007 2008-09-24 12:54 289
}
769a41a0 sago007 2008-09-24 12:54 290
af35c39d sago007 2013-11-16 16:37 291
void Config::setValue(const string &varName,double content)
769a41a0 sago007 2008-09-24 12:54 292
{
c53e6443 sago007 2012-04-17 11:04 293
	configMap[varName] = double2str(content);
769a41a0 sago007 2008-09-24 12:54 294
}
769a41a0 sago007 2008-09-24 12:54 295
af35c39d sago007 2013-11-16 16:37 296
string Config::getString(const string &varName)
769a41a0 sago007 2008-09-24 12:54 297
{
c53e6443 sago007 2012-04-17 11:04 298
	if(exists(varName))
c53e6443 sago007 2012-04-17 11:04 299
	{
c53e6443 sago007 2012-04-17 11:04 300
		return configMap[varName];
c53e6443 sago007 2012-04-17 11:04 301
	}
c53e6443 sago007 2012-04-17 11:04 302
	else
c53e6443 sago007 2012-04-17 11:04 303
		return "";
769a41a0 sago007 2008-09-24 12:54 304
}
769a41a0 sago007 2008-09-24 12:54 305
af35c39d sago007 2013-11-16 16:37 306
int Config::getInt(const string &varName)
769a41a0 sago007 2008-09-24 12:54 307
{
c53e6443 sago007 2012-04-17 11:04 308
	if(exists(varName))
c53e6443 sago007 2012-04-17 11:04 309
	{
c53e6443 sago007 2012-04-17 11:04 310
		return str2int(configMap[varName]);
c53e6443 sago007 2012-04-17 11:04 311
	}
c53e6443 sago007 2012-04-17 11:04 312
	else
c53e6443 sago007 2012-04-17 11:04 313
		return 0;
769a41a0 sago007 2008-09-24 12:54 314
}
769a41a0 sago007 2008-09-24 12:54 315
af35c39d sago007 2013-11-16 16:37 316
double Config::getValue(const string &varName)
769a41a0 sago007 2008-09-24 12:54 317
{
c53e6443 sago007 2012-04-17 11:04 318
	if(exists(varName))
c53e6443 sago007 2012-04-17 11:04 319
	{
c53e6443 sago007 2012-04-17 11:04 320
		return str2double(configMap[varName]);
c53e6443 sago007 2012-04-17 11:04 321
	}
c53e6443 sago007 2012-04-17 11:04 322
	else
c53e6443 sago007 2012-04-17 11:04 323
		return 0.0;
769a41a0 sago007 2008-09-24 12:54 324
}
1970-01-01 00:00 325