00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00034 #ifndef _VSTRING_H
00035 #define _VSTRING_H 1
00036
00037 #pragma GCC system_header
00038
00039 #include <ext/vstring_util.h>
00040 #include <ext/rc_string_base.h>
00041 #include <ext/sso_string_base.h>
00042
00043 namespace __gnu_cxx
00044 {
00050
00051 template<typename _CharT, typename _Traits, typename _Alloc,
00052 template <typename, typename, typename> class _Base>
00053 class __versa_string
00054 : private _Base<_CharT, _Traits, _Alloc>
00055 {
00056 typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
00057 typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
00058
00059
00060 public:
00061 typedef _Traits traits_type;
00062 typedef typename _Traits::char_type value_type;
00063 typedef _Alloc allocator_type;
00064 typedef typename _CharT_alloc_type::size_type size_type;
00065 typedef typename _CharT_alloc_type::difference_type difference_type;
00066 typedef typename _CharT_alloc_type::reference reference;
00067 typedef typename _CharT_alloc_type::const_reference const_reference;
00068 typedef typename _CharT_alloc_type::pointer pointer;
00069 typedef typename _CharT_alloc_type::const_pointer const_pointer;
00070 typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
00071 typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
00072 const_iterator;
00073 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00074 typedef std::reverse_iterator<iterator> reverse_iterator;
00075
00076
00077
00078
00080 static const size_type npos = static_cast<size_type>(-1);
00081
00082 private:
00083 size_type
00084 _M_check(size_type __pos, const char* __s) const
00085 {
00086 if (__pos > this->size())
00087 std::__throw_out_of_range(__N(__s));
00088 return __pos;
00089 }
00090
00091 void
00092 _M_check_length(size_type __n1, size_type __n2, const char* __s) const
00093 {
00094 if (this->max_size() - (this->size() - __n1) < __n2)
00095 std::__throw_length_error(__N(__s));
00096 }
00097
00098
00099 size_type
00100 _M_limit(size_type __pos, size_type __off) const
00101 {
00102 const bool __testoff = __off < this->size() - __pos;
00103 return __testoff ? __off : this->size() - __pos;
00104 }
00105
00106
00107 bool
00108 _M_disjunct(const _CharT* __s) const
00109 {
00110 return (std::less<const _CharT*>()(__s, this->_M_data())
00111 || std::less<const _CharT*>()(this->_M_data()
00112 + this->size(), __s));
00113 }
00114
00115
00116
00117 iterator
00118 _M_ibegin() const
00119 { return iterator(this->_M_data()); }
00120
00121 iterator
00122 _M_iend() const
00123 { return iterator(this->_M_data() + this->_M_length()); }
00124
00125 public:
00126
00127
00128
00129
00133 __versa_string()
00134 : __vstring_base() { }
00135
00139 explicit
00140 __versa_string(const _Alloc& __a)
00141 : __vstring_base(__a) { }
00142
00143
00148 __versa_string(const __versa_string& __str)
00149 : __vstring_base(__str) { }
00150
00157 __versa_string(const __versa_string& __str, size_type __pos,
00158 size_type __n = npos)
00159 : __vstring_base(__str._M_data()
00160 + __str._M_check(__pos,
00161 "__versa_string::__versa_string"),
00162 __str._M_data() + __str._M_limit(__pos, __n)
00163 + __pos, _Alloc()) { }
00164
00172 __versa_string(const __versa_string& __str, size_type __pos,
00173 size_type __n, const _Alloc& __a)
00174 : __vstring_base(__str._M_data()
00175 + __str._M_check(__pos,
00176 "__versa_string::__versa_string"),
00177 __str._M_data() + __str._M_limit(__pos, __n)
00178 + __pos, __a) { }
00179
00189 __versa_string(const _CharT* __s, size_type __n,
00190 const _Alloc& __a = _Alloc())
00191 : __vstring_base(__s, __s + __n, __a) { }
00192
00198 __versa_string(const _CharT* __s, const _Alloc& __a = _Alloc())
00199 : __vstring_base(__s, __s ? __s + traits_type::length(__s) :
00200 __s + npos, __a) { }
00201
00208 __versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
00209 : __vstring_base(__n, __c, __a) { }
00210
00217 template<class _InputIterator>
00218 __versa_string(_InputIterator __beg, _InputIterator __end,
00219 const _Alloc& __a = _Alloc())
00220 : __vstring_base(__beg, __end, __a) { }
00221
00225 ~__versa_string() { }
00226
00231 __versa_string&
00232 operator=(const __versa_string& __str)
00233 { return this->assign(__str); }
00234
00239 __versa_string&
00240 operator=(const _CharT* __s)
00241 { return this->assign(__s); }
00242
00250 __versa_string&
00251 operator=(_CharT __c)
00252 {
00253 this->assign(1, __c);
00254 return *this;
00255 }
00256
00257
00262 iterator
00263 begin()
00264 {
00265 this->_M_leak();
00266 return iterator(this->_M_data());
00267 }
00268
00273 const_iterator
00274 begin() const
00275 { return const_iterator(this->_M_data()); }
00276
00281 iterator
00282 end()
00283 {
00284 this->_M_leak();
00285 return iterator(this->_M_data() + this->size());
00286 }
00287
00292 const_iterator
00293 end() const
00294 { return const_iterator(this->_M_data() + this->size()); }
00295
00301 reverse_iterator
00302 rbegin()
00303 { return reverse_iterator(this->end()); }
00304
00310 const_reverse_iterator
00311 rbegin() const
00312 { return const_reverse_iterator(this->end()); }
00313
00319 reverse_iterator
00320 rend()
00321 { return reverse_iterator(this->begin()); }
00322
00328 const_reverse_iterator
00329 rend() const
00330 { return const_reverse_iterator(this->begin()); }
00331
00332 public:
00333
00336 size_type
00337 size() const
00338 { return this->_M_length(); }
00339
00342 size_type
00343 length() const
00344 { return this->_M_length(); }
00345
00347 size_type
00348 max_size() const
00349 { return this->_M_max_size(); }
00350
00361 void
00362 resize(size_type __n, _CharT __c);
00363
00374 void
00375 resize(size_type __n)
00376 { this->resize(__n, _CharT()); }
00377
00382 size_type
00383 capacity() const
00384 { return this->_M_capacity(); }
00385
00403 void
00404 reserve(size_type __res_arg = 0)
00405 { this->_M_reserve(__res_arg); }
00406
00410 void
00411 clear()
00412 { this->_M_clear(); }
00413
00417 bool
00418 empty() const
00419 { return this->size() == 0; }
00420
00421
00432 const_reference
00433 operator[] (size_type __pos) const
00434 {
00435 _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
00436 return this->_M_data()[__pos];
00437 }
00438
00449 reference
00450 operator[](size_type __pos)
00451 {
00452
00453 _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
00454
00455 _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size());
00456 this->_M_leak();
00457 return this->_M_data()[__pos];
00458 }
00459
00470 const_reference
00471 at(size_type __n) const
00472 {
00473 if (__n >= this->size())
00474 std::__throw_out_of_range(__N("__versa_string::at"));
00475 return this->_M_data()[__n];
00476 }
00477
00489 reference
00490 at(size_type __n)
00491 {
00492 if (__n >= this->size())
00493 std::__throw_out_of_range(__N("__versa_string::at"));
00494 this->_M_leak();
00495 return this->_M_data()[__n];
00496 }
00497
00498
00504 __versa_string&
00505 operator+=(const __versa_string& __str)
00506 { return this->append(__str); }
00507
00513 __versa_string&
00514 operator+=(const _CharT* __s)
00515 { return this->append(__s); }
00516
00522 __versa_string&
00523 operator+=(_CharT __c)
00524 {
00525 this->push_back(__c);
00526 return *this;
00527 }
00528
00534 __versa_string&
00535 append(const __versa_string& __str)
00536 { return _M_append(__str._M_data(), __str.size()); }
00537
00550 __versa_string&
00551 append(const __versa_string& __str, size_type __pos, size_type __n)
00552 { return _M_append(__str._M_data()
00553 + __str._M_check(__pos, "__versa_string::append"),
00554 __str._M_limit(__pos, __n)); }
00555
00562 __versa_string&
00563 append(const _CharT* __s, size_type __n)
00564 {
00565 __glibcxx_requires_string_len(__s, __n);
00566 _M_check_length(size_type(0), __n, "__versa_string::append");
00567 return _M_append(__s, __n);
00568 }
00569
00575 __versa_string&
00576 append(const _CharT* __s)
00577 {
00578 __glibcxx_requires_string(__s);
00579 const size_type __n = traits_type::length(__s);
00580 _M_check_length(size_type(0), __n, "__versa_string::append");
00581 return _M_append(__s, __n);
00582 }
00583
00592 __versa_string&
00593 append(size_type __n, _CharT __c)
00594 { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
00595
00604 template<class _InputIterator>
00605 __versa_string&
00606 append(_InputIterator __first, _InputIterator __last)
00607 { return this->replace(_M_iend(), _M_iend(), __first, __last); }
00608
00613 void
00614 push_back(_CharT __c)
00615 {
00616 const size_type __size = this->size();
00617 if (__size + 1 > this->capacity() || this->_M_is_shared())
00618 this->_M_mutate(__size, size_type(0), 0, size_type(1));
00619 traits_type::assign(this->_M_data()[__size], __c);
00620 this->_M_set_length(__size + 1);
00621 }
00622
00628 __versa_string&
00629 assign(const __versa_string& __str)
00630 {
00631 this->_M_assign(__str);
00632 return *this;
00633 }
00634
00647 __versa_string&
00648 assign(const __versa_string& __str, size_type __pos, size_type __n)
00649 { return _M_replace(size_type(0), this->size(), __str._M_data()
00650 + __str._M_check(__pos, "__versa_string::assign"),
00651 __str._M_limit(__pos, __n)); }
00652
00663 __versa_string&
00664 assign(const _CharT* __s, size_type __n)
00665 {
00666 __glibcxx_requires_string_len(__s, __n);
00667 return _M_replace(size_type(0), this->size(), __s, __n);
00668 }
00669
00679 __versa_string&
00680 assign(const _CharT* __s)
00681 {
00682 __glibcxx_requires_string(__s);
00683 return _M_replace(size_type(0), this->size(), __s,
00684 traits_type::length(__s));
00685 }
00686
00696 __versa_string&
00697 assign(size_type __n, _CharT __c)
00698 { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
00699
00708 template<class _InputIterator>
00709 __versa_string&
00710 assign(_InputIterator __first, _InputIterator __last)
00711 { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
00712
00725 void
00726 insert(iterator __p, size_type __n, _CharT __c)
00727 { this->replace(__p, __p, __n, __c); }
00728
00740 template<class _InputIterator>
00741 void
00742 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
00743 { this->replace(__p, __p, __beg, __end); }
00744
00756 __versa_string&
00757 insert(size_type __pos1, const __versa_string& __str)
00758 { return this->replace(__pos1, size_type(0),
00759 __str._M_data(), __str.size()); }
00760
00779 __versa_string&
00780 insert(size_type __pos1, const __versa_string& __str,
00781 size_type __pos2, size_type __n)
00782 { return this->replace(__pos1, size_type(0), __str._M_data()
00783 + __str._M_check(__pos2, "__versa_string::insert"),
00784 __str._M_limit(__pos2, __n)); }
00785
00802 __versa_string&
00803 insert(size_type __pos, const _CharT* __s, size_type __n)
00804 { return this->replace(__pos, size_type(0), __s, __n); }
00805
00821 __versa_string&
00822 insert(size_type __pos, const _CharT* __s)
00823 {
00824 __glibcxx_requires_string(__s);
00825 return this->replace(__pos, size_type(0), __s,
00826 traits_type::length(__s));
00827 }
00828
00845 __versa_string&
00846 insert(size_type __pos, size_type __n, _CharT __c)
00847 { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),
00848 size_type(0), __n, __c); }
00849
00862 iterator
00863 insert(iterator __p, _CharT __c)
00864 {
00865 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
00866 const size_type __pos = __p - _M_ibegin();
00867 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
00868 this->_M_set_leaked();
00869 return iterator(this->_M_data() + __pos);
00870 }
00871
00886 __versa_string&
00887 erase(size_type __pos = 0, size_type __n = npos)
00888 {
00889 this->_M_erase(_M_check(__pos, "__versa_string::erase"),
00890 _M_limit(__pos, __n));
00891 return *this;
00892 }
00893
00902 iterator
00903 erase(iterator __position)
00904 {
00905 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
00906 && __position < _M_iend());
00907 const size_type __pos = __position - _M_ibegin();
00908 this->_M_erase(__pos, size_type(1));
00909 this->_M_set_leaked();
00910 return iterator(this->_M_data() + __pos);
00911 }
00912
00922 iterator
00923 erase(iterator __first, iterator __last)
00924 {
00925 _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
00926 && __last <= _M_iend());
00927 const size_type __pos = __first - _M_ibegin();
00928 this->_M_erase(__pos, __last - __first);
00929 this->_M_set_leaked();
00930 return iterator(this->_M_data() + __pos);
00931 }
00932
00949 __versa_string&
00950 replace(size_type __pos, size_type __n, const __versa_string& __str)
00951 { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
00952
00971 __versa_string&
00972 replace(size_type __pos1, size_type __n1, const __versa_string& __str,
00973 size_type __pos2, size_type __n2)
00974 {
00975 return this->replace(__pos1, __n1, __str._M_data()
00976 + __str._M_check(__pos2,
00977 "__versa_string::replace"),
00978 __str._M_limit(__pos2, __n2));
00979 }
00980
00998 __versa_string&
00999 replace(size_type __pos, size_type __n1, const _CharT* __s,
01000 size_type __n2)
01001 {
01002 __glibcxx_requires_string_len(__s, __n2);
01003 return _M_replace(_M_check(__pos, "__versa_string::replace"),
01004 _M_limit(__pos, __n1), __s, __n2);
01005 }
01006
01022 __versa_string&
01023 replace(size_type __pos, size_type __n1, const _CharT* __s)
01024 {
01025 __glibcxx_requires_string(__s);
01026 return this->replace(__pos, __n1, __s, traits_type::length(__s));
01027 }
01028
01045 __versa_string&
01046 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
01047 { return _M_replace_aux(_M_check(__pos, "__versa_string::replace"),
01048 _M_limit(__pos, __n1), __n2, __c); }
01049
01063 __versa_string&
01064 replace(iterator __i1, iterator __i2, const __versa_string& __str)
01065 { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
01066
01081 __versa_string&
01082 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
01083 {
01084 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01085 && __i2 <= _M_iend());
01086 return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
01087 }
01088
01102 __versa_string&
01103 replace(iterator __i1, iterator __i2, const _CharT* __s)
01104 {
01105 __glibcxx_requires_string(__s);
01106 return this->replace(__i1, __i2, __s, traits_type::length(__s));
01107 }
01108
01123 __versa_string&
01124 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
01125 {
01126 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01127 && __i2 <= _M_iend());
01128 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
01129 }
01130
01145 template<class _InputIterator>
01146 __versa_string&
01147 replace(iterator __i1, iterator __i2,
01148 _InputIterator __k1, _InputIterator __k2)
01149 {
01150 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01151 && __i2 <= _M_iend());
01152 __glibcxx_requires_valid_range(__k1, __k2);
01153 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
01154 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
01155 }
01156
01157
01158
01159 __versa_string&
01160 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
01161 {
01162 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01163 && __i2 <= _M_iend());
01164 __glibcxx_requires_valid_range(__k1, __k2);
01165 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01166 __k1, __k2 - __k1);
01167 }
01168
01169 __versa_string&
01170 replace(iterator __i1, iterator __i2,
01171 const _CharT* __k1, const _CharT* __k2)
01172 {
01173 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01174 && __i2 <= _M_iend());
01175 __glibcxx_requires_valid_range(__k1, __k2);
01176 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01177 __k1, __k2 - __k1);
01178 }
01179
01180 __versa_string&
01181 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
01182 {
01183 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01184 && __i2 <= _M_iend());
01185 __glibcxx_requires_valid_range(__k1, __k2);
01186 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01187 __k1.base(), __k2 - __k1);
01188 }
01189
01190 __versa_string&
01191 replace(iterator __i1, iterator __i2,
01192 const_iterator __k1, const_iterator __k2)
01193 {
01194 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01195 && __i2 <= _M_iend());
01196 __glibcxx_requires_valid_range(__k1, __k2);
01197 return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01198 __k1.base(), __k2 - __k1);
01199 }
01200
01201 private:
01202 template<class _Integer>
01203 __versa_string&
01204 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
01205 _Integer __val, __true_type)
01206 { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
01207
01208 template<class _InputIterator>
01209 __versa_string&
01210 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
01211 _InputIterator __k2, __false_type);
01212
01213 __versa_string&
01214 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
01215 _CharT __c);
01216
01217 __versa_string&
01218 _M_replace(size_type __pos, size_type __len1, const _CharT* __s,
01219 const size_type __len2);
01220
01221 __versa_string&
01222 _M_append(const _CharT* __s, size_type __n);
01223
01224 public:
01225
01237 size_type
01238 copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
01239
01247 void
01248 swap(__versa_string& __s)
01249 { this->_M_swap(__s); }
01250
01251
01258 const _CharT*
01259 c_str() const
01260 { return this->_M_data(); }
01261
01268 const _CharT*
01269 data() const
01270 { return this->_M_data(); }
01271
01275 allocator_type
01276 get_allocator() const
01277 { return this->_M_get_allocator(); }
01278
01290 size_type
01291 find(const _CharT* __s, size_type __pos, size_type __n) const;
01292
01303 size_type
01304 find(const __versa_string& __str, size_type __pos = 0) const
01305 { return this->find(__str.data(), __pos, __str.size()); }
01306
01317 size_type
01318 find(const _CharT* __s, size_type __pos = 0) const
01319 {
01320 __glibcxx_requires_string(__s);
01321 return this->find(__s, __pos, traits_type::length(__s));
01322 }
01323
01334 size_type
01335 find(_CharT __c, size_type __pos = 0) const;
01336
01347 size_type
01348 rfind(const __versa_string& __str, size_type __pos = npos) const
01349 { return this->rfind(__str.data(), __pos, __str.size()); }
01350
01362 size_type
01363 rfind(const _CharT* __s, size_type __pos, size_type __n) const;
01364
01375 size_type
01376 rfind(const _CharT* __s, size_type __pos = npos) const
01377 {
01378 __glibcxx_requires_string(__s);
01379 return this->rfind(__s, __pos, traits_type::length(__s));
01380 }
01381
01392 size_type
01393 rfind(_CharT __c, size_type __pos = npos) const;
01394
01405 size_type
01406 find_first_of(const __versa_string& __str, size_type __pos = 0) const
01407 { return this->find_first_of(__str.data(), __pos, __str.size()); }
01408
01420 size_type
01421 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
01422
01433 size_type
01434 find_first_of(const _CharT* __s, size_type __pos = 0) const
01435 {
01436 __glibcxx_requires_string(__s);
01437 return this->find_first_of(__s, __pos, traits_type::length(__s));
01438 }
01439
01452 size_type
01453 find_first_of(_CharT __c, size_type __pos = 0) const
01454 { return this->find(__c, __pos); }
01455
01466 size_type
01467 find_last_of(const __versa_string& __str, size_type __pos = npos) const
01468 { return this->find_last_of(__str.data(), __pos, __str.size()); }
01469
01481 size_type
01482 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
01483
01494 size_type
01495 find_last_of(const _CharT* __s, size_type __pos = npos) const
01496 {
01497 __glibcxx_requires_string(__s);
01498 return this->find_last_of(__s, __pos, traits_type::length(__s));
01499 }
01500
01513 size_type
01514 find_last_of(_CharT __c, size_type __pos = npos) const
01515 { return this->rfind(__c, __pos); }
01516
01527 size_type
01528 find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
01529 { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
01530
01542 size_type
01543 find_first_not_of(const _CharT* __s, size_type __pos,
01544 size_type __n) const;
01545
01556 size_type
01557 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
01558 {
01559 __glibcxx_requires_string(__s);
01560 return this->find_first_not_of(__s, __pos, traits_type::length(__s));
01561 }
01562
01573 size_type
01574 find_first_not_of(_CharT __c, size_type __pos = 0) const;
01575
01586 size_type
01587 find_last_not_of(const __versa_string& __str,
01588 size_type __pos = npos) const
01589 { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
01590
01603 size_type
01604 find_last_not_of(const _CharT* __s, size_type __pos,
01605 size_type __n) const;
01616 size_type
01617 find_last_not_of(const _CharT* __s, size_type __pos = npos) const
01618 {
01619 __glibcxx_requires_string(__s);
01620 return this->find_last_not_of(__s, __pos, traits_type::length(__s));
01621 }
01622
01633 size_type
01634 find_last_not_of(_CharT __c, size_type __pos = npos) const;
01635
01648 __versa_string
01649 substr(size_type __pos = 0, size_type __n = npos) const
01650 {
01651 return __versa_string(*this, _M_check(__pos, "__versa_string::substr"),
01652 __n);
01653 }
01654
01668 int
01669 compare(const __versa_string& __str) const
01670 {
01671 if (this->_M_compare(__str))
01672 return 0;
01673
01674 const size_type __size = this->size();
01675 const size_type __osize = __str.size();
01676 const size_type __len = std::min(__size, __osize);
01677
01678 int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
01679 if (!__r)
01680 __r = __size - __osize;
01681 return __r;
01682 }
01683
01701 int
01702 compare(size_type __pos, size_type __n,
01703 const __versa_string& __str) const;
01704
01726 int
01727 compare(size_type __pos1, size_type __n1, const __versa_string& __str,
01728 size_type __pos2, size_type __n2) const;
01729
01744 int
01745 compare(const _CharT* __s) const;
01746
01747
01748
01767 int
01768 compare(size_type __pos, size_type __n1, const _CharT* __s) const;
01769
01792 int
01793 compare(size_type __pos, size_type __n1, const _CharT* __s,
01794 size_type __n2) const;
01795 };
01796
01797
01804 template<typename _CharT, typename _Traits, typename _Alloc,
01805 template <typename, typename, typename> class _Base>
01806 __versa_string<_CharT, _Traits, _Alloc, _Base>
01807 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01808 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
01809
01816 template<typename _CharT, typename _Traits, typename _Alloc,
01817 template <typename, typename, typename> class _Base>
01818 __versa_string<_CharT, _Traits, _Alloc, _Base>
01819 operator+(const _CharT* __lhs,
01820 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
01821
01828 template<typename _CharT, typename _Traits, typename _Alloc,
01829 template <typename, typename, typename> class _Base>
01830 __versa_string<_CharT, _Traits, _Alloc, _Base>
01831 operator+(_CharT __lhs,
01832 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
01833
01840 template<typename _CharT, typename _Traits, typename _Alloc,
01841 template <typename, typename, typename> class _Base>
01842 __versa_string<_CharT, _Traits, _Alloc, _Base>
01843 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01844 const _CharT* __rhs);
01845
01852 template<typename _CharT, typename _Traits, typename _Alloc,
01853 template <typename, typename, typename> class _Base>
01854 __versa_string<_CharT, _Traits, _Alloc, _Base>
01855 operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01856 _CharT __rhs);
01857
01858
01865 template<typename _CharT, typename _Traits, typename _Alloc,
01866 template <typename, typename, typename> class _Base>
01867 inline bool
01868 operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01869 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01870 { return __lhs.compare(__rhs) == 0; }
01871
01878 template<typename _CharT, typename _Traits, typename _Alloc,
01879 template <typename, typename, typename> class _Base>
01880 inline bool
01881 operator==(const _CharT* __lhs,
01882 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01883 { return __rhs.compare(__lhs) == 0; }
01884
01891 template<typename _CharT, typename _Traits, typename _Alloc,
01892 template <typename, typename, typename> class _Base>
01893 inline bool
01894 operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01895 const _CharT* __rhs)
01896 { return __lhs.compare(__rhs) == 0; }
01897
01898
01905 template<typename _CharT, typename _Traits, typename _Alloc,
01906 template <typename, typename, typename> class _Base>
01907 inline bool
01908 operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01909 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01910 { return __rhs.compare(__lhs) != 0; }
01911
01918 template<typename _CharT, typename _Traits, typename _Alloc,
01919 template <typename, typename, typename> class _Base>
01920 inline bool
01921 operator!=(const _CharT* __lhs,
01922 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01923 { return __rhs.compare(__lhs) != 0; }
01924
01931 template<typename _CharT, typename _Traits, typename _Alloc,
01932 template <typename, typename, typename> class _Base>
01933 inline bool
01934 operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01935 const _CharT* __rhs)
01936 { return __lhs.compare(__rhs) != 0; }
01937
01938
01945 template<typename _CharT, typename _Traits, typename _Alloc,
01946 template <typename, typename, typename> class _Base>
01947 inline bool
01948 operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01949 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01950 { return __lhs.compare(__rhs) < 0; }
01951
01958 template<typename _CharT, typename _Traits, typename _Alloc,
01959 template <typename, typename, typename> class _Base>
01960 inline bool
01961 operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01962 const _CharT* __rhs)
01963 { return __lhs.compare(__rhs) < 0; }
01964
01971 template<typename _CharT, typename _Traits, typename _Alloc,
01972 template <typename, typename, typename> class _Base>
01973 inline bool
01974 operator<(const _CharT* __lhs,
01975 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01976 { return __rhs.compare(__lhs) > 0; }
01977
01978
01985 template<typename _CharT, typename _Traits, typename _Alloc,
01986 template <typename, typename, typename> class _Base>
01987 inline bool
01988 operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01989 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01990 { return __lhs.compare(__rhs) > 0; }
01991
01998 template<typename _CharT, typename _Traits, typename _Alloc,
01999 template <typename, typename, typename> class _Base>
02000 inline bool
02001 operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02002 const _CharT* __rhs)
02003 { return __lhs.compare(__rhs) > 0; }
02004
02011 template<typename _CharT, typename _Traits, typename _Alloc,
02012 template <typename, typename, typename> class _Base>
02013 inline bool
02014 operator>(const _CharT* __lhs,
02015 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02016 { return __rhs.compare(__lhs) < 0; }
02017
02018
02025 template<typename _CharT, typename _Traits, typename _Alloc,
02026 template <typename, typename, typename> class _Base>
02027 inline bool
02028 operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02029 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02030 { return __lhs.compare(__rhs) <= 0; }
02031
02038 template<typename _CharT, typename _Traits, typename _Alloc,
02039 template <typename, typename, typename> class _Base>
02040 inline bool
02041 operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02042 const _CharT* __rhs)
02043 { return __lhs.compare(__rhs) <= 0; }
02044
02051 template<typename _CharT, typename _Traits, typename _Alloc,
02052 template <typename, typename, typename> class _Base>
02053 inline bool
02054 operator<=(const _CharT* __lhs,
02055 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02056 { return __rhs.compare(__lhs) >= 0; }
02057
02058
02065 template<typename _CharT, typename _Traits, typename _Alloc,
02066 template <typename, typename, typename> class _Base>
02067 inline bool
02068 operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02069 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02070 { return __lhs.compare(__rhs) >= 0; }
02071
02078 template<typename _CharT, typename _Traits, typename _Alloc,
02079 template <typename, typename, typename> class _Base>
02080 inline bool
02081 operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02082 const _CharT* __rhs)
02083 { return __lhs.compare(__rhs) >= 0; }
02084
02091 template<typename _CharT, typename _Traits, typename _Alloc,
02092 template <typename, typename, typename> class _Base>
02093 inline bool
02094 operator>=(const _CharT* __lhs,
02095 const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02096 { return __rhs.compare(__lhs) <= 0; }
02097
02105 template<typename _CharT, typename _Traits, typename _Alloc,
02106 template <typename, typename, typename> class _Base>
02107 inline void
02108 swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02109 __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02110 { __lhs.swap(__rhs); }
02111
02112 }
02113
02114 namespace std
02115 {
02127 template<typename _CharT, typename _Traits, typename _Alloc,
02128 template <typename, typename, typename> class _Base>
02129 basic_istream<_CharT, _Traits>&
02130 operator>>(basic_istream<_CharT, _Traits>& __is,
02131 __gnu_cxx::__versa_string<_CharT, _Traits,
02132 _Alloc, _Base>& __str);
02133
02143 template<typename _CharT, typename _Traits, typename _Alloc,
02144 template <typename, typename, typename> class _Base>
02145 basic_ostream<_CharT, _Traits>&
02146 operator<<(basic_ostream<_CharT, _Traits>& __os,
02147 const __gnu_cxx::__versa_string<_CharT, _Traits,
02148 _Alloc, _Base>& __str);
02149
02163 template<typename _CharT, typename _Traits, typename _Alloc,
02164 template <typename, typename, typename> class _Base>
02165 basic_istream<_CharT, _Traits>&
02166 getline(basic_istream<_CharT, _Traits>& __is,
02167 __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
02168 _CharT __delim);
02169
02182 template<typename _CharT, typename _Traits, typename _Alloc,
02183 template <typename, typename, typename> class _Base>
02184 inline basic_istream<_CharT, _Traits>&
02185 getline(basic_istream<_CharT, _Traits>& __is,
02186 __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str)
02187 { return getline(__is, __str, __is.widen('\n')); }
02188
02189 }
02190
02191 #ifndef _GLIBCXX_EXPORT_TEMPLATE
02192 # include "vstring.tcc"
02193 #endif
02194
02195 #endif