📄 string.h
字号:
// String.h: interface for the CString class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _GOS_STRING_H
#define _GOS_STRING_H
#define strlen(psz) CString::StrLen(psz)
enum _tagString
{
StrBufGrowSize=1016,
};
class CString
{
public:
void ReleaseBuffer(int nNewLength);
LPTSTR GetBuffer(int nMinBufLength);
void TrimLeft(LPCTSTR pszTarget);
void TrimRight(LPCTSTR pszTarget);
int Replace(TCHAR chOld, TCHAR chNew);
int Replace(LPCTSTR pszOld,LPCTSTR pszNew);
double toDouble();
int toHex();
int toInt();
void Format(LPCTSTR pszFormat,...);
void MakeLower();
void MakeUpper();
int FindOneOf(LPCTSTR pszCharSet);
int ReverseFind(TCHAR ch);
int Find(TCHAR ch,int nStart);
int Find(LPCTSTR psz,int nStart);
void Mid(CString& strOut,int nFirst);
void Mid(CString& strOut,int nFirst,int nCount);
void Right(CString& strOut,int nCount);
void Left(CString& strOut,int nCount);
int Compare(LPCTSTR psz,int nCount);
void StrCpyN(LPCTSTR psz,int nCount);
void StrCatN(LPCTSTR psz,int nCount);
CString(){m_pData=NULL;}
CString(const CString& str);
CString(LPCTSTR psz);
~CString();
public:
static int StrLen(LPCTSTR psz);
static int StrLenEx(LPCTSTR psz);
static LPCTSTR StrAllocEx(LPCTSTR psz);
static LPCTSTR StrReAllocEx(LPCTSTR pszOld,LPCTSTR pszNew,int nCount);
static void StrFreeEx(LPCTSTR psz);
int GetLength()const{return m_pData?AllocSize(m_pData)/sizeof(TCHAR)-1:0;}
BOOL IsEmpty(){return !GetLength();}
int Find(TCHAR ch){return Find(ch,0);}
int Find(LPCTSTR psz){return Find(psz,0);}
const CString& operator+=(LPCTSTR psz){StrCatN(psz,StrLen(psz));return *this;}
const CString& operator+=(const CString& str){StrCatN(str.m_pData,str.GetLength());return *this;}
const CString& operator=(LPCTSTR psz){StrCpyN(psz,StrLen(psz));return *this;}
const CString& operator=(const CString& str){StrCpyN(str.m_pData,str.GetLength());return *this;}
TCHAR operator[](int nIndex){return m_pData[nIndex];}
BOOL operator==(LPCTSTR psz){return !Compare(psz,GetLength()+1);}
BOOL operator==(const CString& str){return !Compare(str.m_pData,GetLength()+1);}
operator LPCTSTR()const{return LPCTSTR(m_pData);}
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);
LPTSTR m_pData;
};
#endif //_GOS_STRING_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -