Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
00001 #ifndef CONFIG_H 00002 #define CONFIG_H 00003 00004 #include <cstdlib> 00005 #include <string> 00006 #include <fstream> 00007 #include <map> 00008 using namespace std; 00009 00020 class Config 00021 { 00022 public: 00032 Config(const string& filename); 00033 00034 //Assignment and copy operations are handled by the compiler generated versions 00035 00041 unsigned int screenWidth() const; 00042 00048 unsigned int screenHeight() const; 00049 00055 bool fullscreen() const; 00056 00057 private: 00067 void readFile(ifstream& file, map<string,string>& map); 00068 00078 void fillValues(const map<string, string>& readValues, map<string, string>& unfoundValues); 00079 00092 string extractValue(const map<string, string>& readValues, map<string, string>& unfoundValues, const string& key, const string& defaultValue); 00093 00100 void writeUnfoundValues(ofstream& file, const map<string, string>& unfoundValues); 00101 00107 void setScreenWidth(const string& screenWidthStr); 00108 00114 void setScreenHeight(const string& screenHeightStr); 00115 00121 void setFullscreen(const string& fullscreenStr); 00122 00123 unsigned int _screenWidth; 00124 unsigned int _screenHeight; 00125 bool _fullscreen; 00126 00127 static const string SCREEN_WIDTH_KEY; 00128 static const string SCREEN_HEIGHT_KEY; 00129 static const string FULLSCREEN_KEY; 00130 00131 static const string SCREEN_WIDTH_DEFAULT; 00132 static const string SCREEN_HEIGHT_DEFAULT; 00133 static const string FULLSCREEN_DEFAULT; 00134 }; 00135 00136 #endif // CONFIG_H