www.pudn.com > GOS.rar > KString.h


// KString.h: interface for the KString class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_KSTRING_H__D6046E4A_2822_4989_9DB4_7EF673961114__INCLUDED_) 
#define AFX_KSTRING_H__D6046E4A_2822_4989_9DB4_7EF673961114__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
class KString   
{ 
private: 
	static int fmtInt(TCHAR aBuf[],int nValue,int nSign); 
	static int fmtHex(TCHAR aBuf[],int nValue,BOOL bUpper); 
	static int fmtDouble(TCHAR aBuf[], double dValue,int nPrec,int nSign); 
	static int strlen(LPCTSTR sz); 
	void AllocBuffer(int nLen,BOOL bCopy); 
	void strncpy(LPCTSTR sz,int nCount); 
	void strncat(LPCTSTR sz,int nCount); 
	LPTSTR m_pData; 
	int m_nLength; 
public: 
	void FreeExtra(); 
	void ReleaseBuffer(int nNewLength); 
	LPTSTR GetBuffer(int nMinBufLength); 
	void TrimLeft(LPCTSTR szTarget); 
	void TrimRight(LPCTSTR szTarget); 
	int Replace(LPCTSTR szOld,LPCTSTR szNew); 
	double toDouble(); 
	int toHex(); 
	int toInt(); 
	void Format(LPCTSTR szFormat,...); 
	void MakeLower(); 
	void MakeUpper(); 
	int FindOneOf(LPCTSTR szCharSet); 
	int ReverseFind(TCHAR ch); 
	int Find(TCHAR ch,int nStart); 
	int Find(LPCTSTR sz,int nStart); 
	KString Mid(int nFirst,int nCount); 
	KString Right(int nCount); 
	KString Left(int nCount); 
	int Compare(LPCTSTR sz,int nCount); 
	KString(); 
	KString(const KString& str); 
	KString(LPCTSTR sz); 
	~KString(); 
public: 
	__inline BOOL IsEmpty(){return !m_nLength;} 
	__inline int GetLength(){return m_nLength;} 
	__inline int Find(TCHAR ch){return Find(ch,0);} 
	__inline int Find(LPCTSTR sz){return Find(sz,0);} 
	__inline const KString& operator+=(LPCTSTR sz){strncat(sz,strlen(sz));return *this;} 
	__inline const KString& operator+=(const KString& str){strncat(str.m_pData,str.m_nLength);return *this;} 
	__inline const KString operator+(LPCTSTR sz){KString s=m_pData;s.strncat(sz,strlen(sz));return s;} 
	__inline const KString operator+(const KString& str){KString s=m_pData;s.strncat(str.m_pData,str.m_nLength);return s;} 
	__inline const KString& operator=(LPCTSTR sz){strncpy(sz,strlen(sz));return *this;} 
	__inline const KString& operator=(const KString& str){strncpy(str.m_pData,str.m_nLength);return *this;} 
	__inline TCHAR operator[](int nIndex){return m_pData[nIndex];} 
	__inline BOOL operator==(LPCTSTR sz){return !Compare(sz,m_nLength+1);} 
	__inline BOOL operator==(const KString& str){return !Compare(str.m_pData,m_nLength+1);} 
	__inline operator LPCTSTR(){return LPCTSTR(m_pData);} 
}; 
 
#endif // !defined(AFX_KSTRING_H__D6046E4A_2822_4989_9DB4_7EF673961114__INCLUDED_)