015
06.07.2005, 11:19 Uhr
FloSoft
Medialer Over-Flow (Administrator)
|
definiers selbst wenn ers nicht findet:
C++: |
template< int t_nBufferLength = 128 > class CW2AEX { public: CW2AEX( LPCWSTR psz ) throw(...) : m_psz( m_szBuffer ) { Init( psz, _AtlGetConversionACP() ); } CW2AEX( LPCWSTR psz, UINT nCodePage ) throw(...) : m_psz( m_szBuffer ) { Init( psz, nCodePage ); } ~CW2AEX() throw() { if( m_psz != m_szBuffer ) { free( m_psz ); } }
operator LPSTR() const throw() { return( m_psz ); }
private: void Init( LPCWSTR psz, UINT nCodePage ) throw(...) { if (psz == NULL) { m_psz = NULL; return; } int nLengthW = lstrlenW( psz )+1; int nLengthA = nLengthW*2;
if( nLengthA > t_nBufferLength ) { m_psz = static_cast< LPSTR >( malloc( nLengthA*sizeof( char ) ) ); if (m_psz == NULL) { AtlThrow( E_OUTOFMEMORY ); } }
if (::WideCharToMultiByte( nCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL ) == 0) { AtlThrowLastWin32(); } }
public: LPSTR m_psz; char m_szBuffer[t_nBufferLength];
private: CW2AEX( const CW2AEX& ) throw(); CW2AEX& operator=( const CW2AEX& ) throw(); }; typedef CW2AEX<> CW2A;
|
-- class God : public ChuckNorris { }; Dieser Post wurde am 06.07.2005 um 11:24 Uhr von FloSoft editiert. |