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

📄 stringa.h

📁 自己改写的在WINCE上开发用的EVC++的FTP操作示例工程,希望能给相关人士提供帮助.
💻 H
字号:
// CStringA.h : header file
//
// CStringA Header
//
// Written by Paul E. Bible <pbible@littlefishsoftware.com>
// Copyright (c) 2000. All Rights Reserved.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is 
// not sold for profit without the authors written consent, and 
// providing that this notice and the authors name and all copyright 
// notices remains intact. If the source code in this file is used in 
// any  commercial application then a statement along the lines of 
// "Portions copyright (c) Paul E. Bible, 2000" must be included in
// the startup banner, "About" box -OR- printed documentation. An email 
// letting me know that you are using it would be nice as well. That's 
// not much to ask considering the amount of work that went into this.
// If even this small restriction is a problem send me an email.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage/loss of business that
// this product may cause.
//
// Expect bugs!
// 
// Please use and enjoy, and let me know of any bugs/mods/improvements 
// that you have found/implemented and I will fix/incorporate them into 
// this file. 
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_StringA_H__C514A391_FB4C_11D3_AABC_0000E215F0C2__INCLUDED_)
#define AFX_StringA_H__C514A391_FB4C_11D3_AABC_0000E215F0C2__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CStringA  
{
public: 
	CStringA();
	CStringA(CStringA& szString);
	CStringA(LPCSTR pszString);
	CStringA(BSTR bstrString);
	CStringA(char ch, int nRepeat);
	virtual ~CStringA();
	
	// Assignment Operations
	const CStringA& operator=(CStringA& strSrc);
	const CStringA& operator=(LPCSTR lpsz);
	const CStringA& operator=(BSTR bstrStr);
	operator LPCSTR() const	{ return m_pszString; }
	char*	GetString()			{ return m_pszString; }
	BSTR	AllocSysString();
	
	// Concatenation
	const CStringA& operator+=(CStringA& strSrc);
	const CStringA& operator+=(LPCSTR lpsz);
	const CStringA& operator+=(BSTR bstrStr);
	const CStringA& operator+=(char ch);
	friend CStringA operator+(CStringA& strSrc1, CStringA& strSrc2);
	friend CStringA operator+(CStringA& strSrc, LPCSTR lpsz);
	friend CStringA operator+(LPCSTR lpsz, CStringA& strSrc);
	friend CStringA operator+(CStringA& strSrc, BSTR bstrStr);
	friend CStringA operator+(BSTR bstrStr, CStringA& strSrc);

	// Accessors for the String as an Array
	int		GetLength() const;
	bool	IsEmpty() const;
	void	Empty();
	char	GetAt(int nIndex);
	void	SetAt(int nIndex, char ch);
	char	operator[] (int nIndex);

	// Conversions
	void	MakeUpper();
	void	MakeLower();
	void	MakeReverse();
	void	TrimLeft();
	void	TrimRight();
	void	TrimLeft(LPCSTR lpszTargets);
	void	TrimRight(LPCSTR lpszTargets);

	// Searching
	int		Find(char ch) const;
	int		Find(char ch, int nStart) const;
	int		Find(LPCSTR lpszSub);
	int		Find(LPCSTR lpszSub, int nStart);
	int		FindOneOf(LPCSTR lpszCharSet) const;

	// Extraction
	CStringA Mid(int nFirst) const;
	CStringA Mid(int nFirst, int nCount) const;
	CStringA Left(int nCount) const;
	CStringA Right(int nCount) const;
	CStringA SpanIncluding(LPCSTR lpszCharSet) const;
	CStringA SpanExcluding(LPCSTR lpszCharSet) const;

	// Comparison
	int Compare(CStringA& str) const;
	int Compare(LPCSTR lpsz) const;
	int CompareNoCase(CStringA& str) const;
	int CompareNoCase(LPCSTR lpsz) const;

	// Formatting
	void Format(LPCSTR pszCharSet, ...);

	// Replacing
	int Replace(char chOld, char chNew);
	int Replace(LPCSTR lpszOld, LPCSTR lpszNew);
	
protected:
	LPSTR	m_pszString;
	void	StringCopy(CStringA& str, int nLen, int nIndex, int nExtra) const;
	void	StringCopy(int nSrcLen, LPCSTR lpszSrcData);
	void	ConcatCopy(LPCSTR lpszData);
	void	ConcatCopy(char ch);
	void	ConcatCopy(LPCSTR lpszData1, LPCSTR lpszData2);
	void	AllocString(int nLen);
	void	ReAllocString(int nLen);
};	

// Compare operations
bool operator==(const CStringA& s1, const CStringA& s2);
bool operator==(const CStringA& s1, LPCSTR s2);
bool operator==(LPCSTR s1, const CStringA& s2);
bool operator!=(const CStringA& s1, const CStringA& s2);
bool operator!=(const CStringA& s1, LPCSTR s2);
bool operator!=(LPCSTR s1, const CStringA& s2);

// Compare implementations
inline bool operator==(const CStringA& s1, const CStringA& s2)
	{ return s1.Compare(s2) == 0; }
inline bool operator==(const CStringA& s1, LPCSTR s2)
	{ return s1.Compare(s2) == 0; }
inline bool operator==(LPCSTR s1, const CStringA& s2)
	{ return s2.Compare(s1) == 0; }
inline bool operator!=(const CStringA& s1, const CStringA& s2)
	{ return s1.Compare(s2) != 0; }
inline bool operator!=(const CStringA& s1, LPCSTR s2)
	{ return s1.Compare(s2) != 0; }
inline bool operator!=(LPCSTR s1, const CStringA& s2)
	{ return s2.Compare(s1) != 0; }

#endif // !defined(AFX_StringA_H__C514A391_FB4C_11D3_AABC_0000E215F0C2__INCLUDED_)

⌨️ 快捷键说明

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