Diff: StringToValue.hpp
- Revision:
- 0:f398994b70f5
diff -r 000000000000 -r f398994b70f5 StringToValue.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/StringToValue.hpp Thu Mar 31 04:42:55 2016 +0000 @@ -0,0 +1,35 @@ +#ifndef STRING_TO_VALUE_HPP +#define STRING_TO_VALUE_HPP + +#include <string> + +namespace ConvertData{ +template <class T> +T stringToValue(std::string str) +{ + T result; + return result; +} +template<> +std::string stringToValue(std::string str) +{ + return str; +} + +template<> +int stringToValue(std::string str) +{ + return atoi(str.c_str()); +} +long convert(std::string str) +{ + return atol(str.c_str()); +} +template<> +float stringToValue(std::string str) +{ + return atof(str.c_str()); +} +} + +#endif //STRING_TO_VALUE_HPP \ No newline at end of file