00001 00014 #ifndef CCOMMANDPARSER_H 00015 #define CCOMMANDPARSER_H 00016 00020 inline void GetLine(std::istream& i, std::string& s) 00021 { 00022 #ifdef WIN32 00023 char c; 00024 s = ""; 00025 std::cin.get(c); 00026 while(isprint(c)) 00027 { 00028 s += c; 00029 std::cin.get(c); 00030 } 00031 #elif defined LINUX 00032 std::getline(i, s); 00033 #else 00034 #error OS not supported 00035 #endif 00036 } 00037 00038 00046 class CCommandParser 00047 { 00048 public: 00053 static CCommandParser* getInstance() 00054 { 00055 if (s_pInstance == NULL) 00056 { 00057 s_pInstance = new CCommandParser; 00058 } 00059 return s_pInstance; 00060 } 00061 00066 static void freeInstance() 00067 { 00068 if (s_pInstance) 00069 { 00070 delete s_pInstance; 00071 s_pInstance = NULL; 00072 } 00073 } 00074 00075 00080 CCommand Parse(std::string StrCommand) const; 00081 00082 00083 private: 00087 CCommandParser() {} 00088 00089 00093 static bool StringToFloat(const std::string& StringNumber, float* pFloat); 00094 00098 static bool StringToInt(const std::string& StringNumber, int* pInt); 00099 00100 00101 static CCommandParser* s_pInstance; 00103 }; 00104 00105 00106 #endif // CCOMMANDPARSER_H 00107
1.5.4