ExtMfcSafeNativeTCHAR.h
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:143k
源码类别:
界面编程
开发平台:
Visual C++
- }
- CExtSafeStringT & operator = ( const CExtSafeStringT & strSrc )
- {
- CThisSimpleString::operator = ( strSrc );
- return ( *this );
- }
- CExtSafeStringT & operator = ( const CThisSimpleString& strSrc )
- {
- CThisSimpleString::operator = ( strSrc );
- return ( *this );
- }
- CExtSafeStringT & operator = ( PCXSTR pszSrc )
- {
- CThisSimpleString::operator = ( pszSrc );
- return ( *this );
- }
- CExtSafeStringT & operator = ( PCYSTR pszSrc )
- {
- int nDestLength = (pszSrc != NULL) ? StringTraits::GetBaseTypeLength( pszSrc ) : 0;
- if( nDestLength > 0 )
- {
- PXSTR pszBuffer = GetBuffer( nDestLength );
- StringTraits::ConvertToBaseType( pszBuffer, nDestLength, pszSrc );
- ReleaseBufferSetLength( nDestLength );
- }
- else
- {
- Empty();
- }
- return ( *this );
- }
- CExtSafeStringT & operator = ( const unsigned char* pszSrc )
- {
- return ( operator = ( reinterpret_cast < const char * > ( pszSrc ) ) );
- }
- CExtSafeStringT & operator = ( char ch )
- {
- char ach[2] = { ch, 0 };
- return ( operator = ( ach ) );
- }
- CExtSafeStringT & operator = ( wchar_t ch )
- {
- wchar_t ach[2] = { ch, 0 };
- return ( operator = ( ach ) );
- }
- // CExtSafeStringT & operator = ( const VARIANT& var );
- CExtSafeStringT & operator += ( const CThisSimpleString& str )
- {
- CThisSimpleString::operator += ( str );
- return ( *this );
- }
- CExtSafeStringT & operator += ( PCXSTR pszSrc )
- {
- CThisSimpleString::operator += ( pszSrc );
- return ( *this );
- }
- template < int t_nSize >
- CExtSafeStringT & operator += ( const CStaticString < XCHAR, t_nSize > & strSrc )
- {
- CThisSimpleString::operator += ( strSrc );
- return ( *this );
- }
- CExtSafeStringT & operator += ( PCYSTR pszSrc )
- {
- CExtSafeStringT str( pszSrc, GetManager() );
- return ( operator += ( str ) );
- }
- CExtSafeStringT & operator += ( char ch )
- {
- CThisSimpleString::operator += ( ch );
- return ( *this );
- }
- CExtSafeStringT & operator += ( unsigned char ch )
- {
- CThisSimpleString::operator += ( ch );
- return ( *this );
- }
- CExtSafeStringT & operator += ( wchar_t ch )
- {
- CThisSimpleString::operator += ( ch );
- return ( *this );
- }
- // CExtSafeStringT & operator += ( const VARIANT& var );
- int Compare( PCXSTR psz ) const throw()
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)psz) ) );
- return ( StringTraits::StringCompare( GetString(), psz ) );
- }
- int CompareNoCase( PCXSTR psz ) const throw()
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)psz) ) );
- return ( StringTraits::StringCompareIgnore( GetString(), psz ) );
- }
- int Collate( PCXSTR psz ) const throw()
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)psz) ) );
- return ( StringTraits::StringCollate( GetString(), psz ) );
- }
- int CollateNoCase( PCXSTR psz ) const throw()
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)psz) ) );
- return ( StringTraits::StringCollateIgnore( GetString(), psz ) );
- }
- int Delete( int iIndex, int nCount = 1 )
- {
- ATLASSERT( iIndex >= 0 );
- ATLASSERT( nCount >= 0 );
- int nLength = GetLength();
- if( (nCount+iIndex) > nLength )
- {
- nCount = nLength-iIndex;
- }
- if( nCount > 0 )
- {
- int nNewLength = nLength-nCount;
- int nXCHARsToCopy = nLength-(iIndex+nCount)+1;
- PXSTR pszBuffer = GetBuffer();
- UINT nSizeInBytes =
- nXCHARsToCopy * sizeof(XCHAR);
- __EXT_MFC_MEMMOVE(
- pszBuffer + iIndex,
- nSizeInBytes,
- pszBuffer + iIndex + nCount,
- nSizeInBytes
- );
- ReleaseBufferSetLength( nNewLength );
- }
- return ( GetLength() );
- }
- int Insert( int iIndex, XCHAR ch )
- {
- ATLASSERT( iIndex >= 0 );
- if( iIndex > GetLength() )
- {
- iIndex = GetLength();
- }
- int nNewLength = GetLength()+1;
- PXSTR pszBuffer = GetBuffer( nNewLength );
- UINT nSizeInBytes =
- ( nNewLength - iIndex ) * sizeof(XCHAR);
- __EXT_MFC_MEMMOVE(
- pszBuffer + iIndex + 1,
- nSizeInBytes,
- pszBuffer + iIndex,
- nSizeInBytes
- );
- pszBuffer[iIndex] = ch;
- ReleaseBufferSetLength( nNewLength );
- return ( nNewLength );
- }
- int Insert( int iIndex, PCXSTR psz )
- {
- ATLASSERT( iIndex >= 0 );
- if( iIndex > GetLength() )
- {
- iIndex = GetLength();
- }
- int nInsertLength = StringTraits::SafeStringLen( psz );
- int nNewLength = GetLength();
- if( nInsertLength > 0 )
- {
- nNewLength += nInsertLength;
- PXSTR pszBuffer = GetBuffer( nNewLength );
- UINT nSizeInBytes =
- ( nNewLength - iIndex - nInsertLength + 1 ) * sizeof(XCHAR);
- __EXT_MFC_MEMMOVE(
- pszBuffer + iIndex + nInsertLength,
- nSizeInBytes,
- pszBuffer + iIndex,
- nSizeInBytes
- );
- __EXT_MFC_MEMCPY(
- pszBuffer + iIndex,
- nInsertLength * sizeof(XCHAR),
- psz,
- nInsertLength * sizeof(XCHAR)
- );
- ReleaseBufferSetLength( nNewLength );
- }
- return ( nNewLength );
- }
- int Replace( XCHAR chOld, XCHAR chNew )
- {
- int nCount = 0;
- if( chOld != chNew )
- {
- bool bCopied = false;
- PXSTR pszBuffer = const_cast < PXSTR > ( GetString() );
- int nLength = GetLength();
- int iChar = 0;
- while( iChar < nLength )
- {
- if( pszBuffer[iChar] == chOld )
- {
- if( !bCopied )
- {
- bCopied = true;
- pszBuffer = GetBuffer( nLength );
- }
- pszBuffer[iChar] = chNew;
- nCount++;
- }
- iChar = int( StringTraits::CharNext( pszBuffer+iChar )-pszBuffer );
- }
- if( bCopied )
- {
- ReleaseBufferSetLength( nLength );
- }
- }
- return ( nCount );
- }
- int Replace( PCXSTR pszOld, PCXSTR pszNew )
- {
- int nSourceLen = StringTraits::SafeStringLen( pszOld );
- if( nSourceLen == 0 )
- return ( 0 );
- int nReplacementLen = StringTraits::SafeStringLen( pszNew );
- int nCount = 0;
- {
- PCXSTR pszStart = GetString();
- PCXSTR pszEnd = pszStart+GetLength();
- while( pszStart < pszEnd )
- {
- PCXSTR pszTarget;
- while( (pszTarget = StringTraits::StringFindString( pszStart, pszOld ) ) != NULL)
- {
- nCount++;
- pszStart = pszTarget+nSourceLen;
- }
- pszStart += StringTraits::SafeStringLen( pszStart )+1;
- }
- }
- if( nCount > 0 )
- {
- int nOldLength = GetLength();
- int nNewLength = nOldLength+(nReplacementLen-nSourceLen)*nCount;
- PXSTR pszBuffer = GetBuffer( max( nNewLength, nOldLength ) );
- PXSTR pszStart = pszBuffer;
- PXSTR pszEnd = pszStart+nOldLength;
- while( pszStart < pszEnd )
- {
- PXSTR pszTarget;
- while( (pszTarget = StringTraits::StringFindString( pszStart, pszOld ) ) != NULL )
- {
- int nBalance = nOldLength-int(pszTarget-pszBuffer+nSourceLen);
- UINT nSizeInBytes =
- nBalance * sizeof(XCHAR);
- __EXT_MFC_MEMMOVE(
- pszTarget + nReplacementLen,
- nSizeInBytes,
- pszTarget + nSourceLen,
- nSizeInBytes
- );
- __EXT_MFC_MEMCPY(
- pszTarget,
- nReplacementLen * sizeof(XCHAR),
- pszNew,
- nReplacementLen * sizeof(XCHAR)
- );
- pszStart = pszTarget+nReplacementLen;
- pszTarget[nReplacementLen+nBalance] = 0;
- nOldLength += (nReplacementLen-nSourceLen);
- }
- pszStart += StringTraits::SafeStringLen( pszStart )+1;
- }
- ATLASSERT( pszBuffer[nNewLength] == 0 );
- ReleaseBufferSetLength( nNewLength );
- }
- return ( nCount );
- }
- int Remove( XCHAR chRemove )
- {
- int nLength = GetLength();
- PXSTR pszBuffer = GetBuffer( nLength );
- PXSTR pszSource = pszBuffer;
- PXSTR pszDest = pszBuffer;
- PXSTR pszEnd = pszBuffer+nLength;
- while( pszSource < pszEnd )
- {
- PXSTR pszNewSource = StringTraits::CharNext( pszSource );
- if( *pszSource != chRemove )
- {
- PXSTR pszNewDest = pszDest+(pszNewSource-pszSource);
- while( pszDest != pszNewDest )
- {
- *pszDest = *pszSource;
- pszSource++;
- pszDest++;
- }
- }
- pszSource = pszNewSource;
- }
- *pszDest = 0;
- int nCount = int( pszSource-pszDest );
- ReleaseBufferSetLength( nLength-nCount );
- return ( nCount );
- }
- CExtSafeStringT Tokenize( PCXSTR pszTokens, int& iStart ) const
- {
- ATLASSERT( iStart >= 0 );
- if( pszTokens == NULL )
- {
- return ( *this );
- }
- PCXSTR pszPlace = GetString()+iStart;
- PCXSTR pszEnd = GetString()+GetLength();
- if( pszPlace < pszEnd )
- {
- int nIncluding =
- StringTraits::StringSpanIncluding( pszPlace, pszTokens );
- if( (pszPlace+nIncluding) < pszEnd )
- {
- pszPlace += nIncluding;
- int nExcluding = StringTraits::StringSpanExcluding( pszPlace, pszTokens );
- int iFrom = iStart+nIncluding;
- int nUntil = nExcluding;
- iStart = iFrom+nUntil+1;
- return ( Mid( iFrom, nUntil ) );
- }
- }
- iStart = -1;
- return ( CExtSafeStringT( GetManager() ) );
- }
- int Find( XCHAR ch, int iStart = 0 ) const throw()
- {
- ATLASSERT( iStart >= 0 );
- int nLength = GetLength();
- if( iStart >= nLength)
- {
- return ( -1 );
- }
- PCXSTR psz = StringTraits::StringFindChar( GetString()+iStart, ch );
- return ( (psz == NULL) ? -1 : int( psz-GetString() ) );
- }
- int Find( PCXSTR pszSub, int iStart = 0 ) const throw()
- {
- ATLASSERT( iStart >= 0 );
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszSub) ) );
- int nLength = GetLength();
- if( iStart > nLength )
- {
- return ( -1 );
- }
- PCXSTR psz = StringTraits::StringFindString( GetString()+iStart, pszSub );
- return ( (psz == NULL) ? -1 : int( psz-GetString() ) );
- }
- int FindOneOf( PCXSTR pszCharSet ) const throw()
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszCharSet) ) );
- PCXSTR psz = StringTraits::StringScanSet( GetString(), pszCharSet );
- return ( (psz == NULL) ? -1 : int( psz-GetString() ) );
- }
- int ReverseFind( XCHAR ch ) const throw()
- {
- PCXSTR psz = StringTraits::StringFindCharRev( GetString(), ch );
- return ( (psz == NULL) ? -1 : int( psz-GetString() ) );
- }
- CExtSafeStringT & MakeUpper()
- {
- int nLength = GetLength();
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::StringUppercase( pszBuffer );
- ReleaseBufferSetLength( nLength );
- return ( *this );
- }
- CExtSafeStringT & MakeLower()
- {
- int nLength = GetLength();
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::StringLowercase( pszBuffer );
- ReleaseBufferSetLength( nLength );
- return ( *this );
- }
- CExtSafeStringT & MakeReverse()
- {
- int nLength = GetLength();
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::StringReverse( pszBuffer );
- ReleaseBufferSetLength( nLength );
- return ( *this );
- }
- CExtSafeStringT & TrimRight()
- {
- PCXSTR psz = GetString();
- PCXSTR pszLast = NULL;
- while( *psz != 0 )
- {
- if( StringTraits::IsSpace( *psz ) )
- {
- if( pszLast == NULL )
- pszLast = psz;
- }
- else
- {
- pszLast = NULL;
- }
- psz = StringTraits::CharNext( psz );
- }
- if( pszLast != NULL )
- {
- int iLast = int( pszLast-GetString() );
- Truncate( iLast );
- }
- return ( *this );
- }
- CExtSafeStringT & TrimLeft()
- {
- PCXSTR psz = GetString();
- while( StringTraits::IsSpace( *psz ) )
- {
- psz = StringTraits::CharNext( psz );
- }
- if( psz != GetString() )
- {
- int iFirst = int( psz-GetString() );
- PXSTR pszBuffer = GetBuffer( GetLength() );
- psz = pszBuffer+iFirst;
- int nDataLength = GetLength()-iFirst;
- UINT nSizeInBytes =
- ( nDataLength + 1 ) * sizeof(XCHAR);
- __EXT_MFC_MEMMOVE(
- pszBuffer,
- nSizeInBytes,
- psz,
- nSizeInBytes
- );
- ReleaseBufferSetLength( nDataLength );
- }
- return ( *this );
- }
- CExtSafeStringT & Trim()
- {
- return ( TrimRight().TrimLeft() );
- }
- CExtSafeStringT & Trim( XCHAR chTarget )
- {
- return ( TrimRight( chTarget ).TrimLeft( chTarget ) );
- }
- CExtSafeStringT & Trim( PCXSTR pszTargets )
- {
- return ( TrimRight( pszTargets ).TrimLeft( pszTargets ) );
- }
- CExtSafeStringT & TrimRight( XCHAR chTarget )
- {
- PCXSTR psz = GetString();
- PCXSTR pszLast = NULL;
- while( *psz != 0 )
- {
- if( *psz == chTarget )
- {
- if( pszLast == NULL )
- {
- pszLast = psz;
- }
- }
- else
- {
- pszLast = NULL;
- }
- psz = StringTraits::CharNext( psz );
- }
- if( pszLast != NULL )
- {
- int iLast = int( pszLast-GetString() );
- Truncate( iLast );
- }
- return ( *this );
- }
- CExtSafeStringT & TrimRight( PCXSTR pszTargets )
- {
- if( (pszTargets == NULL) || (*pszTargets == 0) )
- {
- return ( *this );
- }
- PCXSTR psz = GetString();
- PCXSTR pszLast = NULL;
- while( *psz != 0 )
- {
- if( StringTraits::StringFindChar( pszTargets, *psz ) != NULL )
- {
- if( pszLast == NULL )
- {
- pszLast = psz;
- }
- }
- else
- {
- pszLast = NULL;
- }
- psz = StringTraits::CharNext( psz );
- }
- if( pszLast != NULL )
- {
- int iLast = int( pszLast-GetString() );
- Truncate( iLast );
- }
- return ( *this );
- }
- CExtSafeStringT & TrimLeft( XCHAR chTarget )
- {
- PCXSTR psz = GetString();
- while( chTarget == *psz )
- {
- psz = StringTraits::CharNext( psz );
- }
- if( psz != GetString() )
- {
- int iFirst = int( psz-GetString() );
- PXSTR pszBuffer = GetBuffer( GetLength() );
- psz = pszBuffer+iFirst;
- int nDataLength = GetLength()-iFirst;
- UINT nSizeInBytes =
- ( nDataLength + 1 ) * sizeof(XCHAR);
- __EXT_MFC_MEMMOVE(
- pszBuffer,
- nSizeInBytes,
- psz,
- nSizeInBytes
- );
- ReleaseBufferSetLength( nDataLength );
- }
- return ( *this );
- }
- CExtSafeStringT & TrimLeft( PCXSTR pszTargets )
- {
- if( (pszTargets == NULL) || (*pszTargets == 0) )
- {
- return ( *this );
- }
- PCXSTR psz = GetString();
- while( (*psz != 0) && (StringTraits::StringFindChar( pszTargets, *psz ) != NULL) )
- {
- psz = StringTraits::CharNext( psz );
- }
- if( psz != GetString() )
- {
- int iFirst = int( psz-GetString() );
- PXSTR pszBuffer = GetBuffer( GetLength() );
- psz = pszBuffer+iFirst;
- int nDataLength = GetLength()-iFirst;
- UINT nSizeInBytes =
- ( nDataLength + 1 ) * sizeof(XCHAR);
- __EXT_MFC_MEMMOVE(
- pszBuffer,
- nSizeInBytes,
- psz,
- nSizeInBytes
- );
- ReleaseBufferSetLength( nDataLength );
- }
- return ( *this );
- }
- __if_exists( StringTraits::ConvertToOem )
- {
- void AnsiToOem()
- {
- int nLength = GetLength();
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::ConvertToOem( pszBuffer );
- ReleaseBufferSetLength( nLength );
- }
- }
- __if_exists( StringTraits::ConvertToAnsi )
- {
- void OemToAnsi()
- {
- int nLength = GetLength();
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::ConvertToAnsi( pszBuffer );
- ReleaseBufferSetLength( nLength );
- }
- }
- CExtSafeStringT Mid( int iFirst ) const
- {
- return ( Mid( iFirst, GetLength()-iFirst ) );
- }
- CExtSafeStringT Mid( int iFirst, int nCount ) const
- {
- ATLASSERT( iFirst >= 0 );
- ATLASSERT( nCount >= 0 );
- if( (iFirst+nCount) > GetLength() )
- {
- nCount = GetLength()-iFirst;
- }
- if( iFirst > GetLength() )
- {
- nCount = 0;
- }
- ATLASSERT( (nCount == 0) || ((iFirst+nCount) <= GetLength()) );
- if( (iFirst == 0) && ((iFirst+nCount) == GetLength()) )
- {
- return ( *this );
- }
- return ( CExtSafeStringT( GetString()+iFirst, nCount, GetManager() ) );
- }
- CExtSafeStringT Right( int nCount ) const
- {
- ATLASSERT( nCount >= 0 );
- int nLength = GetLength();
- if( nCount >= nLength )
- {
- return ( *this );
- }
- return ( CExtSafeStringT( GetString()+nLength-nCount, nCount, GetManager() ) );
- }
- CExtSafeStringT Left( int nCount ) const
- {
- ATLASSERT( nCount >= 0 );
- int nLength = GetLength();
- if( nCount >= nLength )
- {
- return ( *this );
- }
- return ( CExtSafeStringT( GetString(), nCount, GetManager() ) );
- }
- CExtSafeStringT SpanIncluding( PCXSTR pszCharSet ) const
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszCharSet) ) );
- return ( Left( StringTraits::StringSpanIncluding( GetString(), pszCharSet ) ) );
- }
- CExtSafeStringT SpanExcluding( PCXSTR pszCharSet ) const
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszCharSet) ) );
- return ( Left( StringTraits::StringSpanExcluding( GetString(), pszCharSet ) ) );
- }
- void __cdecl Format( PCXSTR pszFormat, ... )
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszFormat) ) );
- va_list argList;
- va_start( argList, pszFormat );
- FormatV( pszFormat, argList );
- va_end( argList );
- }
- void __cdecl Format( UINT nFormatID, ... )
- {
- CExtSafeStringT strFormat( GetManager() );
- ATLVERIFY( strFormat.LoadString( nFormatID ) );
- va_list argList;
- va_start( argList, nFormatID );
- FormatV( strFormat, argList );
- va_end( argList );
- }
- void __cdecl AppendFormat( UINT nFormatID, ... )
- {
- va_list argList;
- va_start( argList, nFormatID );
- CExtSafeStringT strFormat( GetManager() );
- ATLVERIFY( strFormat.LoadString( nFormatID ) );
- AppendFormatV( strFormat, argList );
- va_end( argList );
- }
- void __cdecl AppendFormat( PCXSTR pszFormat, ... )
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszFormat) ) );
- va_list argList;
- va_start( argList, pszFormat );
- AppendFormatV( pszFormat, argList );
- va_end( argList );
- }
- void AppendFormatV( PCXSTR pszFormat, va_list args )
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszFormat) ) );
- int nCurrentLength = GetLength();
- int nAppendLength = StringTraits::GetFormattedLength( pszFormat, args );
- PXSTR pszBuffer = GetBuffer( nCurrentLength+nAppendLength );
- StringTraits::Format( pszBuffer+nCurrentLength, pszFormat, args );
- ReleaseBufferSetLength( nCurrentLength+nAppendLength );
- }
- void FormatV( PCXSTR pszFormat, va_list args )
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszFormat) ) );
- int nLength = StringTraits::GetFormattedLength( pszFormat, args );
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::Format( pszBuffer, pszFormat, args );
- ReleaseBufferSetLength( nLength );
- }
- __if_exists(StringTraits::FormatMessage)
- {
- void __cdecl FormatMessage( PCXSTR pszFormat, ... )
- {
- va_list argList;
- va_start( argList, pszFormat );
- FormatMessageV( pszFormat, &argList );
- va_end( argList );
- }
- void __cdecl FormatMessage( UINT nFormatID, ... )
- {
- CExtSafeStringT strFormat( GetManager() );
- ATLVERIFY( strFormat.LoadString( nFormatID ) );
- va_list argList;
- va_start( argList, nFormatID );
- FormatMessageV( strFormat, &argList );
- va_end( argList );
- }
- }
- BSTR AllocSysString() const
- {
- BSTR bstrResult = StringTraits::AllocSysString( GetString(),
- GetLength() );
- if( bstrResult == NULL )
- {
- ThrowMemoryException();
- }
- return ( bstrResult );
- }
- BSTR SetSysString( BSTR* pbstr ) const
- {
- ATLASSERT( AtlIsValidAddress( pbstr, sizeof(BSTR) ) );
- if( !StringTraits::ReAllocSysString( GetString(), pbstr,
- GetLength() ) )
- {
- ThrowMemoryException();
- }
- ATLASSERT( *pbstr != NULL );
- return ( *pbstr );
- }
- BOOL GetEnvironmentVariable( PCXSTR pszVar )
- {
- ULONG nLength = StringTraits::GetEnvironmentVariable( pszVar, NULL, 0 );
- BOOL bRetVal = FALSE;
- if( nLength == 0 )
- {
- Empty();
- }
- else
- {
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::GetEnvironmentVariable( pszVar, pszBuffer, nLength );
- ReleaseBuffer();
- bRetVal = TRUE;
- }
- return ( bRetVal );
- }
- BOOL LoadString( UINT nID )
- {
- HINSTANCE hInst = StringTraits::FindStringResourceInstance( nID );
- if( hInst == NULL )
- {
- return ( FALSE );
- }
- return ( LoadString( hInst, nID ) );
- }
- BOOL LoadString( HINSTANCE hInstance, UINT nID )
- {
- const ATLSTRINGRESOURCEIMAGE* pImage = AtlGetStringResourceImage( hInstance, nID );
- if( pImage == NULL )
- {
- return ( FALSE );
- }
- int nLength = StringTraits::GetBaseTypeLength(
- (PCXSTR)pImage->achString,
- pImage->nLength
- );
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::ConvertToBaseType(
- pszBuffer,
- nLength,
- (PCXSTR)pImage->achString,
- pImage->nLength
- );
- ReleaseBufferSetLength( nLength );
- return ( TRUE );
- }
- BOOL LoadString( HINSTANCE hInstance, UINT nID, WORD wLanguageID )
- {
- const ATLSTRINGRESOURCEIMAGE* pImage = AtlGetStringResourceImage( hInstance, nID, wLanguageID );
- if( pImage == NULL )
- {
- return ( FALSE );
- }
- int nLength = StringTraits::GetBaseTypeLength( pImage->achString, pImage->nLength );
- PXSTR pszBuffer = GetBuffer( nLength );
- StringTraits::ConvertToBaseType(
- pszBuffer,
- nLength,
- (StringTraits::PCXSTR)pImage->achString,
- pImage->nLength
- );
- ReleaseBufferSetLength( nLength );
- return ( TRUE );
- }
- friend CExtSafeStringT operator + ( const CExtSafeStringT & str1, const CExtSafeStringT & str2 )
- {
- CExtSafeStringT strResult( str1.GetManager() );
- Concatenate( strResult, str1, str1.GetLength(), str2, str2.GetLength() );
- return ( strResult );
- }
- friend CExtSafeStringT operator + ( const CExtSafeStringT & str1, PCXSTR psz2 )
- {
- CExtSafeStringT strResult( str1.GetManager() );
- Concatenate( strResult, str1, str1.GetLength(), psz2, StringLength( psz2 ) );
- return ( strResult );
- }
- friend CExtSafeStringT operator + ( PCXSTR psz1, const CExtSafeStringT & str2 )
- {
- CExtSafeStringT strResult( str2.GetManager() );
- Concatenate( strResult, psz1, StringLength( psz1 ), str2, str2.GetLength() );
- return ( strResult );
- }
- friend CExtSafeStringT operator + ( const CExtSafeStringT & str1, wchar_t ch2 )
- {
- CExtSafeStringT strResult( str1.GetManager() );
- XCHAR chTemp = XCHAR( ch2 );
- Concatenate( strResult, str1, str1.GetLength(), &chTemp, 1 );
- return ( strResult );
- }
- friend CExtSafeStringT operator + ( const CExtSafeStringT & str1, char ch2 )
- {
- CExtSafeStringT strResult( str1.GetManager() );
- XCHAR chTemp = XCHAR( ch2 );
- Concatenate( strResult, str1, str1.GetLength(), &chTemp, 1 );
- return ( strResult );
- }
- friend CExtSafeStringT operator + ( wchar_t ch1, const CExtSafeStringT & str2 )
- {
- CExtSafeStringT strResult( str2.GetManager() );
- XCHAR chTemp = XCHAR( ch1 );
- Concatenate( strResult, &chTemp, 1, str2, str2.GetLength() );
- return ( strResult );
- }
- friend CExtSafeStringT operator + ( char ch1, const CExtSafeStringT & str2 )
- {
- CExtSafeStringT strResult( str2.GetManager() );
- XCHAR chTemp = XCHAR( ch1 );
- Concatenate( strResult, &chTemp, 1, str2, str2.GetLength() );
- return ( strResult );
- }
- friend bool operator == ( const CExtSafeStringT & str1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str1.Compare( str2 ) == 0 );
- }
- friend bool operator == (
- const CExtSafeStringT & str1, PCXSTR psz2 ) throw()
- {
- return ( str1.Compare( psz2 ) == 0 );
- }
- friend bool operator == (
- PCXSTR psz1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str2.Compare( psz1 ) == 0 );
- }
- friend bool operator == (
- const CExtSafeStringT & str1, PCYSTR psz2 ) throw( ... )
- {
- CExtSafeStringT str2( psz2, str1.GetManager() );
- return ( str1 == str2 );
- }
- friend bool operator == (
- PCYSTR psz1, const CExtSafeStringT & str2 ) throw( ... )
- {
- CExtSafeStringT str1( psz1, str2.GetManager() );
- return ( str1 == str2 );
- }
- friend bool operator != (
- const CExtSafeStringT & str1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str1.Compare( str2 ) != 0 );
- }
- friend bool operator != (
- const CExtSafeStringT & str1, PCXSTR psz2 ) throw()
- {
- return ( str1.Compare( psz2 ) != 0 );
- }
- friend bool operator != (
- PCXSTR psz1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str2.Compare( psz1 ) != 0 );
- }
- friend bool operator != (
- const CExtSafeStringT & str1, PCYSTR psz2 ) throw( ... )
- {
- CExtSafeStringT str2( psz2, str1.GetManager() );
- return ( str1 != str2 );
- }
- friend bool operator != (
- PCYSTR psz1, const CExtSafeStringT & str2 ) throw( ... )
- {
- CExtSafeStringT str1( psz1, str2.GetManager() );
- return ( str1 != str2 );
- }
- friend bool operator < ( const CExtSafeStringT & str1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str1.Compare( str2 ) < 0 );
- }
- friend bool operator < ( const CExtSafeStringT & str1, PCXSTR psz2 ) throw()
- {
- return ( str1.Compare( psz2 ) < 0 );
- }
- friend bool operator < ( PCXSTR psz1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str2.Compare( psz1 ) >= 0 );
- }
- friend bool operator > ( const CExtSafeStringT & str1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str1.Compare( str2 ) > 0 );
- }
- friend bool operator > ( const CExtSafeStringT & str1, PCXSTR psz2 ) throw()
- {
- return ( str1.Compare( psz2 ) > 0 );
- }
- friend bool operator > ( PCXSTR psz1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str2.Compare( psz1 ) <= 0 );
- }
- friend bool operator <= ( const CExtSafeStringT & str1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str1.Compare( str2 ) <= 0 );
- }
- friend bool operator <= ( const CExtSafeStringT & str1, PCXSTR psz2 ) throw()
- {
- return ( str1.Compare( psz2 ) <= 0 );
- }
- friend bool operator <= ( PCXSTR psz1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str2.Compare( psz1 ) > 0 );
- }
- friend bool operator >= ( const CExtSafeStringT & str1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str1.Compare( str2 ) >= 0 );
- }
- friend bool operator >= ( const CExtSafeStringT & str1, PCXSTR psz2 ) throw()
- {
- return ( str1.Compare( psz2 ) >= 0 );
- }
- friend bool operator >= ( PCXSTR psz1, const CExtSafeStringT & str2 ) throw()
- {
- return ( str2.Compare( psz1 ) < 0 );
- }
- friend bool operator == ( XCHAR ch1, const CExtSafeStringT & str2 ) throw()
- {
- return ( (str2.GetLength() == 1) && (str2[0] == ch1) );
- }
- friend bool operator == ( const CExtSafeStringT & str1, XCHAR ch2 ) throw()
- {
- return ( (str1.GetLength() == 1) && (str1[0] == ch2) );
- }
- friend bool operator != ( XCHAR ch1, const CExtSafeStringT & str2 ) throw()
- {
- return ( (str2.GetLength() != 1) || (str2[0] != ch1) );
- }
- friend bool operator != ( const CExtSafeStringT & str1, XCHAR ch2 ) throw()
- {
- return ( (str1.GetLength() != 1) || (str1[0] != ch2) );
- }
- private:
- bool CheckImplicitLoad( const void* pv )
- {
- bool bRet = false;
- if( (pv != NULL) && IS_INTRESOURCE( pv ) )
- {
- UINT nID = LOWORD( reinterpret_cast < DWORD_PTR > ( pv ) );
- if( !LoadString( nID ) )
- {
- ATLTRACE( atlTraceString, 2, _T( "Warning: implicit LoadString(%u) failedn" ), nID );
- }
- bRet = true;
- }
- return ( bRet );
- }
- __if_exists( StringTraits::FormatMessage )
- {
- void FormatMessageV( PCXSTR pszFormat, va_list* pArgList )
- {
- CHeapPtr< XCHAR, CLocalAllocator > pszTemp;
- DWORD dwResult = StringTraits::FormatMessage( FORMAT_MESSAGE_FROM_STRING|
- FORMAT_MESSAGE_ALLOCATE_BUFFER, pszFormat, 0, 0, reinterpret_cast < PXSTR > ( &pszTemp ),
- 0, pArgList );
- if( dwResult == 0 )
- {
- ThrowMemoryException();
- }
- *this = pszTemp;
- }
- }
- }; // class CExtSafeStringT
- template < typename BaseType, class StringTraits >
- inline
- CArchive & operator << (
- CArchive& ar,
- const CExtSafeStringT < BaseType, StringTraits > & str
- )
- {
- AfxWriteStringLength(
- ar,
- str.GetLength(),
- sizeof(BaseType) == sizeof(wchar_t)
- );
- ar.Write(
- str,
- str.GetLength() * sizeof(BaseType)
- );
- return ar;
- }
- template < typename BaseType, class StringTraits >
- inline
- CArchive & operator >> (
- CArchive& ar,
- CExtSafeStringT < BaseType, StringTraits > & str
- )
- {
- int nCharSize;
- UINT nLength = UINT( AfxReadStringLength( ar, nCharSize ) );
- if( nCharSize == sizeof(char) )
- {
- ATL::CTempBuffer < char > pszBufferA( nLength + 1 );
- pszBufferA[ nLength ] = ' ';
- UINT nBytesRead =
- ar.Read(
- pszBufferA,
- nLength * sizeof(char)
- );
- if( nBytesRead != ( nLength * sizeof(char) ) )
- AfxThrowArchiveException( CArchiveException::endOfFile );
- str = pszBufferA;
- }
- else
- {
- ASSERT( nCharSize == sizeof(wchar_t) );
- ATL::CTempBuffer< wchar_t > pszBufferW( nLength+1 );
- pszBufferW[ nLength ] = L' ';
- UINT nBytesRead =
- ar.Read(
- pszBufferW,
- nLength * sizeof(wchar_t)
- );
- if( nBytesRead != ( nLength * sizeof(wchar_t) ) )
- AfxThrowArchiveException( CArchiveException::endOfFile );
- str = (BaseType *)(wchar_t *)pszBufferW;
- }
- return ar;
- }
- typedef
- CExtSafeStrTraitMFC <
- __prof_uis_used_wchar_t,
- CExtSafeChTraitsCRT< __prof_uis_used_wchar_t >
- >
- __prof_uis_used_StrTraitMFC;
- typedef
- CExtSafeStringT <
- __prof_uis_used_wchar_t,
- __prof_uis_used_StrTraitMFC
- >
- __prof_uis_used_CStringT;
- typedef
- CExtSafeStrTraitMFC <
- __prof_uis_converted_wchar_t,
- CExtSafeChTraitsCRT< __prof_uis_used_wchar_t >
- >
- __prof_uis_converted_StrTraitMFC;
- typedef
- CExtSafeStringT <
- __prof_uis_converted_wchar_t,
- __prof_uis_converted_StrTraitMFC
- >
- __prof_uis_converted_CStringT;
- #if (defined _MSC_EXTENSIONS)
- #define __EXT_MFC_TEMPLATED_WCHAR_T_ADAPTOR_NO_VTABLE __declspec(novtable)
- #else
- #define __EXT_MFC_TEMPLATED_WCHAR_T_ADAPTOR_NO_VTABLE
- #endif
- template < class _c_, class _n_ >
- class __EXT_MFC_TEMPLATED_WCHAR_T_ADAPTOR_NO_VTABLE CExtNWCT
- {
- protected:
- _c_ m_data;
- public:
- typedef CExtNWCT < _c_, _n_ > _Myt;
- CExtNWCT( _c_ data )
- : m_data( data )
- {
- }
- CExtNWCT( _n_ data )
- : m_data( * ( ( _c_ * ) ( &data ) ) )
- {
- }
- CExtNWCT( const int _the_null_val = NULL )
- // : m_data( reinterpret_cast < _c_ > ( _the_null_val ) )
- // : m_data( _c_( *((_c_*)LPVOID(&_the_null_val)) ) )
- : m_data( ( _c_ ) ( _the_null_val ) )
- {
- _the_null_val;
- }
- CExtNWCT( const _Myt & other )
- : m_data( other.m_data )
- {
- }
- operator _c_ ()
- {
- return m_data;
- }
- operator _n_ ()
- {
- return * ( ( _n_ * ) ( &m_data ) );
- }
- operator const _c_ () const
- {
- return m_data;
- }
- operator const _n_ () const
- {
- return * ( ( _n_ * ) ( &m_data ) );
- }
- _Myt & operator = ( const _Myt & other )
- {
- m_data = other.m_data;
- return (*this);
- }
- _Myt & operator = ( _c_ data )
- {
- m_data = data;
- return (*this);
- }
- _Myt & operator = ( _n_ data )
- {
- m_data = * ( ( _c_ * ) ( &data ) );
- return (*this);
- }
- _Myt & operator = ( const int _the_null_val )
- {
- m_data = ( reinterpret_cast < _c_ > ( _the_null_val ) );
- return (*this);
- }
- bool operator == ( const _Myt & other ) const
- {
- return (m_data == other.m_data) ? true : false;
- }
- bool operator == ( const _c_ & data ) const
- {
- return (m_data == data) ? true : false;
- }
- bool operator == ( const _n_ & data ) const
- {
- return (m_data == ( * ( ( _c_ * ) ( &data ) ) )) ? true : false;
- }
- bool operator == ( const int _the_null_val ) const
- {
- return (m_data == ( reinterpret_cast < _c_ > ( _the_null_val ) ) ) ? true : false;
- }
- bool operator != ( const _Myt & other ) const
- {
- return (m_data != other.m_data) ? true : false;
- }
- bool operator != ( const _c_ & data ) const
- {
- return (m_data != data) ? true : false;
- }
- bool operator != ( const _n_ & data ) const
- {
- return (m_data != ( * ( ( _c_ * ) ( &data ) ) )) ? true : false;
- }
- bool operator != ( const int _the_null_val ) const
- {
- // return (m_data != ( reinterpret_cast < _c_ > ( _the_null_val ) ) ) ? true : false;
- return (m_data != ( (_c_) (int) ( _the_null_val ) ) ) ? true : false;
- }
- bool operator <= ( const _Myt & other ) const
- {
- return (m_data <= other.m_data) ? true : false;
- }
- bool operator <= ( const _c_ & data ) const
- {
- return (m_data <= data) ? true : false;
- }
- bool operator <= ( const _n_ & data ) const
- {
- return (m_data <= ( * ( ( _c_ * ) ( &data ) ) )) ? true : false;
- }
- bool operator >= ( const _Myt & other ) const
- {
- return (m_data >= other.m_data) ? true : false;
- }
- bool operator >= ( const _c_ & data ) const
- {
- return (m_data >= data) ? true : false;
- }
- bool operator >= ( const _n_ & data ) const
- {
- return (m_data >= ( * ( ( _c_ * ) ( &data ) ) )) ? true : false;
- }
- bool operator < ( const _Myt & other ) const
- {
- return (m_data < other.m_data) ? true : false;
- }
- bool operator < ( const _c_ & data ) const
- {
- return (m_data < data) ? true : false;
- }
- bool operator < ( const _n_ & data ) const
- {
- return (m_data < ( * ( ( _c_ * ) ( &data ) ) )) ? true : false;
- }
- bool operator > ( const _Myt & other ) const
- {
- return (m_data > other.m_data) ? true : false;
- }
- bool operator > ( const _c_ & data ) const
- {
- return (m_data > data) ? true : false;
- }
- bool operator > ( const _n_ & data ) const
- {
- return (m_data > ( * ( ( _c_ * ) ( &data ) ) )) ? true : false;
- }
- operator bool () const
- {
- return (m_data == reinterpret_cast < _c_ > ( NULL )) ? false : true;
- }
- // operator int () const
- // {
- // return (int)m_data;
- // }
- // operator long () const
- // {
- // return (long)m_data;
- // }
- // operator unsigned int () const
- // {
- // return (unsigned int)m_data;
- // }
- // operator unsigned long () const
- // {
- // return (unsigned long)m_data;
- // }
- }; // class CExtNWCT
- template < class _c_, class _n_, class _a_ >
- class __EXT_MFC_TEMPLATED_WCHAR_T_ADAPTOR_NO_VTABLE CExtNWCTA
- : public CExtNWCT < _c_, _n_ >
- {
- public:
- typedef CExtNWCTA < _c_, _n_, _a_ > _Myt;
- typedef CExtNWCT < _c_, _n_ > _Mybt;
- CExtNWCTA( _c_ data )
- : _Mybt( data )
- {
- }
- CExtNWCTA( _n_ data )
- : _Mybt( data )
- {
- }
- CExtNWCTA( const int _the_null_val = NULL )
- : _Mybt( _the_null_val )
- {
- }
- CExtNWCTA( const _Myt & other )
- : _Mybt( other )
- {
- }
- CExtNWCTA( const __prof_uis_used_CStringT & other )
- : _Mybt( ( _i_ )( other.GetString() ) )
- {
- }
- CExtNWCTA( const __prof_uis_converted_CStringT & other )
- : _Mybt( ( _i_ )( other.GetString() ) )
- {
- }
- // _Myt & operator = ( const __prof_uis_used_CStringT & other )
- // {
- // return _Mybt::operator = ( ( _i_ )( other.GetString() ) );
- // }
- // _Myt & operator = ( const __prof_uis_converted_CStringT & other )
- // {
- // return _Mybt::operator = ( ( _i_ )( other.GetString() ) );
- // }
- operator __prof_uis_used_CStringT () const
- {
- return __prof_uis_used_CStringT( (__prof_uis_used_CStringT::XCHAR *)m_data );
- }
- operator __prof_uis_converted_CStringT () const
- {
- return __prof_uis_converted_CStringT( (__prof_uis_converted_CStringT::XCHAR *)m_data );
- }
- _a_ operator [] ( int nIndex ) const
- {
- return ( ( _a_ ) ( m_data[ nIndex ] ) );
- }
- }; // class CExtNWCTA
- template < class _c_, class _i_, class _n_ >
- class __EXT_MFC_TEMPLATED_WCHAR_T_ADAPTOR_NO_VTABLE CExtNWCTC
- {
- protected:
- _i_ m_data;
- public:
- typedef CExtNWCTC < _c_, _i_, _n_ > _Myt;
- CExtNWCTC( _c_ data )
- : m_data( const_cast < _i_ > ( data ) )
- {
- }
- CExtNWCTC( _n_ data )
- : m_data( * ( ( _i_ * ) ( &data ) ) )
- {
- }
- CExtNWCTC( const int _the_null_val = NULL )
- // : m_data( reinterpret_cast < _i_ > ( _the_null_val ) )
- // : m_data( _i_( *((_i_*)LPVOID(&_the_null_val)) ) )
- : m_data( reinterpret_cast < _i_ > ( _the_null_val ) )
- {
- _the_null_val;
- }
- CExtNWCTC( const _Myt & other )
- : m_data( other.m_data )
- {
- }
- operator _c_ () const
- {
- return m_data;
- }
- operator _n_ () const
- {
- return * ( ( _n_ * ) ( &m_data ) );
- }
- _Myt & operator = ( const _Myt & other )
- {
- m_data = other.m_data;
- return (*this);
- }
- _Myt & operator = ( _c_ data )
- {
- m_data = const_cast < _i_ > ( data );
- return (*this);
- }
- _Myt & operator = ( _n_ data )
- {
- m_data = * ( ( _i_ * ) ( &data ) );
- return (*this);
- }
- _Myt & operator = ( const int _the_null_val )
- {
- m_data = ( reinterpret_cast < _i_ > ( _the_null_val ) );
- return (*this);
- }
- bool operator == ( const _Myt & other ) const
- {
- return (m_data == other.m_data) ? true : false;
- }
- bool operator == ( _c_ & data ) const
- {
- return (m_data == ( const_cast < _i_ > ( data ) ) ) ? true : false;
- }
- bool operator == ( _n_ & data ) const
- {
- return (m_data == ( * ( ( _i_ * ) ( &data ) )) ) ? true : false;
- }
- bool operator == ( const int _the_null_val ) const
- {
- return (m_data == ( reinterpret_cast < _i_ > ( _the_null_val ) ) ) ? true : false;
- }
- bool operator != ( const _Myt & other ) const
- {
- return (m_data != other.m_data) ? true : false;
- }
- bool operator != ( _c_ & data ) const
- {
- return (m_data != ( const_cast < _i_ > ( data ) ) ) ? true : false;
- }
- bool operator != ( _n_ & data ) const
- {
- return (m_data != ( * ( ( _i_ * ) ( &data ) )) ) ? true : false;
- }
- bool operator != ( const int _the_null_val ) const
- {
- // return (m_data != ( reinterpret_cast < _i_ > ( _the_null_val ) ) ) ? true : false;
- return (m_data != ( (_c_) (int) ( _the_null_val ) ) ) ? true : false;
- }
- bool operator <= ( const _Myt & other ) const
- {
- return (m_data <= other.m_data) ? true : false;
- }
- bool operator <= ( _c_ & data ) const
- {
- return (m_data <= ( const_cast < _i_ > ( data ) ) ) ? true : false;
- }
- bool operator <= ( _n_ & data ) const
- {
- return (m_data <= ( * ( ( _i_ * ) ( &data ) )) ) ? true : false;
- }
- bool operator >= ( const _Myt & other ) const
- {
- return (m_data >= other.m_data) ? true : false;
- }
- bool operator >= ( _c_ & data ) const
- {
- return (m_data >= ( const_cast < _i_ > ( data ) ) ) ? true : false;
- }
- bool operator >= ( _n_ & data ) const
- {
- return (m_data >= ( * ( ( _i_ * ) ( &data ) )) ) ? true : false;
- }
- bool operator < ( const _Myt & other ) const
- {
- return (m_data < other.m_data) ? true : false;
- }
- bool operator < ( _c_ & data ) const
- {
- return (m_data < ( const_cast < _i_ > ( data ) ) ) ? true : false;
- }
- bool operator < ( _n_ & data ) const
- {
- return (m_data < ( * ( ( _i_ * ) ( &data ) )) ) ? true : false;
- }
- bool operator > ( const _Myt & other ) const
- {
- return (m_data > other.m_data) ? true : false;
- }
- bool operator > ( _c_ & data ) const
- {
- return (m_data > ( const_cast < _i_ > ( data ) ) ) ? true : false;
- }
- bool operator > ( _n_ & data ) const
- {
- return (m_data > ( * ( ( _i_ * ) ( &data ) )) ) ? true : false;
- }
- operator bool () const
- {
- return (m_data == reinterpret_cast < _i_ > ( NULL )) ? false : true;
- }
- // operator int () const
- // {
- // return (int)m_data;
- // }
- // operator long () const
- // {
- // return (long)m_data;
- // }
- // operator unsigned int () const
- // {
- // return (unsigned int)m_data;
- // }
- // operator unsigned long () const
- // {
- // return (unsigned long)m_data;
- // }
- }; // class CExtNWCTC
- template < class _c_, class _i_, class _n_, class _a_ >
- class __EXT_MFC_TEMPLATED_WCHAR_T_ADAPTOR_NO_VTABLE CExtNWCTCA
- : public CExtNWCTC < _c_, _i_, _n_ >
- {
- public:
- typedef CExtNWCTCA < _c_, _i_, _n_, _a_ > _Myt;
- typedef CExtNWCTC < _c_, _i_, _n_ > _Mybt;
- CExtNWCTCA( _c_ data )
- : _Mybt( data )
- {
- }
- CExtNWCTCA( _n_ data )
- : _Mybt( data )
- {
- }
- CExtNWCTCA( const int _the_null_val = NULL )
- : _Mybt( _the_null_val )
- {
- }
- CExtNWCTCA( const _Myt & other )
- : _Mybt( other )
- {
- }
- CExtNWCTCA( const __prof_uis_used_CStringT & other )
- : _Mybt( ( _i_ )( other.GetString() ) )
- {
- }
- CExtNWCTCA( const __prof_uis_converted_CStringT & other )
- : _Mybt( ( _i_ )( other.GetString() ) )
- {
- }
- // _Myt & operator = ( const __prof_uis_used_CStringT & other )
- // {
- // return _Mybt::operator = ( ( _i_ )( other.GetString() ) );
- // }
- // _Myt & operator = ( const __prof_uis_converted_CStringT & other )
- // {
- // return _Mybt::operator = ( ( _i_ )( other.GetString() ) );
- // }
- operator __prof_uis_used_CStringT () const
- {
- return __prof_uis_used_CStringT( (__prof_uis_used_CStringT::PCXSTR)m_data );
- }
- operator __prof_uis_converted_CStringT () const
- {
- return __prof_uis_converted_CStringT( (__prof_uis_converted_CStringT::PCXSTR)m_data );
- }
- _a_ operator [] ( int nIndex ) const
- {
- return ( ( _a_ ) ( m_data[ nIndex ] ) );
- }
- }; // CExtNWCTCA
- typedef CExtNWCT < unsigned short , __wchar_t > __EXT_MFC_SAFE_TCHAR;
- typedef CExtNWCTC < const unsigned short , unsigned short , const __wchar_t > __EXT_MFC_SAFE_CONST_TCHAR;
- typedef CExtNWCTA < unsigned short * , __wchar_t * , __prof_uis_used_wchar_t > __EXT_MFC_SAFE_LPTSTR;
- typedef CExtNWCTCA < const unsigned short * , unsigned short * , const __wchar_t * , __prof_uis_used_wchar_t > __EXT_MFC_SAFE_LPCTSTR;
- typedef CExtNWCT < unsigned short & , __wchar_t & > __EXT_MFC_SAFE_TCHAR_REF;
- typedef CExtNWCTC < const unsigned short & , unsigned short & , const __wchar_t & > __EXT_MFC_SAFE_CONST_TCHAR_REF;
- typedef CExtNWCTA < unsigned short * & , __wchar_t * & , __prof_uis_used_wchar_t > __EXT_MFC_SAFE_LPTSTR_REF;
- typedef CExtNWCTCA < const unsigned short * & , unsigned short * & , const __wchar_t * & , __prof_uis_used_wchar_t > __EXT_MFC_SAFE_LPCTSTR_REF;
- typedef CStringA CExtSafeStringA; // allways same as MFC's
- class CExtSafeStringW : public __prof_uis_used_CStringT
- {
- public:
- CExtSafeStringW()
- {
- }
- // CExtSafeStringW( __EXT_MFC_SAFE_LPTSTR pszSrc )
- // {
- // const __prof_uis_used_wchar_t * ptr = pszSrc;
- // (*this) = ptr;
- // }
- CExtSafeStringW( __EXT_MFC_SAFE_LPCTSTR pszSrc )
- {
- const __prof_uis_used_wchar_t * ptr = pszSrc;
- (*this) = ptr;
- }
- explicit CExtSafeStringW( IAtlStringMgr * pStringMgr ) throw()
- : __prof_uis_used_CStringT( pStringMgr )
- {
- }
- // CExtSafeStringW( const VARIANT & varSrc )
- // : __prof_uis_used_CStringT( varSrc )
- // {
- // }
- // CExtSafeStringW( const VARIANT & varSrc, IAtlStringMgr * pStringMgr )
- // : __prof_uis_used_CStringT( varSrc, pStringMgr )
- // {
- // }
- CExtSafeStringW( const CExtSafeStringW & strSrc )
- : __prof_uis_used_CStringT( strSrc )
- {
- }
- CExtSafeStringW( const __prof_uis_used_CStringT & strSrc )
- : __prof_uis_used_CStringT( strSrc )
- {
- }
- CExtSafeStringW( const XCHAR * pszSrc )
- : __prof_uis_used_CStringT( pszSrc )
- {
- }
- CExtSafeStringW( LPCSTR pszSrc, IAtlStringMgr * pStringMgr )
- : __prof_uis_used_CStringT( pszSrc, pStringMgr )
- {
- }
- CSTRING_EXPLICIT CExtSafeStringW( const YCHAR * pszSrc )
- : __prof_uis_used_CStringT( pszSrc )
- {
- }
- CExtSafeStringW( LPCWSTR pszSrc, IAtlStringMgr * pStringMgr )
- : __prof_uis_used_CStringT( pszSrc, pStringMgr )
- {
- }
- CSTRING_EXPLICIT CExtSafeStringW( const unsigned char * pszSrc )
- : __prof_uis_used_CStringT( pszSrc )
- {
- }
- CExtSafeStringW( const unsigned char * pszSrc, IAtlStringMgr * pStringMgr )
- : __prof_uis_used_CStringT( pszSrc, pStringMgr )
- {
- }
- CSTRING_EXPLICIT CExtSafeStringW( char ch, int nLength = 1 )
- : __prof_uis_used_CStringT( ch, nLength )
- {
- }
- CSTRING_EXPLICIT CExtSafeStringW( __prof_uis_used_wchar_t ch, int nLength = 1 )
- : __prof_uis_used_CStringT( ((XCHAR *)(&ch)), nLength )
- {
- }
- CSTRING_EXPLICIT CExtSafeStringW( __prof_uis_converted_wchar_t ch, int nLength = 1 )
- : __prof_uis_used_CStringT( ((XCHAR *)(&ch)), nLength )
- {
- }
- CExtSafeStringW( const XCHAR * pch, int nLength )
- : __prof_uis_used_CStringT( pch, nLength )
- {
- }
- CExtSafeStringW( const XCHAR * pch, int nLength, IAtlStringMgr * pStringMgr )
- : __prof_uis_used_CStringT( pch, nLength, pStringMgr )
- {
- }
- CExtSafeStringW( const YCHAR * pch, int nLength )
- : __prof_uis_used_CStringT( pch, nLength )
- {
- }
- CExtSafeStringW( const YCHAR * pch, int nLength, IAtlStringMgr * pStringMgr )
- : __prof_uis_used_CStringT( pch, nLength, pStringMgr )
- {
- }
- operator __prof_uis_converted_wchar_t * ()
- {
- LPVOID pData = (LPVOID)GetString();
- return ( (__prof_uis_converted_wchar_t *) pData );
- }
- operator const __prof_uis_converted_wchar_t * () const
- {
- LPVOID pData = (LPVOID)GetString();
- return ( (__prof_uis_converted_wchar_t *) pData );
- }
- operator __prof_uis_used_wchar_t * ()
- {
- LPVOID pData = (LPVOID)GetString();
- return ( (__prof_uis_used_wchar_t *) pData );
- }
- operator const __prof_uis_used_wchar_t * () const
- {
- LPVOID pData = (LPVOID)GetString();
- return ( (__prof_uis_used_wchar_t *) pData );
- }
- operator __EXT_MFC_SAFE_LPTSTR ()
- {
- LPVOID pData = (LPVOID)GetString();
- return __EXT_MFC_SAFE_LPTSTR( (__prof_uis_used_wchar_t *) pData );
- }
- operator __EXT_MFC_SAFE_LPCTSTR () const
- {
- LPVOID pData = (LPVOID)GetString();
- return __EXT_MFC_SAFE_LPCTSTR( (__prof_uis_used_wchar_t *) pData );
- }
- operator __prof_uis_converted_CStringT & ()
- {
- return * ( ( __prof_uis_converted_CStringT * ) ( this ) );
- }
- operator const __prof_uis_converted_CStringT & () const
- {
- return * ( ( __prof_uis_converted_CStringT * ) ( this ) );
- }
- CExtSafeStringW & operator = (
- const __prof_uis_used_wchar_t * other
- )
- {
- __prof_uis_used_CStringT::operator = ( other );
- return (*this);
- }
- CExtSafeStringW & operator = (
- const __prof_uis_converted_wchar_t * other
- )
- {
- return ( operator = ( (__prof_uis_used_wchar_t *)other ) );
- }
- CExtSafeStringW & operator = ( __prof_uis_converted_wchar_t ch )
- {
- __prof_uis_used_wchar_t ach[2] = { ((__prof_uis_used_wchar_t)ch), 0 };
- return ( operator = ( reinterpret_cast < PCXSTR > ( ach ) ) );
- }
- CExtSafeStringW & operator = ( __prof_uis_used_wchar_t ch )
- {
- __prof_uis_used_wchar_t ach[2] = { ((__prof_uis_used_wchar_t)ch), 0 };
- return ( operator=( reinterpret_cast < PCXSTR > ( ach ) ) );
- }
- CExtSafeStringW & operator = ( const __prof_uis_used_CStringT & other )
- {
- return ( operator = ( reinterpret_cast < PCXSTR > ( other.GetString() ) ) );
- }
- CExtSafeStringW & operator = ( const __prof_uis_converted_CStringT & other )
- {
- return ( operator = ( reinterpret_cast < PCXSTR > ( other.GetString() ) ) );
- }
- CExtSafeStringW & operator = (
- __EXT_MFC_SAFE_LPTSTR s
- )
- {
- return ( operator = ( ( const __prof_uis_used_wchar_t * ) ( s ) ) );
- }
- CExtSafeStringW & operator = (
- __EXT_MFC_SAFE_LPCTSTR s
- )
- {
- return ( operator = ( ( const __prof_uis_used_wchar_t * ) ( s ) ) );
- }
- friend CExtSafeStringW operator + (
- const __prof_uis_used_CStringT & str1,
- __prof_uis_converted_wchar_t * psz2
- )
- {
- return
- // disable warning 4675
- #pragma warning( push )
- #pragma warning ( disable : 4675 )
- operator + (
- str1,
- reinterpret_cast < PCXSTR > ( psz2 )
- );
- // rollback warning 4675
- #pragma warning( pop )
- }
- friend CExtSafeStringW operator + (
- __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- )
- {
- // disable warning 4675
- #pragma warning( push )
- #pragma warning ( disable : 4675 )
- return
- operator + (
- reinterpret_cast < PCXSTR > ( psz1 ),
- str2
- );
- // rollback warning 4675
- #pragma warning( pop )
- }
- CExtSafeStringW & operator += ( const char * pszSrc )
- {
- __prof_uis_used_CStringT::operator += ( pszSrc );
- return (*this);
- }
- CExtSafeStringW & operator += ( const __prof_uis_converted_wchar_t * pszSrc )
- {
- __prof_uis_used_CStringT::operator += ( reinterpret_cast < PCXSTR > ( pszSrc ) );
- return (*this);
- }
- CExtSafeStringW & operator += ( const CExtSafeStringW & s )
- {
- __prof_uis_used_CStringT::operator += ( s );
- return (*this);
- }
- CExtSafeStringW & operator += ( char ch )
- {
- __prof_uis_used_CStringT::operator += ( ch );
- return (*this);
- }
- CExtSafeStringW & operator += ( __prof_uis_used_wchar_t ch )
- {
- __prof_uis_used_CStringT::operator += ( (unsigned char)ch );
- return (*this);
- }
- CExtSafeStringW & operator += ( __prof_uis_converted_wchar_t ch )
- {
- __prof_uis_used_CStringT::operator += ( (unsigned char)ch );
- return (*this);
- }
- friend CExtSafeStringW operator + (
- const __prof_uis_used_CStringT & str1,
- const char * psz2
- )
- {
- // disable warning 4675
- #pragma warning( push )
- #pragma warning ( disable : 4675 )
- return
- operator + (
- str1,
- CExtSafeStringW( psz2 )
- );
- // rollback warning 4675
- #pragma warning( pop )
- }
- friend CExtSafeStringW operator + (
- const __prof_uis_used_CStringT & str1,
- const __prof_uis_converted_wchar_t * psz2
- )
- {
- // disable warning 4675
- #pragma warning( push )
- #pragma warning ( disable : 4675 )
- return
- operator + (
- str1,
- reinterpret_cast < PCXSTR > ( psz2 )
- );
- // rollback warning 4675
- #pragma warning( pop )
- }
- friend CExtSafeStringW operator + (
- const char * psz1,
- const __prof_uis_used_CStringT & str2
- )
- {
- return
- operator + (
- CExtSafeStringW( psz1 ),
- str2
- );
- }
- friend CExtSafeStringW operator + (
- const __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- )
- {
- return
- operator + (
- reinterpret_cast < PCXSTR > ( psz1 ),
- str2
- );
- }
- // friend CExtSafeStringW operator + (
- // const __prof_uis_used_CStringT & str1,
- // __prof_uis_converted_wchar_t ch2
- // )
- // {
- // return
- // operator + (
- // str1,
- // * ( reinterpret_cast < XCHAR * > ( &ch2 ) )
- // );
- // }
- // friend CExtSafeStringW operator + (
- // __prof_uis_converted_wchar_t ch1,
- // const __prof_uis_used_CStringT & str2
- // )
- // {
- // return
- // operator + (
- // * ( reinterpret_cast < XCHAR * > ( &ch1 ) ),
- // str2
- // );
- // }
- friend bool operator == (
- const __prof_uis_used_CStringT & str1,
- const __prof_uis_converted_wchar_t * psz2
- ) throw()
- {
- return ( str1.Compare( reinterpret_cast < PCXSTR > ( psz2 ) ) == 0 );
- }
- friend bool operator == (
- const __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( str2.Compare( reinterpret_cast < PCXSTR > ( psz1 ) ) == 0 );
- }
- friend bool operator != (
- const __prof_uis_used_CStringT & str1,
- const __prof_uis_converted_wchar_t * psz2
- ) throw()
- {
- return ( str1.Compare( reinterpret_cast < PCXSTR > ( psz2 ) ) != 0 );
- }
- friend bool operator != (
- const __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( str2.Compare( reinterpret_cast < PCXSTR > ( psz1 ) ) != 0 );
- }
- friend bool operator < (
- const __prof_uis_used_CStringT & str1,
- const __prof_uis_converted_wchar_t * psz2
- ) throw()
- {
- return ( str1.Compare( reinterpret_cast < PCXSTR > ( psz2 ) ) < 0 );
- }
- friend bool operator < (
- const __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( str2.Compare( reinterpret_cast < PCXSTR > ( psz1 ) ) >= 0 );
- }
- friend bool operator > (
- const __prof_uis_used_CStringT & str1,
- const __prof_uis_converted_wchar_t * psz2
- ) throw()
- {
- return ( str1.Compare( reinterpret_cast < PCXSTR > ( psz2 ) ) > 0 );
- }
- friend bool operator > (
- const __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( str2.Compare( reinterpret_cast < PCXSTR > ( psz1 ) ) <= 0 );
- }
- friend bool operator <= (
- const __prof_uis_used_CStringT & str1,
- const __prof_uis_converted_wchar_t * psz2
- ) throw()
- {
- return ( str1.Compare( reinterpret_cast < PCXSTR > ( psz2 ) ) <= 0 );
- }
- friend bool operator <= (
- const __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( str2.Compare( reinterpret_cast < PCXSTR > ( psz1 ) ) > 0 );
- }
- friend bool operator >= (
- const __prof_uis_used_CStringT & str1,
- const __prof_uis_converted_wchar_t * psz2
- ) throw()
- {
- return ( str1.Compare( reinterpret_cast < PCXSTR > ( psz2 ) ) >= 0 );
- }
- friend bool operator >= (
- const __prof_uis_converted_wchar_t * psz1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( str2.Compare( reinterpret_cast < PCXSTR > ( psz1 ) ) < 0 );
- }
- friend bool operator == (
- __prof_uis_converted_wchar_t ch1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( (str2.GetLength() == 1) && (str2[0] == ( * ( reinterpret_cast < XCHAR * > ( &ch1 ) ) )) );
- }
- friend bool operator == (
- const __prof_uis_used_CStringT & str1,
- __prof_uis_converted_wchar_t ch2
- ) throw()
- {
- return ( (str1.GetLength() == 1) && (str1[0] == ( * ( reinterpret_cast < XCHAR * > ( &ch2 ) ) )) );
- }
- friend bool operator != (
- __prof_uis_converted_wchar_t ch1,
- const __prof_uis_used_CStringT & str2
- ) throw()
- {
- return ( (str2.GetLength() != 1) || (str2[0] != ( * ( reinterpret_cast < XCHAR * > ( &ch1 ) ) )) );
- }
- friend bool operator != (
- const __prof_uis_used_CStringT & str1,
- __prof_uis_converted_wchar_t ch2
- ) throw()
- {
- return ( (str1.GetLength() != 1) || (str1[0] != ( * ( reinterpret_cast < XCHAR * > ( &ch2 ) ) )) );
- }
- void __cdecl Format( const __prof_uis_converted_wchar_t * pszFormat, ... )
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszFormat) ) );
- va_list argList;
- va_start( argList, pszFormat );
- FormatV( ((PCXSTR)pszFormat), argList );
- va_end( argList );
- }
- void __cdecl Format( const __prof_uis_used_wchar_t * pszFormat, ... )
- {
- ATLASSERT( AtlIsValidString( ((LPCWSTR)pszFormat) ) );
- va_list argList;
- va_start( argList, pszFormat );
- FormatV( ((PCXSTR)pszFormat), argList );
- va_end( argList );
- }
- }; // class CExtSafeStringW
- typedef CExtSafeStringW CExtSafeString;
- class CExtSafeStringArray : public CStringArray
- {
- public:
- const CExtSafeString & GetAt( INT_PTR nIndex ) const
- {
- const CString & s = CStringArray::GetAt( nIndex );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- void SetAt(
- INT_PTR nIndex,
- __EXT_MFC_SAFE_LPCTSTR newElement
- )
- {
- CStringArray::SetAt(
- nIndex,
- (LPCTSTR)newElement
- );
- }
- void SetAt(
- INT_PTR nIndex,
- const CExtSafeString & newElement
- )
- {
- const CString & s = * ( ( CString * ) ( & newElement ) ); // Xtra-dirty-cast
- CStringArray::SetAt(
- nIndex,
- s
- );
- }
- CExtSafeString & ElementAt( INT_PTR nIndex )
- {
- CString & s = CStringArray::ElementAt( nIndex );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- const CExtSafeString * GetData() const
- {
- const CString * s = CStringArray::GetData();
- return ( ( CExtSafeString * ) ( s ) ); // Xtra-dirty-cast
- }
- CExtSafeString * GetData()
- {
- CString * s = CStringArray::GetData();
- return ( ( CExtSafeString * ) ( s ) ); // Xtra-dirty-cast
- }
- void SetAtGrow(
- INT_PTR nIndex,
- __EXT_MFC_SAFE_LPCTSTR newElement
- )
- {
- CStringArray::SetAtGrow(
- nIndex,
- (LPCTSTR)newElement
- );
- }
- void SetAtGrow(
- INT_PTR nIndex,
- const CExtSafeString & newElement
- )
- {
- CStringArray::SetAtGrow(
- nIndex,
- * ( ( CString * ) ( & newElement ) ) // Xtra-dirty-cast
- );
- }
- INT_PTR Add( __EXT_MFC_SAFE_LPCTSTR newElement )
- {
- return
- CStringArray::Add(
- (LPCTSTR)newElement
- );
- }
- INT_PTR Add( const CExtSafeString & newElement )
- {
- return
- CStringArray::Add(
- * ( ( CString * ) ( & newElement ) ) // Xtra-dirty-cast
- );
- }
- const CExtSafeString & operator [] ( INT_PTR nIndex ) const
- {
- const CString & s = CStringArray::operator [] ( nIndex );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- CExtSafeString & operator [] ( INT_PTR nIndex )
- {
- CString & s = CStringArray::operator [] ( nIndex );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- void InsertAt(
- INT_PTR nIndex,
- __EXT_MFC_SAFE_LPCTSTR newElement,
- INT_PTR nCount = 1
- )
- {
- CStringArray::InsertAt(
- nIndex,
- (LPCTSTR)newElement,
- nCount
- );
- }
- void InsertAt(
- INT_PTR nIndex,
- const CString & newElement,
- INT_PTR nCount = 1
- )
- {
- CStringArray::InsertAt(
- nIndex,
- * ( ( CString * ) ( & newElement ) ), // Xtra-dirty-cast
- nCount
- );
- }
- }; // class CExtSafeStringArray
- class CExtSafeStringList : public CStringList
- {
- public:
- CExtSafeStringList( INT_PTR nBlockSize = 10 )
- : CStringList( nBlockSize )
- {
- }
- CExtSafeString & GetHead()
- {
- CString & s = CStringList::GetHead();
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- const CExtSafeString & GetHead() const
- {
- const CString & s = CStringList::GetHead();
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- CExtSafeString & GetTail()
- {
- CString & s = CStringList::GetTail();
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- const CExtSafeString & GetTail() const
- {
- const CString & s = CStringList::GetTail();
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- CExtSafeString RemoveHead()
- {
- return CExtSafeString( (LPCTSTR)CStringList::RemoveHead() );
- }
- CExtSafeString RemoveTail()
- {
- return CExtSafeString( (LPCTSTR)CStringList::RemoveTail() );
- }
- POSITION AddHead( __EXT_MFC_SAFE_LPCTSTR newElement )
- {
- return CStringList::AddHead( (LPCTSTR)newElement );
- }
- POSITION AddTail( __EXT_MFC_SAFE_LPCTSTR newElement )
- {
- return CStringList::AddTail( (LPCTSTR)newElement );
- }
- POSITION AddHead( const CExtSafeString & newElement )
- {
- return CStringList::AddHead( (LPCTSTR)newElement );
- }
- void AddHead( CExtSafeStringList * pNewList )
- {
- CStringList::AddHead( (CStringList *)pNewList );
- }
- POSITION AddTail( const CExtSafeString & newElement )
- {
- return CStringList::AddTail( (LPCTSTR)newElement );
- }
- void AddTail( CExtSafeStringList * pNewList )
- {
- CStringList::AddTail( (CStringList *)pNewList );
- }
- CExtSafeString & GetNext( POSITION & rPosition )
- {
- CString & s = CStringList::GetNext( rPosition );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- const CExtSafeString & GetNext( POSITION & rPosition ) const
- {
- const CString & s = CStringList::GetNext( rPosition );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- CExtSafeString & GetPrev( POSITION & rPosition )
- {
- CString & s = CStringList::GetPrev( rPosition );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- const CExtSafeString & GetPrev( POSITION & rPosition ) const
- {
- const CString & s = CStringList::GetPrev( rPosition );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- CExtSafeString & GetAt( POSITION position )
- {
- CString & s = CStringList::GetAt( position );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- const CExtSafeString & GetAt( POSITION position ) const
- {
- const CString & s = CStringList::GetAt( position );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- void SetAt( POSITION pos, __EXT_MFC_SAFE_LPCTSTR newElement )
- {
- CStringList::SetAt( pos, (LPCTSTR)newElement );
- }
- void SetAt( POSITION pos, const CExtSafeString & newElement )
- {
- CStringList::SetAt( pos, (LPCTSTR)newElement );
- }
- POSITION InsertBefore( POSITION position, __EXT_MFC_SAFE_LPCTSTR newElement )
- {
- return CStringList::InsertBefore( position, (LPCTSTR)newElement );
- }
- POSITION InsertAfter( POSITION position, __EXT_MFC_SAFE_LPCTSTR newElement )
- {
- return CStringList::InsertAfter( position, (LPCTSTR)newElement );
- }
- POSITION InsertBefore( POSITION position, const CExtSafeString & newElement )
- {
- return CStringList::InsertBefore( position, (LPCTSTR)newElement );
- }
- POSITION InsertAfter( POSITION position, const CExtSafeString & newElement )
- {
- return CStringList::InsertAfter( position, (LPCTSTR)newElement );
- }
- POSITION Find( __EXT_MFC_SAFE_LPCTSTR searchValue, POSITION startAfter = NULL ) const
- {
- return CStringList::Find( searchValue, startAfter );
- }
- }; // class CExtSafeStringList
- class CExtSafeMapStringToPtr : public CMapStringToPtr
- {
- public:
- CExtSafeMapStringToPtr(
- INT_PTR nBlockSize = 10
- )
- : CMapStringToPtr( nBlockSize )
- {
- }
- BOOL Lookup(
- __EXT_MFC_SAFE_LPCTSTR key,
- void * & rValue
- ) const
- {
- return
- CMapStringToPtr::Lookup(
- key,
- rValue
- );
- }
- BOOL LookupKey(
- __EXT_MFC_SAFE_LPCTSTR key,
- __EXT_MFC_SAFE_LPCTSTR & rKey
- ) const
- {
- return
- CMapStringToPtr::LookupKey(
- key,
- (LPCTSTR &) rKey
- );
- }
- void * & operator [] (
- __EXT_MFC_SAFE_LPCTSTR key
- )
- {
- return CMapStringToPtr::operator []( key );
- }
- void SetAt(
- __EXT_MFC_SAFE_LPCTSTR key,
- void * newValue
- )
- {
- CMapStringToPtr::SetAt(
- key,
- newValue
- );
- }
- BOOL RemoveKey(
- __EXT_MFC_SAFE_LPCTSTR key
- )
- {
- return CMapStringToPtr::RemoveKey( key );
- }
- void GetNextAssoc(
- POSITION & rNextPosition,
- CExtSafeString & rKey,
- void * & rValue
- ) const
- {
- CMapStringToPtr::GetNextAssoc(
- rNextPosition,
- (CString&) rKey, // Xtra-dirty-cast
- rValue
- );
- }
- UINT HashKey(
- __EXT_MFC_SAFE_LPCTSTR key
- ) const
- {
- return CMapStringToPtr::HashKey( key );
- }
- }; // class CExtSafeMapStringToPtr
- class CExtSafeMapStringToOb : public CMapStringToOb
- {
- public:
- CExtSafeMapStringToOb( INT_PTR nBlockSize = 10 )
- : CMapStringToOb( nBlockSize )
- {
- }
- BOOL Lookup(
- __EXT_MFC_SAFE_LPCTSTR key,
- CObject * & rValue
- ) const
- {
- return
- CMapStringToOb::Lookup(
- key,
- rValue
- );
- }
- BOOL LookupKey(
- __EXT_MFC_SAFE_LPCTSTR key,
- __EXT_MFC_SAFE_LPCTSTR & rKey
- ) const
- {
- return
- CMapStringToOb::LookupKey(
- key,
- (LPCTSTR &) rKey
- );
- }
- CObject * & operator [] ( __EXT_MFC_SAFE_LPCTSTR key )
- {
- return CMapStringToOb::operator [] ( key );
- }
- void SetAt(
- __EXT_MFC_SAFE_LPCTSTR key,
- CObject * newValue
- )
- {
- CMapStringToOb::SetAt(
- key,
- newValue
- );
- }
- BOOL RemoveKey( __EXT_MFC_SAFE_LPCTSTR key )
- {
- return CMapStringToOb::RemoveKey( key );
- }
- void GetNextAssoc(
- POSITION & rNextPosition,
- CExtSafeString & rKey,
- CObject * & rValue
- ) const
- {
- CMapStringToOb::GetNextAssoc(
- rNextPosition,
- (CString&) rKey, // Xtra-dirty-cast
- rValue
- );
- }
- UINT HashKey( __EXT_MFC_SAFE_LPCTSTR key ) const
- {
- return CMapStringToOb::HashKey( key );
- }
- }; // class CExtSafeMapStringToOb
- class CExtSafeMapStringToString : public CMapStringToString
- {
- public:
- CExtSafeMapStringToString( INT_PTR nBlockSize = 10 )
- : CMapStringToString( nBlockSize )
- {
- }
- BOOL Lookup(
- __EXT_MFC_SAFE_LPCTSTR key,
- CExtSafeString & rValue
- ) const
- {
- return
- CMapStringToString::Lookup(
- key,
- (CString &) rValue // Xtra-dirty-cast
- );
- }
- const CPair * PLookup( __EXT_MFC_SAFE_LPCTSTR key ) const
- {
- return CMapStringToString::PLookup( key );
- }
- CPair * PLookup( __EXT_MFC_SAFE_LPCTSTR key )
- {
- return CMapStringToString::PLookup( key );
- }
- BOOL LookupKey(
- __EXT_MFC_SAFE_LPCTSTR key,
- __EXT_MFC_SAFE_LPCTSTR & rKey
- ) const
- {
- return
- CMapStringToString::LookupKey(
- key,
- (LPCTSTR &) rKey
- );
- }
- CExtSafeString & operator [] ( __EXT_MFC_SAFE_LPCTSTR key )
- {
- CString & s = CMapStringToString::operator [] ( key );
- return * ( ( CExtSafeString * ) ( & s ) ); // Xtra-dirty-cast
- }
- void SetAt(
- __EXT_MFC_SAFE_LPCTSTR key,
- __EXT_MFC_SAFE_LPCTSTR newValue
- )
- {
- CMapStringToString::SetAt(
- key,
- newValue
- );
- }
- BOOL RemoveKey(
- __EXT_MFC_SAFE_LPCTSTR key
- )
- {
- return
- CMapStringToString::RemoveKey(
- key
- );
- }
- void GetNextAssoc(
- POSITION & rNextPosition,
- CExtSafeString & rKey,
- CExtSafeString & rValue
- ) const
- {
- CMapStringToString::GetNextAssoc(
- rNextPosition,
- (CString &) rKey, // Xtra-dirty-cast
- (CString &) rValue // Xtra-dirty-cast
- );
- }
- UINT HashKey(__EXT_MFC_SAFE_LPCTSTR key) const
- {
- return CMapStringToString::HashKey( key );
- }
- }; // class CExtSafeMapStringToString
- #define __EXT_MFC_SAFE_ON_WM_DEVMODECHANGE()
- { WM_DEVMODECHANGE, 0, 0, 0, AfxSig_vs,
- (AFX_PMSG)(AFX_PMSGW)
- (static_cast < void (AFX_MSG_CALL CWnd::*)(__EXT_MFC_SAFE_LPTSTR) > (OnDevModeChange)) },
- #define __EXT_MFC_SAFE_ON_WM_ASKCBFORMATNAME()
- { WM_ASKCBFORMATNAME, 0, 0, 0, AfxSig_vwl,
- (AFX_PMSG)(AFX_PMSGW)
- (static_cast < void (AFX_MSG_CALL CWnd::*)(UINT, __EXT_MFC_SAFE_LPTSTR) > (OnAskCbFormatName)) },
- #define __EXT_MFC_SAFE_ON_WM_SETTINGCHANGE()
- { WM_SETTINGCHANGE, 0, 0, 0, AfxSig_vws,
- (AFX_PMSG)(AFX_PMSGW)
- (static_cast < void (AFX_MSG_CALL CWnd::*)(UINT, __EXT_MFC_SAFE_LPCTSTR) > (OnSettingChange)) },
- #define __EXT_MFC_SAFE_ON_WM_WININICHANGE()
- { WM_WININICHANGE, 0, 0, 0, AfxSig_vs,
- (AFX_PMSG)(AFX_PMSGW)
- (static_cast < void (AFX_MSG_CALL CWnd::*)(__EXT_MFC_SAFE_LPCTSTR) > (OnWinIniChange)) },
- #else // if - (defined __EXT_MFC_ENABLE_TEMPLATED_CHARS)
- #pragma message(" Prof-UIS native unicode character type support:")
- #pragma message(" disabled (symbol __EXT_MFC_ENABLE_TEMPLATED_CHARS is not defined)")
- #endif // if not - (defined __EXT_MFC_ENABLE_TEMPLATED_CHARS)
- #endif // (defined _UNICODE) && (defined _WCHAR_T_DEFINED) && (defined __EXT_MFC_ENABLE_TEMPLATED_CHARS)
- #endif // #if _MFC_VER >= 0x700
- #if (!defined __EXT_MFC_TEMPLATED_CHARS_IMPLEMENTED)
- typedef TCHAR __EXT_MFC_SAFE_TCHAR;
- typedef const TCHAR __EXT_MFC_SAFE_CONST_TCHAR;
- typedef LPTSTR __EXT_MFC_SAFE_LPTSTR;
- typedef LPCTSTR __EXT_MFC_SAFE_LPCTSTR;
- typedef TCHAR & __EXT_MFC_SAFE_TCHAR_REF;
- typedef const TCHAR & __EXT_MFC_SAFE_CONST_TCHAR_REF;
- typedef LPTSTR & __EXT_MFC_SAFE_LPTSTR_REF;
- typedef LPCTSTR & __EXT_MFC_SAFE_LPCTSTR_REF;
- typedef TCHAR __prof_uis_used_wchar_t;
- typedef TCHAR __prof_uis_converted_wchar_t;
- typedef CString CExtSafeString;
- #if _MFC_VER >= 0x700
- typedef CStringA CExtSafeStringA; // allways same as MFC's
- typedef CStringW CExtSafeStringW;
- #endif // #if _MFC_VER >= 0x700
- typedef CStringArray CExtSafeStringArray;
- typedef CStringList CExtSafeStringList;
- typedef CMapStringToPtr CExtSafeMapStringToPtr;
- typedef CMapStringToOb CExtSafeMapStringToOb;
- typedef CMapStringToString CExtSafeMapStringToString;
- #define __EXT_MFC_SAFE_ON_WM_DEVMODECHANGE()
- ON_WM_DEVMODECHANGE()
- #define __EXT_MFC_SAFE_ON_WM_ASKCBFORMATNAME()
- ON_WM_ASKCBFORMATNAME()
- #define __EXT_MFC_SAFE_ON_WM_SETTINGCHANGE()
- ON_WM_SETTINGCHANGE()
- #define __EXT_MFC_SAFE_ON_WM_WININICHANGE()
- ON_WM_WININICHANGE()
- #endif (!defined __EXT_MFC_TEMPLATED_CHARS_IMPLEMENTED)
- #if _MFC_VER >= 0x800
- // rollback warning 4201
- #pragma warning( pop )
- #endif // _MFC_VER >= 0x800
- #endif // __ExtMfcSafeNativeTCHAR_H