summaryrefslogtreecommitdiff
path: root/include/m_core.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-22 16:04:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-22 16:04:17 +0000
commite2c2a1f5a84c6c9b705dc85c6a2dd1f97edd57e4 (patch)
treeba79bdcede96f80039f8b88d2791f198b9ec2981 /include/m_core.h
parentf8e34b5f83f3ce5f39d541e9068b6b8cb6d92acd (diff)
T2Utf - handy replacement for ptrA<mir_utf8decodeT()>
git-svn-id: http://svn.miranda-ng.org/main/trunk@13758 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include/m_core.h')
-rw-r--r--include/m_core.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/m_core.h b/include/m_core.h
index 4b8eb0a824..e29dc0f100 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -670,6 +670,33 @@ __forceinline char* mir_utf8decodeA(const char* src)
#define mir_utf8encodeT mir_utf8encode
#endif
+class T2Utf
+{
+ char* m_str;
+
+public:
+ __forceinline T2Utf(const TCHAR *str) :
+ m_str(mir_utf8encodeT(str))
+ {}
+
+ __forceinline ~T2Utf()
+ { mir_free(m_str);
+ }
+
+ __forceinline char* detach()
+ { char *res = m_str; m_str = NULL;
+ return res;
+ }
+
+ __forceinline char& operator[](int idx) const { return m_str[idx]; }
+ __forceinline operator char*() const { return m_str; }
+ __forceinline operator unsigned char*() const { return (unsigned char*)m_str; }
+ __forceinline operator LPARAM() const { return (LPARAM)m_str; }
+ #ifdef _XSTRING_
+ std::string str() const { return std::string(m_str); }
+ #endif
+};
+
///////////////////////////////////////////////////////////////////////////////
// Window subclassing