📄 _string.h
字号:
template <class _Integer> _Self& _M_replace_dispatch(iterator __first, iterator __last, _Integer __n, _Integer __x, const __true_type& /*IsIntegral*/) { _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) return replace(__first, __last, (size_type) __n, (_CharT) __x); } template <class _InputIter> _Self& _M_replace_dispatch(iterator __first, iterator __last, _InputIter __f, _InputIter __l, const __false_type& /*IsIntegral*/) { _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsIterator; typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator; typedef typename _Lor2<_IsIterator, _IsConstIterator>::_Ret _CheckInside; return _M_replace_aux(__first, __last, __f, __l, _CheckInside()); } template <class _RandomIter> _Self& _M_replace_aux(iterator __first, iterator __last, _RandomIter __f, _RandomIter __l, __true_type const& /*_CheckInside*/) { _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) return _M_replace(__first, __last, &(*__f), &(*__l), _M_inside(&(*__f))); } template <class _InputIter> _Self& _M_replace_aux(iterator __first, iterator __last, _InputIter __f, _InputIter __l, __false_type const& /*_CheckInside*/) { _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) return _M_replaceT(__first, __last, __f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); } template <class _InputIter> _Self& _M_replaceT(iterator __first, iterator __last, _InputIter __f, _InputIter __l, const input_iterator_tag&__ite_tag) { _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) for ( ; __first != __last && __f != __l; ++__first, ++__f) _Traits::assign(*__first, *__f); if (__f == __l) erase(__first, __last); else _M_insertT(__last, __f, __l, __ite_tag); return *this; } template <class _ForwardIter> _Self& _M_replaceT(iterator __first, iterator __last, _ForwardIter __f, _ForwardIter __l, const forward_iterator_tag &__ite_tag) { _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) difference_type __n = distance(__f, __l); const difference_type __len = __last - __first; if (__len >= __n) { _M_copyT(__f, __l, __first); erase(__first + __n, __last); } else { _ForwardIter __m = __f; advance(__m, __len); _M_copyT(__f, __m, __first); _M_insertT(__last, __m, __l, __ite_tag); } return *this; }public: // Check to see if _InputIter is an integer type. If so, then // it can't be an iterator. template <class _InputIter> _Self& replace(iterator __first, iterator __last, _InputIter __f, _InputIter __l) { _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) typedef typename _IsIntegral<_InputIter>::_Ret _Integral; return _M_replace_dispatch(__first, __last, __f, __l, _Integral()); }# endif#endif#if !defined (_STLP_MEMBER_TEMPLATES) || \ !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)# if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) _Self& replace(iterator __first, iterator __last, const _CharT* __f, const _CharT* __l) { _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) return _M_replace(__first, __last, __f, __l, _M_inside(__f)); }# endif#endifpublic: // Other modifier member functions. size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { _STLP_FIX_LITERAL_BUG(__s) if (__pos > size()) this->_M_throw_out_of_range(); const size_type __len = (min) (__n, size() - __pos); _Traits::copy(__s, this->_M_Start() + __pos, __len); return __len; } void swap(_Self& __s) { this->_M_Swap(__s); }public: // Conversion to C string. const _CharT* c_str() const { return this->_M_Start(); } const _CharT* data() const { return this->_M_Start(); }public: // find. size_type find(const _Self& __s, size_type __pos = 0) const { return find(__s._M_Start(), __pos, __s.size()); } size_type find(const _CharT* __s, size_type __pos = 0) const { _STLP_FIX_LITERAL_BUG(__s) return find(__s, __pos, _Traits::length(__s)); } size_type find(const _CharT* __s, size_type __pos, size_type __n) const; // WIE: Versant schema compiler 5.2.2 ICE workaround size_type find(_CharT __c) const { return find(__c, 0); } size_type find(_CharT __c, size_type __pos /* = 0 */) const;public: // rfind. size_type rfind(const _Self& __s, size_type __pos = npos) const { return rfind(__s._M_Start(), __pos, __s.size()); } size_type rfind(const _CharT* __s, size_type __pos = npos) const { _STLP_FIX_LITERAL_BUG(__s) return rfind(__s, __pos, _Traits::length(__s)); } size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const; size_type rfind(_CharT __c, size_type __pos = npos) const;public: // find_first_of size_type find_first_of(const _Self& __s, size_type __pos = 0) const { return find_first_of(__s._M_Start(), __pos, __s.size()); } size_type find_first_of(const _CharT* __s, size_type __pos = 0) const { _STLP_FIX_LITERAL_BUG(__s) return find_first_of(__s, __pos, _Traits::length(__s)); } size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_first_of(_CharT __c, size_type __pos = 0) const { return find(__c, __pos); }public: // find_last_of size_type find_last_of(const _Self& __s, size_type __pos = npos) const { return find_last_of(__s._M_Start(), __pos, __s.size()); } size_type find_last_of(const _CharT* __s, size_type __pos = npos) const { _STLP_FIX_LITERAL_BUG(__s) return find_last_of(__s, __pos, _Traits::length(__s)); } size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_last_of(_CharT __c, size_type __pos = npos) const { return rfind(__c, __pos); }public: // find_first_not_of size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const { return find_first_not_of(__s._M_Start(), __pos, __s.size()); } size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const { _STLP_FIX_LITERAL_BUG(__s) return find_first_not_of(__s, __pos, _Traits::length(__s)); } size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_first_not_of(_CharT __c, size_type __pos = 0) const;public: // find_last_not_of size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const { return find_last_not_of(__s._M_Start(), __pos, __s.size()); } size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const { _STLP_FIX_LITERAL_BUG(__s) return find_last_not_of(__s, __pos, _Traits::length(__s)); } size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_last_not_of(_CharT __c, size_type __pos = npos) const;public: // Substring. _Self substr(size_type __pos = 0, size_type __n = npos) const { return _Self(*this, __pos, __n, get_allocator()); }public: // Compare int compare(const _Self& __s) const { return _M_compare(this->_M_Start(), this->_M_Finish(), __s._M_Start(), __s._M_Finish()); } int compare(size_type __pos1, size_type __n1, const _Self& __s) const { if (__pos1 > size()) this->_M_throw_out_of_range(); return _M_compare(this->_M_Start() + __pos1, this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), __s._M_Start(), __s._M_Finish()); } int compare(size_type __pos1, size_type __n1, const _Self& __s, size_type __pos2, size_type __n2) const { if (__pos1 > size() || __pos2 > __s.size()) this->_M_throw_out_of_range(); return _M_compare(this->_M_Start() + __pos1, this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), __s._M_Start() + __pos2, __s._M_Start() + __pos2 + (min) (__n2, __s.size() - __pos2)); } int compare(const _CharT* __s) const { _STLP_FIX_LITERAL_BUG(__s) return _M_compare(this->_M_Start(), this->_M_Finish(), __s, __s + _Traits::length(__s)); } int compare(size_type __pos1, size_type __n1, const _CharT* __s) const { _STLP_FIX_LITERAL_BUG(__s) if (__pos1 > size()) this->_M_throw_out_of_range(); return _M_compare(this->_M_Start() + __pos1, this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), __s, __s + _Traits::length(__s)); } int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const { _STLP_FIX_LITERAL_BUG(__s) if (__pos1 > size()) this->_M_throw_out_of_range(); return _M_compare(this->_M_Start() + __pos1, this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), __s, __s + __n2); }public: // Helper functions for compare. static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1, const _CharT* __f2, const _CharT* __l2) { const ptrdiff_t __n1 = __l1 - __f1; const ptrdiff_t __n2 = __l2 - __f2; const int cmp = _Traits::compare(__f1, __f2, (min) (__n1, __n2)); return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0)); }#if defined (_STLP_USE_TEMPLATE_EXPRESSION) && !defined (_STLP_DEBUG) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)# define _STLP_STRING_SUM_BASE(__reserve, __size, __alloc) _STLP_PRIV _String_base<_CharT,_Alloc>(__alloc, __size + 1)# include <stl/_string_sum_methods.h># undef _STLP_STRING_SUM_BASE#endif /* _STLP_USE_TEMPLATE_EXPRESSION */};#if !defined (_STLP_STATIC_CONST_INIT_BUG)# if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)template <class _CharT, class _Traits, class _Alloc>const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;# endif#endif#if defined (_STLP_USE_TEMPLATE_EXPORT)_STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;# if defined (_STLP_HAS_WCHAR_T)_STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;# endif#endif /* _STLP_USE_TEMPLATE_EXPORT */#if defined (basic_string)_STLP_MOVE_TO_STD_NAMESPACE# undef basic_string#endif_STLP_END_NAMESPACE#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)# include <stl/_string_workaround.h>#endif#if defined (_STLP_DEBUG)# include <stl/debug/_string.h>#endif_STLP_BEGIN_NAMESPACE// ------------------------------------------------------------// Non-member functions.// Swap.#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)template <class _CharT, class _Traits, class _Alloc>inline void _STLP_CALLswap(basic_string<_CharT,_Traits,_Alloc>& __x, basic_string<_CharT,_Traits,_Alloc>& __y){ __x.swap(__y); }#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)template <class _CharT, class _Traits, class _Alloc>struct __move_traits<basic_string<_CharT, _Traits, _Alloc> > { typedef __stlp_movable implemented; //Completness depends on the allocator: typedef typename __move_traits<_Alloc>::complete complete;};/*#else * There is no need to specialize for string and wstring in this case * as the default __move_traits will already tell that string is movable * but not complete. We cannot define it as complete as nothing guaranty * that the STLport user hasn't specialized std::allocator for char or * wchar_t. */#endif_STLP_MOVE_TO_PRIV_NAMESPACEtemplate <class _CharT, class _Traits, class _Alloc>void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s, _CharT* __buf, size_t __n);#if defined(_STLP_USE_WIDE_INTERFACE)// A couple of functions to transfer between ASCII/Unicodewstring __ASCIIToWide(const char *ascii);string __WideToASCII(const wchar_t *wide);#endifinline const char* _STLP_CALL__get_c_string(const string& __str) { return __str.c_str(); }_STLP_MOVE_TO_STD_NAMESPACE_STLP_END_NAMESPACE#include <stl/_string_operators.h>#if defined(_STLP_USE_NO_IOSTREAMS) || \ (defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION))# include <stl/_string.c>#endif#endif /* _STLP_INTERNAL_STRING_H *//* * Local Variables: * mode:C++ * End: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -