summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-04-12 13:17:28 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-04-12 13:17:28 +0000
commitbdb3f0597f6ac1eac050a68053d2c4acebdf644d (patch)
tree8601714d5938a7764ec100cad2be6bfe6abd64af
parent2e7f73ce9e8ebc532b5da539324a763725197b5f (diff)
m_gui: CMOption for strings
git-svn-id: http://svn.miranda-ng.org/main/trunk@16632 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_gui.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/include/m_gui.h b/include/m_gui.h
index b919207189..c78ebfe7e7 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -133,6 +133,72 @@ private:
void operator= (const CMOption &) {}
};
+#ifdef M_SYSTEM_CPP_H__
+
+template<>
+class CMOption<char*> : public CMOptionBase
+{
+public:
+
+ typedef char Type;
+
+ __forceinline CMOption(PROTO_INTERFACE *proto, char *szSetting, const Type *defValue = nullptr) :
+ CMOptionBase(proto, szSetting), m_default(defValue)
+ {}
+
+ __forceinline operator Type*()
+ {
+ m_value = m_proto->getStringA(m_szSetting);
+ if (!m_value) m_value = mir_strdup(m_default);
+ return m_value;
+ }
+ __forceinline Type* operator= (Type *value)
+ {
+ m_proto->setString(m_szSetting, value);
+ return value;
+ }
+
+private:
+ const Type *m_default;
+ mir_ptr<Type> m_value;
+
+ CMOption(const CMOption &) : CMOptionBase(NULL, NULL) {}
+ void operator= (const CMOption &) {}
+};
+
+template<>
+class CMOption<wchar_t*> : public CMOptionBase
+{
+public:
+
+ typedef wchar_t Type;
+
+ __forceinline CMOption(PROTO_INTERFACE *proto, char *szSetting, const Type *defValue = nullptr) :
+ CMOptionBase(proto, szSetting), m_default(defValue)
+ {}
+
+ __forceinline operator Type*()
+ {
+ m_value = m_proto->getWStringA(m_szSetting);
+ if (!m_value) m_value = mir_wstrdup(m_default);
+ return m_value;
+ }
+
+ __forceinline const Type* operator= (const Type *value)
+ {
+ m_proto->setWString(m_szSetting, value);
+ return value;
+ }
+
+private:
+ const Type *m_default;
+ mir_ptr<Type> m_value;
+
+ CMOption(const CMOption &) : CMOptionBase(NULL, NULL) {}
+ void operator= (const CMOption &) {}
+};
+
+#endif
/////////////////////////////////////////////////////////////////////////////////////////
// Callbacks