00001
00002
00003 #ifndef UTILS_H
00004 #define UTILS_H
00005
00006
00007 #include <string>
00008 #include <sstream>
00009
00010
00011 namespace pge {
00012 namespace utils {
00013
00014
00015
00016
00017 static std::string intToString(int i) {
00018 std::stringstream str;
00019 std::string s;
00020
00021 str << i;
00022 str >> s;
00023 return s;
00024 }
00025
00026
00027
00028
00029
00030 static int stringToInt(const std::string &s) {
00031 std::istringstream stream;
00032 int d = 0;
00033
00034
00035 stream.str(s);
00036 stream >> d;
00037 return d;
00038 }
00039
00040
00041
00042
00043
00044 static float stringToFloat(const std::string &s) {
00045 std::istringstream stream;
00046 float f = 0.0f;
00047
00048
00049 stream.str(s);
00050 stream >> std::dec >> f;
00051 return f;
00052 }
00053
00054 };
00055 };
00056
00057 #endif