From ea922a1ddd0526d37c6a299ab6260729612a8dfa Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 28 Feb 2013 17:02:58 +0000 Subject: new template, VARST, to hold the result of calling Utils_ReplaceVarsT() git-svn-id: http://svn.miranda-ng.org/main/trunk@3806 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_system_cpp.h | 2 ++ include/m_utils.h | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 67b5a243d5..2cb5a5af5e 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_SYSTEM_CPP_H__ #define M_SYSTEM_CPP_H__ 1 +#include + #include "m_system.h" #if defined(_UNICODE) diff --git a/include/m_utils.h b/include/m_utils.h index 64d0e2a2e3..bd9f21d887 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -414,16 +414,34 @@ typedef struct #define MS_UTILS_REPLACEVARS "Utils/ReplaceVars" __forceinline char* Utils_ReplaceVars(const char *szData) { - REPLACEVARSDATA dat = {0}; - dat.cbSize = sizeof(dat); + REPLACEVARSDATA dat = { sizeof(dat) }; return (char*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szData, (LPARAM)&dat); } __forceinline TCHAR* Utils_ReplaceVarsT(const TCHAR *szData) { - REPLACEVARSDATA dat = {0}; - dat.cbSize = sizeof(dat); - dat.dwFlags = RVF_TCHAR; + REPLACEVARSDATA dat = { sizeof(dat), RVF_TCHAR }; return (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szData, (LPARAM)&dat); } + +#if defined(__cplusplus) + #if !defined(M_SYSTEM_CPP_H__) + #include "m_system_cpp.h" + #endif + + struct VARS : public mir_ptr + { + __forceinline VARS(const char *str) : + mir_ptr( Utils_ReplaceVars(str)) + {} + }; + + struct VARST : public mir_ptr + { + __forceinline VARST(const TCHAR *str) : + mir_ptr( Utils_ReplaceVarsT(str)) + {} + }; +#endif + #ifdef _UNICODE #define MS_UTILS_PATHTORELATIVEW "Utils/PathToRelativeW" #define MS_UTILS_PATHTOABSOLUTEW "Utils/PathToAbsoluteW" -- cgit v1.2.3