diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-05 10:44:08 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-05 10:44:08 -0800 |
commit | 063a465227f13c0d673a0d9cd82d0b9cff1f0fc2 (patch) | |
tree | ff5116ed36ca692c9793730de6f8b03abbc1c29f /common.h | |
parent | 230fb921ec89e3a30d5ccdad57beb1b77b4ab055 (diff) |
Begin to rework term256 support
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -304,6 +304,14 @@ T from_string(const wcstring &x) { } template<typename T> +T from_string(const std::string &x) { + T result = T(); + std::stringstream stream(x); + stream >> result; + return result; +} + +template<typename T> wcstring to_string(const T &x) { std::wstringstream stream; stream << x; @@ -319,6 +327,16 @@ inline wcstring to_string(const long &x) { } template<> +inline bool from_string(const std::string &x) { + return ! x.empty() && strchr("YTyt", x.at(0)); +} + +template<> +inline bool from_string(const wcstring &x) { + return ! x.empty() && wcschr(L"YTyt", x.at(0)); +} + +template<> inline wcstring to_string(const int &x) { return to_string(static_cast<long>(x)); } |