CA2WEX Class
This class is used by the string conversion macros CA2TEX, CA2CTEX, CT2WEX, and CT2CWEX, and the typedef CA2W.
Important
This class and its members cannot be used in applications that execute in the Windows Runtime.
template <int t_nBufferLength = 128>
class CA2WEX
t_nBufferLength
The size of the buffer used in the translation process. The default length is 128 bytes.
Name | Description |
---|---|
CA2WEX::CA2WEX | The constructor. |
CA2WEX::~CA2WEX | The destructor. |
Name | Description |
---|---|
CA2WEX::operator LPWSTR | Conversion operator. |
Name | Description |
---|---|
CA2WEX::m_psz | The data member that stores the source string. |
CA2WEX::m_szBuffer | The static buffer, used to store the converted string. |
Unless extra functionality is required, use CA2TEX, CA2CTEX, CT2WEX, CT2CWEX, or CA2W in your code.
This class contains a fixed-size static buffer which is used to store the result of the conversion. If the result is too large to fit into the static buffer, the class allocates memory using malloc, freeing the memory when the object goes out of scope. This ensures that, unlike text conversion macros available in previous versions of ATL, this class is safe to use in loops and that it won't overflow the stack.
If the class tries to allocate memory on the heap and fails, it will call AtlThrow
with an argument of E_OUTOFMEMORY.
By default, the ATL conversion classes and macros use the current thread's ANSI code page for the conversion. If you want to override that behavior for a specific conversion, specify the code page as the second parameter to the constructor for the class.
The following macros are based on this class:
CA2TEX
CA2CTEX
CT2WEX
CT2CWEX
The following typedef is based on this class:
- CA2W
For a discussion of these text conversion macros, see ATL and MFC String Conversion Macros.
See ATL and MFC String Conversion Macros for an example of using these string conversion macros.
Header: atlconv.h
The constructor.
CA2WEX(LPCSTR psz, UINT nCodePage) throw(...);
CA2WEX(LPCSTR psz) throw(...);
psz
The text string to be converted.
nCodePage
The code page used to perform the conversion. See the code page parameter discussion for the Windows SDK function MultiByteToWideChar for more details.
Allocates the buffer used in the translation process.
The destructor.
~CA2WEX() throw();
Frees the allocated buffer.
The data member that stores the source string.
LPWSTR m_psz;
The static buffer, used to store the converted string.
wchar_t m_szBuffer[t_nBufferLength];
Conversion operator.
operator LPWSTR() const throw();
Returns the text string as type LPWSTR.
CA2AEX Class
CA2CAEX Class
CW2AEX Class
CW2CWEX Class
CW2WEX Class
Class Overview