ReactOS 0.4.15-dev-7998-gdb93cb1
ATL::CA2WEX< t_nBufferLength > Class Template Reference

#include <atlconv.h>

Public Member Functions

 CA2WEX (_In_z_ LPCSTR psz)
 
 CA2WEX (_In_z_ LPCSTR psz, _In_ UINT nCodePage)
 
 ~CA2WEX () noexcept
 
_Ret_z_ operator LPWSTR () const noexcept
 

Public Attributes

LPWSTR m_psz
 
wchar_t m_szBuffer [t_nBufferLength]
 

Private Member Functions

 CA2WEX (_In_ const CA2WEX &) noexcept=delete
 
CA2WEXoperator= (_In_ const CA2WEX &) noexcept=delete
 
void Init (_In_z_ LPCSTR psz, _In_ UINT nCodePage)
 

Detailed Description

template<int t_nBufferLength = 128>
class ATL::CA2WEX< t_nBufferLength >

Definition at line 189 of file atlconv.h.

Constructor & Destructor Documentation

◆ CA2WEX() [1/3]

template<int t_nBufferLength = 128>
ATL::CA2WEX< t_nBufferLength >::CA2WEX ( _In_z_ LPCSTR  psz)
inline

Definition at line 195 of file atlconv.h.

196 {
197 Init(psz, CP_ACP);
198 }
#define CP_ACP
Definition: compat.h:109

◆ CA2WEX() [2/3]

template<int t_nBufferLength = 128>
ATL::CA2WEX< t_nBufferLength >::CA2WEX ( _In_z_ LPCSTR  psz,
_In_ UINT  nCodePage 
)
inline

Definition at line 200 of file atlconv.h.

201 {
202 Init(psz, nCodePage);
203 }

◆ ~CA2WEX()

template<int t_nBufferLength = 128>
ATL::CA2WEX< t_nBufferLength >::~CA2WEX ( )
inlinenoexcept

Definition at line 205 of file atlconv.h.

206 {
207 if (m_psz != m_szBuffer)
208 free(m_psz);
209 }
LPWSTR m_psz
Definition: atlconv.h:192
wchar_t m_szBuffer[t_nBufferLength]
Definition: atlconv.h:193
#define free
Definition: debug_ros.c:5

◆ CA2WEX() [3/3]

template<int t_nBufferLength = 128>
ATL::CA2WEX< t_nBufferLength >::CA2WEX ( _In_ const CA2WEX< t_nBufferLength > &  )
privatedeletenoexcept

Member Function Documentation

◆ Init()

template<int t_nBufferLength = 128>
void ATL::CA2WEX< t_nBufferLength >::Init ( _In_z_ LPCSTR  psz,
_In_ UINT  nCodePage 
)
inlineprivate

Definition at line 221 of file atlconv.h.

222 {
223 if (!psz)
224 {
225 m_psz = NULL;
226 m_szBuffer[0] = 0;
227 return;
228 }
229
230#if 1
231 int cchMax = lstrlenA(psz) + 1; // This is 3 times faster
232#else
233 int cchMax = MultiByteToWideChar(nCodePage, 0, psz, -1, NULL, 0); // It's slow
234#endif
235 if (cchMax <= (int)_countof(m_szBuffer))
236 {
237 // Use the static buffer
240 }
241 else
242 {
243 // Allocate a new buffer
244 m_szBuffer[0] = 0;
245 m_psz = (LPWSTR)malloc(cchMax * sizeof(WCHAR));
246 if (!m_psz)
248 }
249
250 MultiByteToWideChar(nCodePage, 0, psz, -1, m_psz, cchMax);
251 m_psz[cchMax - 1] = 0;
252 }
UINT cchMax
#define AtlThrow(x)
Definition: atldef.h:20
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define _countof(array)
Definition: sndvol32.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ operator LPWSTR()

template<int t_nBufferLength = 128>
_Ret_z_ ATL::CA2WEX< t_nBufferLength >::operator LPWSTR ( ) const
inlinenoexcept

Definition at line 211 of file atlconv.h.

212 {
213 return m_psz;
214 }

◆ operator=()

template<int t_nBufferLength = 128>
CA2WEX & ATL::CA2WEX< t_nBufferLength >::operator= ( _In_ const CA2WEX< t_nBufferLength > &  )
privatedeletenoexcept

Member Data Documentation

◆ m_psz

template<int t_nBufferLength = 128>
LPWSTR ATL::CA2WEX< t_nBufferLength >::m_psz

◆ m_szBuffer

template<int t_nBufferLength = 128>
wchar_t ATL::CA2WEX< t_nBufferLength >::m_szBuffer[t_nBufferLength]

The documentation for this class was generated from the following file: