From 57c87234383026f1f57a3044f0d934fc13ea9d0e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 1 Jun 2012 21:37:18 +0000 Subject: - RecentContacts added; - _A2T & _T2A classes moved to m_utils.h git-svn-id: http://svn.miranda-ng.org/main/trunk@255 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_system_cpp.h | 13 +++++++++---- include/m_utils.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 99d244097c..3187948810 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -25,6 +25,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_system.h" +#if defined( _UNICODE ) + #define tstring wstring +#else + #define tstring string +#endif + #if defined( __cplusplus ) extern LIST_INTERFACE li; @@ -112,7 +118,7 @@ template struct OBJLIST : public LIST LIST( aincr, ( FTSortFunc ) id ) {} - __inline OBJLIST( const OBJLIST& x ) : + __inline OBJLIST( const OBJLIST& x ) : LIST( x.increment, x.sortFunc ) { items = NULL; #if defined( _STATIC ) @@ -135,13 +141,13 @@ template struct OBJLIST : public LIST ~OBJLIST() { #if !defined( _STATIC ) - if (li.cbSize != 0) + if (li.cbSize != 0) #endif destroy(); } __inline void destroy( void ) - { + { for ( int i=0; i < this->count; i++ ) delete this->items[i]; @@ -181,4 +187,3 @@ template struct OBJLIST : public LIST #endif #endif // M_SYSTEM_CPP_H - 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__ -- cgit v1.2.3