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

#include <atlconv.h>

Public Member Functions

 CW2AEX (_In_z_ LPCWSTR psz)
 
 CW2AEX (_In_z_ LPCWSTR psz, _In_ UINT nCodePage)
 
 ~CW2AEX () noexcept
 
_Ret_z_ operator LPSTR () const noexcept
 

Public Attributes

LPSTR m_psz
 
char m_szBuffer [t_nBufferLength]
 

Private Member Functions

 CW2AEX (_In_ const CW2AEX &) noexcept=delete
 
CW2AEXoperator= (_In_ const CW2AEX &) noexcept=delete
 
void Init (_In_z_ LPCWSTR psz, _In_ UINT nConvertCodePage)
 

Detailed Description

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

Definition at line 256 of file atlconv.h.

Constructor & Destructor Documentation

◆ CW2AEX() [1/3]

template<int t_nBufferLength = 128>
ATL::CW2AEX< t_nBufferLength >::CW2AEX ( _In_z_ LPCWSTR  psz)
inline

Definition at line 262 of file atlconv.h.

263 {
264 Init(psz, CP_ACP);
265 }
#define CP_ACP
Definition: compat.h:109

◆ CW2AEX() [2/3]

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

Definition at line 267 of file atlconv.h.

268 {
269 Init(psz, nCodePage);
270 }

◆ ~CW2AEX()

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

Definition at line 272 of file atlconv.h.

273 {
274 if (m_psz != m_szBuffer)
275 free(m_psz);
276 }
char m_szBuffer[t_nBufferLength]
Definition: atlconv.h:260
LPSTR m_psz
Definition: atlconv.h:259
#define free
Definition: debug_ros.c:5

◆ CW2AEX() [3/3]

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

Member Function Documentation

◆ Init()

template<int t_nBufferLength = 128>
void ATL::CW2AEX< t_nBufferLength >::Init ( _In_z_ LPCWSTR  psz,
_In_ UINT  nConvertCodePage 
)
inlineprivate

Definition at line 288 of file atlconv.h.

289 {
290 if (!psz)
291 {
292 m_psz = NULL;
293 m_szBuffer[0] = 0;
294 return;
295 }
296
297 // NOTE: This has a failure.
298 int cchMax = WideCharToMultiByte(nConvertCodePage, 0, psz, -1, NULL, 0, NULL, NULL);
299 if (cchMax <= (int)_countof(m_szBuffer))
300 {
301 // Use the static buffer
304 }
305 else
306 {
307 // Allocate a new buffer
308 m_szBuffer[0] = 0;
309 m_psz = (LPSTR)malloc(cchMax * sizeof(CHAR));
310 if (!m_psz)
312 }
313
314 WideCharToMultiByte(nConvertCodePage, 0, psz, -1, m_psz, cchMax, NULL, NULL);
315 m_psz[cchMax - 1] = 0;
316 }
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 WideCharToMultiByte
Definition: compat.h:111
#define _countof(array)
Definition: sndvol32.h:68
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

◆ operator LPSTR()

template<int t_nBufferLength = 128>
_Ret_z_ ATL::CW2AEX< t_nBufferLength >::operator LPSTR ( ) const
inlinenoexcept

Definition at line 278 of file atlconv.h.

279 {
280 return m_psz;
281 }

◆ operator=()

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

Member Data Documentation

◆ m_psz

template<int t_nBufferLength = 128>
LPSTR ATL::CW2AEX< t_nBufferLength >::m_psz

◆ m_szBuffer

template<int t_nBufferLength = 128>
char ATL::CW2AEX< t_nBufferLength >::m_szBuffer[t_nBufferLength]

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