⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringex.h

📁 chm reader源代码 evc下使用 pocket pc 2003 能够阅读chm格式
💻 H
字号:
//-------------------------------------------------------------------------------------------------
//
//	IBSL Technologies (c) 2000
//	BrainTree Development Ltd(c) 2000
//
//	Rennie Bowe
//	P J Tewkesbury
//
//-------------------------------------------------------------------------------------------------
//
//////////////////////////////////////////////////////////////////////
// StringEx.h
//

#ifndef __STRINGEX_H_
#define __STRINGEX_H_

#include "atlconv.h"

// To be added
// FormatSystemErrorMessage :- Takes Error code & converts it into a string.

class CStringEx : public CString
{
public:
	friend CString;

	CStringEx() : CString() {};
	CStringEx( const CString& stringSrc) : CString( stringSrc ){};
	CStringEx( const CStringEx& stringSrc) : CString( stringSrc ){};
	CStringEx( TCHAR ch, int nRepeat = 1 ) : CString( ch, nRepeat ){};
	CStringEx( LPCTSTR lpch, int nLength ) : CString( lpch, nLength ){};
	CStringEx( const unsigned char* psz ) : CString( psz ){};
	CStringEx( LPCWSTR lpsz ) : CString( lpsz ){};
	CStringEx( LPWSTR lpsz ) : CString( lpsz ){};

	CStringEx(DWORD SystemErrorCode);
	CStringEx(TCHAR *szFormat, ... );
	CStringEx(UINT nResID);				// Load string with Resource String

	void operator () (UINT nResID);		// CString Name; Name(nID);

#if 0
	CStringEx( STRRET strRet ) : CString()
	{			
		USES_CONVERSION;
		switch(strRet.uType)
		{
		case STRRET_CSTR:
			{				
				Format(_T("%s"),A2W(strRet.cStr));
			}
			break;

		case STRRET_WSTR:
			{	
				Format(_T("%s"),OLE2W(strRet.pOleStr));				
			}
			break;
		}	
	};d

#endif

	CStringEx(int Size) : CString()
	{			
		GetBufferSetLength(Size);		
	};	

public:
	CStringEx&	Append(CString Fmt,...);

	CStringEx&	Insert(int pos, LPCTSTR s);
	CStringEx&	Insert(int pos, TCHAR c);

	CStringEx&	Delete(int pos, int len);
	CStringEx&	Replace(int pos, int len, LPCTSTR s);
	CStringEx&	ReplaceAll(LPCTSTR s1, LPCTSTR s2);

	int			Find( TCHAR ch, int startpos = 0 ) const;
	int			Find( LPCTSTR lpszSub, int startpos = 0 ) const;
	int			FindNoCase( TCHAR ch, int startpos = 0 ) const;
	int			FindNoCase( LPCTSTR lpszSub, int startpos = 0 ) const;

	int			FindReplace( LPCTSTR lpszSub, LPCTSTR lpszReplaceWith, BOOL bGlobal = TRUE );
	int			FindReplaceNoCase( LPCTSTR lpszSub, LPCTSTR lpszReplaceWith, BOOL bGlobal = TRUE );

	int			ReverseFind( TCHAR ch ) { return CString::ReverseFind(ch);};
	int			ReverseFind( LPCTSTR lpszSub, int startpos = -1 );
	int			ReverseFindNoCase( TCHAR ch, int startpos = -1  );
	int			ReverseFindNoCase( LPCTSTR lpszSub, int startpos = -1 );

	CStringEx	GetField( LPCTSTR delim, int fieldnum);
	CStringEx	GetField( TCHAR delim, int fieldnum);
	int			GetFieldCount( LPCTSTR delim );
	int			GetFieldCount( TCHAR delim );

	CStringEx	GetDelimitedField( LPCTSTR delimStart, LPCTSTR delimEnd, int fieldnum = 0);	
	void		StripFormatChars();
	CStringEx	RemoveAll(TCHAR c) const;
	CStringEx	RemoveAll(const CStringEx& s) const;
	CStringEx	Remove(TCHAR c) const;
	CStringEx	Remove(const CStringEx& s) const;
	int			CountChar(TCHAR ch);
	void		RemoveExtraSpaces();

	CStringEx&	operator<<(int Value)
	{		
		Append(_T("%d"),Value);		
		return *this;
	};

	CStringEx&	operator<<(LPCTSTR Text)
	{		
		Append(_T("%s"),Text);
		return *this;
	};

	CStringEx&	operator<<(LPTSTR Text)
	{		
		Append(_T("%s"),Text);
		return *this;
	};

	CStringEx&	operator<<(DWORD Value)
	{		
		Append(_T("%d"),Value);
		return *this;
	};
	
#ifdef _UNICODE
	CStringEx&	operator<<(LPCSTR Text)
	{		
		USES_CONVERSION;
		Append(_T("%s"),A2T(Text));
		return *this;
	};

	CStringEx&	operator<<(LPSTR Text)
	{		
		USES_CONVERSION;
		Append(_T("%s"),A2T(Text));
		return *this;
	};
#endif
};

#endif
/////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -