aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-03-05 10:44:08 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-03-05 10:44:08 -0800
commit063a465227f13c0d673a0d9cd82d0b9cff1f0fc2 (patch)
treeff5116ed36ca692c9793730de6f8b03abbc1c29f /common.h
parent230fb921ec89e3a30d5ccdad57beb1b77b4ab055 (diff)
Begin to rework term256 support
Diffstat (limited to 'common.h')
-rw-r--r--common.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/common.h b/common.h
index 7eaed866..8bb5b8bd 100644
--- a/common.h
+++ b/common.h
@@ -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));
}