summaryrefslogtreecommitdiff
path: root/include/m_core.h
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-06-04 13:09:01 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-06-04 13:09:01 +0000
commit420403dedffee8a10336e450337d30e1f25336b2 (patch)
tree83cb1fa5841c10f70c82ecd8ab3e6ad01cbaec85 /include/m_core.h
parentebd9c68d49bb57f0c9aa3d242200ce3a3e4e2283 (diff)
code optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@16912 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include/m_core.h')
-rw-r--r--include/m_core.h56
1 files changed, 17 insertions, 39 deletions
diff --git a/include/m_core.h b/include/m_core.h
index 07ffec3156..634a864708 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -529,32 +529,27 @@ MIR_CORE_DLL(wchar_t*) mir_a2u(const char* src);
MIR_CORE_DLL(char*) mir_u2a_cp(const wchar_t* src, int codepage);
MIR_CORE_DLL(char*) mir_u2a(const wchar_t* src);
-#if defined(__cplusplus)
+#ifdef __cplusplus
-class _A2T
+#ifndef M_SYSTEM_CPP_H__
+extern "C++"
{
- TCHAR* buf;
+#include <m_system_cpp.h>
+}
+#endif
+class _A2T : public ptrT
+{
public:
- __forceinline _A2T(const char* s) : buf(mir_a2t(s)) {}
- __forceinline _A2T(const char* s, int cp) : buf(mir_a2t_cp(s, cp)) {}
- ~_A2T() { mir_free(buf); }
-
- __forceinline operator LPARAM() const { return (LPARAM)buf; }
- __forceinline operator TCHAR*() const { return buf; }
+ __inline _A2T(const char* s) : ptrT(mir_a2t(s)) {}
+ __inline _A2T(const char* s, int cp) : ptrT(mir_a2t_cp(s, cp)) {}
};
-class _T2A
+class _T2A : public ptrA
{
- char* buf;
-
public:
- __forceinline _T2A(const TCHAR* s) : buf(mir_t2a(s)) {}
- __forceinline _T2A(const TCHAR* s, int cp) : buf(mir_t2a_cp(s, cp)) {}
- __forceinline ~_T2A() { mir_free(buf); }
-
- __forceinline operator LPARAM() const { return (LPARAM)buf; }
- __forceinline operator char*() const { return buf; }
+ __forceinline _T2A(const TCHAR* s) : ptrA(mir_t2a(s)) {}
+ __forceinline _T2A(const TCHAR* s, int cp) : ptrA(mir_t2a_cp(s, cp)) {}
};
#endif
@@ -631,30 +626,13 @@ __forceinline char* mir_utf8decodeA(const char* src)
#define mir_utf8encodeT mir_utf8encode
#endif
-class T2Utf
+class T2Utf : public ptrA
{
- 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[](size_t 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; }
+ __forceinline T2Utf(const TCHAR *str) : ptrA(mir_utf8encodeT(str)) {}
+ __forceinline operator BYTE* () const { return (BYTE*)data; }
#ifdef _XSTRING_
- std::string str() const { return std::string(m_str); }
+ std::string str() const { return std::string(data); }
#endif
};