summaryrefslogtreecommitdiff
path: root/include/m_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/m_utils.h')
-rw-r--r--include/m_utils.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/m_utils.h b/include/m_utils.h
index bac74a2685..7ea24f528e 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -530,4 +530,44 @@ extern struct SHA1_INTERFACE sha1i;
#define mir_u2t_cp(s,c) mir_u2a_cp(s,c)
#endif
+#if defined( __cplusplus )
+
+#ifdef _STATIC
+ void mir_free( void* );
+ WCHAR* mir_a2u_cp(const char* src, int codepage);
+ WCHAR* mir_a2u(const char* src);
+ char* mir_u2a_cp(const wchar_t* src, int codepage);
+ char* mir_u2a( const wchar_t* src);
+#endif
+
+class _A2T
+{
+ TCHAR* buf;
+
+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 TCHAR*() const
+ { return buf;
+ }
+};
+
+class _T2A
+{
+ 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 char*() const
+ { return buf;
+ }
+};
+
+#endif
+
#endif // M_UTILS_H__