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

📄 xstring

📁 pwlib源码库
💻
📖 第 1 页 / 共 2 页
字号:
	const_iterator begin() const		{return (_Ptr); }	iterator end()		{_Freeze();		return ((iterator)_Psum(_Ptr, _Len)); }	const_iterator end() const		{return ((const_iterator)_Psum(_Ptr, _Len)); }	reverse_iterator rbegin()		{return (reverse_iterator(end())); }	const_reverse_iterator rbegin() const		{return (const_reverse_iterator(end())); }	reverse_iterator rend()		{return (reverse_iterator(begin())); }	const_reverse_iterator rend() const		{return (const_reverse_iterator(begin())); }	reference at(size_type _P0)		{if (_Len <= _P0)			_Xran();		_Freeze();		return (_Ptr[_P0]); }	const_reference at(size_type _P0) const		{if (_Len <= _P0)			_Xran();		return (_Ptr[_P0]); }	reference operator[](size_type _P0)		{if (_Len < _P0 || _Ptr == 0)			return ((reference)*_Nullstr());		_Freeze();		return (_Ptr[_P0]); }	const_reference operator[](size_type _P0) const		{if (_Ptr == 0)			return (*_Nullstr());		else			return (_Ptr[_P0]); }	const _E *c_str() const		{return (_Ptr == 0 ? _Nullstr() : _Ptr); }	const _E *data() const		{return (c_str()); }	size_type length() const		{return (_Len); }	size_type size() const		{return (_Len); }	size_type max_size() const		{size_type _N = allocator.max_size();		return (_N <= 2 ? 1 : _N - 2); }	void resize(size_type _N, _E _C)		{_N <= _Len ? erase(_N) : append(_N - _Len, _C); }	void resize(size_type _N)		{_N <= _Len ? erase(_N) : append(_N - _Len, _E(0)); }	size_type capacity() const		{return (_Res); }	void reserve(size_type _N = 0)		{if (_Res < _N)			_Grow(_N); }	bool empty() const		{return (_Len == 0); }	size_type copy(_E *_S, size_type _N, size_type _P0 = 0) const		{if (_Len < _P0)			_Xran();		if (_Len - _P0 < _N)			_N = _Len - _P0;		if (0 < _N)			_Tr::copy(_S, _Ptr + _P0, _N);		return (_N); }	void swap(_Myt& _X)		{if (allocator == _X.allocator)			{std::swap(_Ptr, _X._Ptr);			std::swap(_Len, _X._Len);			std::swap(_Res, _X._Res); }		else			{_Myt _Ts = *this; *this = _X, _X = _Ts; }}	friend void swap(_Myt& _X, _Myt& _Y)		{_X.swap(_Y); }	size_type find(const _Myt& _X, size_type _P = 0) const		{return (find(_X.c_str(), _P, _X.size())); }	size_type find(const _E *_S, size_type _P,		size_type _N) const		{if (_N == 0 && _P <= _Len)			return (_P);		size_type _Nm;		if (_P < _Len && _N <= (_Nm = _Len - _P))			{const _E *_U, *_V;			for (_Nm -= _N - 1, _V = _Ptr + _P;				(_U = _Tr::find(_V, _Nm, *_S)) != 0;				_Nm -= _U - _V + 1, _V = _U + 1)				if (_Tr::compare(_U, _S, _N) == 0)					return (_U - _Ptr); }		return (npos); }	size_type find(const _E *_S, size_type _P = 0) const		{return (find(_S, _P, _Tr::length(_S))); }	size_type find(_E _C, size_type _P = 0) const		{return (find((const _E *)&_C, _P, 1)); }	size_type rfind(const _Myt& _X, size_type _P = npos) const		{return (rfind(_X.c_str(), _P, _X.size())); }	size_type rfind(const _E *_S, size_type _P,		size_type _N) const		{if (_N == 0)			return (_P < _Len ? _P : _Len);		if (_N <= _Len)			for (const _E *_U = _Ptr +				+ (_P < _Len - _N ? _P : _Len - _N); ; --_U)				if (_Tr::eq(*_U, *_S)					&& _Tr::compare(_U, _S, _N) == 0)					return (_U - _Ptr);				else if (_U == _Ptr)					break;		return (npos); }	size_type rfind(const _E *_S, size_type _P = npos) const		{return (rfind(_S, _P, _Tr::length(_S))); }	size_type rfind(_E _C, size_type _P = npos) const		{return (rfind((const _E *)&_C, _P, 1)); }	size_type find_first_of(const _Myt& _X,		size_type _P = 0) const		{return (find_first_of(_X.c_str(), _P, _X.size())); }	size_type find_first_of(const _E *_S, size_type _P,		size_type _N) const		{if (0 < _N && _P < _Len)			{const _E *const _V = _Ptr + _Len;			for (const _E *_U = _Ptr + _P; _U < _V; ++_U)				if (_Tr::find(_S, _N, *_U) != 0)					return (_U - _Ptr); }		return (npos); }	size_type find_first_of(const _E *_S, size_type _P = 0) const		{return (find_first_of(_S, _P, _Tr::length(_S))); }	size_type find_first_of(_E _C, size_type _P = 0) const		{return (find((const _E *)&_C, _P, 1)); }	size_type find_last_of(const _Myt& _X,		size_type _P = npos) const		{return (find_last_of(_X.c_str(), _P, _X.size())); }	size_type find_last_of(const _E *_S, size_type _P,		size_type _N) const		{if (0 < _N && 0 < _Len)			for (const _E *_U = _Ptr				+ (_P < _Len ? _P : _Len - 1); ; --_U)				if (_Tr::find(_S, _N, *_U) != 0)					return (_U - _Ptr);				else if (_U == _Ptr)					break;		return (npos); }	size_type find_last_of(const _E *_S,		size_type _P = npos) const		{return (find_last_of(_S, _P, _Tr::length(_S))); }	size_type find_last_of(_E _C, size_type _P = npos) const		{return (rfind((const _E *)&_C, _P, 1)); }	size_type find_first_not_of(const _Myt& _X,		size_type _P = 0) const		{return (find_first_not_of(_X.c_str(), _P,			_X.size())); }	size_type find_first_not_of(const _E *_S, size_type _P,		size_type _N) const		{if (_P < _Len)			{const _E *const _V = _Ptr + _Len;			for (const _E *_U = _Ptr + _P; _U < _V; ++_U)				if (_Tr::find(_S, _N, *_U) == 0)					return (_U - _Ptr); }		return (npos); }	size_type find_first_not_of(const _E *_S,		size_type _P = 0) const		{return (find_first_not_of(_S, _P, _Tr::length(_S))); }	size_type find_first_not_of(_E _C, size_type _P = 0) const		{return (find_first_not_of((const _E *)&_C, _P, 1)); }	size_type find_last_not_of(const _Myt& _X,		size_type _P = npos) const		{return (find_last_not_of(_X.c_str(), _P, _X.size())); }	size_type find_last_not_of(const _E *_S, size_type _P,		 size_type _N) const		{if (0 < _Len)			for (const _E *_U = _Ptr				+ (_P < _Len ? _P : _Len - 1); ; --_U)				if (_Tr::find(_S, _N, *_U) == 0)					return (_U - _Ptr);				else if (_U == _Ptr)					break;		return (npos); }	size_type find_last_not_of(const _E *_S,		size_type _P = npos) const		{return (find_last_not_of(_S, _P, _Tr::length(_S))); }	size_type find_last_not_of(_E _C, size_type _P = npos) const		{return (find_last_not_of((const _E *)&_C, _P, 1)); }	_Myt substr(size_type _P = 0, size_type _M = npos) const		{return (_Myt(*this, _P, _M)); }	int compare(const _Myt& _X) const		{return (compare(0, _Len, _X.c_str(), _X.size())); }	int compare(size_type _P0, size_type _N0,		const _Myt& _X) const		{return (compare(_P0, _N0, _X, 0, npos)); }	int compare(size_type _P0, size_type _N0, const _Myt& _X,		size_type _P, size_type _M) const		{if (_X.size() < _P)			_Xran();		if (_X._Len - _P < _M)			_M = _X._Len - _P;		return (compare(_P0, _N0, _X.c_str() + _P, _M)); }	int compare(const _E *_S) const		{return (compare(0, _Len, _S, _Tr::length(_S))); }	int compare(size_type _P0, size_type _N0, const _E *_S) const		{return (compare(_P0, _N0, _S, _Tr::length(_S))); }	int compare(size_type _P0, size_type _N0, const _E *_S,		size_type _M) const		{if (_Len < _P0)			_Xran();		if (_Len - _P0 < _N0)			_N0 = _Len - _P0;		size_type _Ans = _Tr::compare(_Psum(_Ptr, _P0), _S,			_N0 < _M ? _N0 : _M);		return (_Ans != 0 ? _Ans : _N0 < _M ? -1			: _N0 == _M ? 0 : +1); }	_A get_allocator() const		{return (allocator); }protected:	_A allocator;private:	enum {_MIN_SIZE = sizeof (_E) <= 32 ? 31 : 7};	void _Copy(size_type _N)		{size_type _Ns = _N | _MIN_SIZE;		if (max_size() < _Ns)			_Ns = _N;		_E *_S;		_TRY_BEGIN			_S = allocator.allocate(_Ns + 2, (void *)0);		_CATCH_ALL			_Ns = _N;			_S = allocator.allocate(_Ns + 2, (void *)0);		_CATCH_END		if (0 < _Len)			_Tr::copy(_S + 1, _Ptr, _Len);		size_type _Olen = _Len;		_Tidy(true);		_Ptr = _S + 1;		_Refcnt(_Ptr) = 0;		_Res = _Ns;		_Eos(_Olen); }	void _Eos(size_type _N)		{_Tr::assign(_Ptr[_Len = _N], _E(0)); }	void _Freeze()		{if (_Ptr != 0			&& _Refcnt(_Ptr) != 0 && _Refcnt(_Ptr) != _FROZEN)			_Grow(_Len);		if (_Ptr != 0)			_Refcnt(_Ptr) = _FROZEN; }	bool _Grow(size_type _N, bool _Trim = false)		{if (max_size() < _N)			_Xlen();		if (_Trim)			_Len = 0;		else if (_N < _Len)			_Len = _N;		if (_Ptr != 0			&& _Refcnt(_Ptr) != 0 && _Refcnt(_Ptr) != _FROZEN)			if (_N == 0)				{_Tidy(true);				return (false); }			else				{_Copy(_N);				return (true); }		if (_N == 0)			{if (_Trim)				_Tidy(true);			else if (_Ptr != 0)				_Eos(0);			return (false); }		else			{if (_Trim && (_MIN_SIZE < _Res || _Res < _N))				{_Tidy(true);				_Copy(_N); }			else if (!_Trim && _Res < _N)				_Copy(_N);			return (true); }}	static const _E * __cdecl _Nullstr()		{static const _E _C = _E(0);		return (&_C); }	static size_type _Pdif(const_pointer _P2, const_pointer _P1)		{return (_P2 == 0 ? 0 : _P2 - _P1); }	static const_pointer _Psum(const_pointer _P, size_type _N)		{return (_P == 0 ? 0 : _P + _N); }	static pointer _Psum(pointer _P, size_type _N)		{return (_P == 0 ? 0 : _P + _N); }	unsigned char& _Refcnt(const _E *_U)		{return (((unsigned char *)_U)[-1]); }	void _Tidy(bool _Built = false)		{if (!_Built || _Ptr == 0)			;		else if (_Refcnt(_Ptr) == 0 || _Refcnt(_Ptr) == _FROZEN)			allocator.deallocate(_Ptr - 1, _Res + 2);		else			--_Refcnt(_Ptr);		_Ptr = 0, _Len = 0, _Res = 0; }	_E *_Ptr;	size_type _Len, _Res;	};template<class _E, class _Tr, class _A>	const basic_string<_E, _Tr, _A>::size_type		basic_string<_E, _Tr, _A>::npos = -1;#ifdef	_DLL#pragma warning(disable:4231) /* the extern before template is a non-standard extension */extern template class _CRTIMP basic_string<char, char_traits<char>, allocator<char> >;extern template class _CRTIMP basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;#pragma warning(default:4231) /* restore previous warning */#endiftypedef basic_string<char, char_traits<char>, allocator<char> >	string;typedef basic_string<wchar_t, char_traits<wchar_t>,	allocator<wchar_t> > wstring;_STD_END#ifdef  _MSC_VER#pragma pack(pop)#endif  /* _MSC_VER */#endif /* _XSTRING *//* * Copyright (c) 1995-1998 by P.J. Plauger.  ALL RIGHTS RESERVED.  * Consult your license regarding permissions and restrictions. */

⌨️ 快捷键说明

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