git repos / blockattack-game

blame: source/code/common.cc

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