_string.h

00001 /*
00002  * Copyright (c) 1997-1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999 
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted 
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 
00019 #ifndef _STLP_DBG_STRING_H
00020 #define _STLP_DBG_STRING_H
00021 
00022 #include <stl/debug/_iterator.h>
00023 
00024 # define _STLP_DBG_STRING_BASE _Nondebug_string <_CharT, _Traits, _Alloc>
00025 
00026 _STLP_BEGIN_NAMESPACE
00027 
00028 # ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
00029 template <class _CharT,class _Traits, class _Alloc>
00030 inline _CharT*
00031 value_type(const  _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
00032 return (_CharT*)0;
00033 }
00034 template <class _CharT, class _Traits, class _Alloc>
00035 inline random_access_iterator_tag
00036 iterator_category(const  _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
00037   return random_access_iterator_tag();
00038 }
00039 # endif
00040 
00041 template <class _CharT, class _Traits, class _Alloc> 
00042 class basic_string : public _STLP_DBG_STRING_BASE {
00043 private:
00044   typedef _STLP_DBG_STRING_BASE _Base;
00045   typedef basic_string<_CharT, _Traits, _Alloc> _Self;
00046 protected:
00047   mutable __owned_list _M_iter_list;
00048 public:
00049   __IMPORT_CONTAINER_TYPEDEFS(_Base)
00050   typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
00051   typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
00052   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
00053 # ifdef _STLP_USE_NATIVE_STRING
00054   // this typedef is being used for conversions
00055   typedef _STLP_VENDOR_STD::basic_string<_CharT,_Traits, 
00056     _STLP_VENDOR_STD::allocator<_CharT> >  __std_string;
00057 # endif
00058 public:                         // Constructor, destructor, assignment.
00059   typedef typename _Base::_Reserve_t _Reserve_t;
00060 
00061   const _Base* _Get_base() const { return (const _Base*)this; }
00062   _Base* _Get_base() { return (_Base*)this; }
00063 
00064   basic_string() :_STLP_DBG_STRING_BASE(), _M_iter_list(_Get_base()) {}
00065   
00066   explicit basic_string(const allocator_type& __a): 
00067     _STLP_DBG_STRING_BASE(__a), _M_iter_list(_Get_base()) {}
00068 
00069   basic_string(_Reserve_t __r, size_t __n,
00070                const allocator_type& __a = allocator_type())
00071     : _STLP_DBG_STRING_BASE(__r, __n, __a), _M_iter_list(_Get_base()) {}
00072 
00073   basic_string(const _Self& __s): 
00074     _STLP_DBG_STRING_BASE(__s), _M_iter_list(_Get_base()) {}
00075 
00076   basic_string(const _Self& __s, size_type __pos, size_type __n = _Base::npos,
00077                const allocator_type& __a = allocator_type()):
00078     _STLP_DBG_STRING_BASE(__s, __pos, __n, __a), _M_iter_list(_Get_base()) {}
00079 
00080   basic_string(const _CharT* __s, size_type __n,
00081                     const allocator_type& __a = allocator_type()):
00082     _STLP_DBG_STRING_BASE(__s, __n, __a), _M_iter_list(_Get_base()) {}
00083 
00084   basic_string(const _CharT* __s,
00085                     const allocator_type& __a = allocator_type()):
00086     _STLP_DBG_STRING_BASE(__s, __a), _M_iter_list(_Get_base()) {}
00087 
00088   basic_string(size_type __n, _CharT __c,
00089                     const allocator_type& __a = allocator_type()):
00090     _STLP_DBG_STRING_BASE(__n, __c, __a), _M_iter_list(_Get_base()) {}
00091 
00092 #if defined (_STLP_MEMBER_TEMPLATES) && !(defined(__MRC__)||defined(__SC__))
00093 # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
00094   template <class _InputIterator>
00095   basic_string(_InputIterator __f, _InputIterator __l):
00096     _STLP_DBG_STRING_BASE(__f, __l), _M_iter_list(_Get_base()) {}
00097 #  endif
00098   template <class _InputIterator>
00099   basic_string(_InputIterator __f, _InputIterator __l,
00100                     const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL):
00101     _STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
00102 #else /* _STLP_MEMBER_TEMPLATES */
00103   basic_string(const_iterator __f, const_iterator __l, 
00104                     const allocator_type & __a = allocator_type()):
00105     _STLP_DBG_STRING_BASE(__f._M_iterator, __l._M_iterator, __a), 
00106      _M_iter_list(_Get_base()) {}
00107 
00108   basic_string(const _CharT* __f, const _CharT* __l,
00109                const allocator_type& __a = allocator_type()):
00110    _STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
00111 #endif
00112 
00113 # ifdef _STLP_USE_NATIVE_STRING
00114   // these conversion operations still needed for
00115   // strstream, etc.
00116   basic_string (const __std_string& __x)
00117     : _STLP_DBG_STRING_BASE(__x.begin(), __x.end()), _M_iter_list(_Get_base()) {}
00118   operator __std_string() const { return __std_string(this->data()); }
00119 # endif
00120 
00121   // constructor from non-debug version
00122   basic_string (const _Base& __x)
00123     : _STLP_DBG_STRING_BASE(__x), _M_iter_list(_Get_base()) {}
00124 
00125   _Self& operator=(const _Self& __s) {
00126     _Base::operator=(__s);
00127     return *this;
00128   }
00129 
00130   _Self& operator=(const _CharT* __s) { 
00131     _STLP_FIX_LITERAL_BUG(__s)
00132     _Base::operator=(__s);
00133     return *this;
00134   }
00135 
00136   _Self& operator=(_CharT __c) {
00137     _Base::operator=(__c);
00138     return *this;
00139   }
00140 
00141 public:                         // Iterators.
00142 
00143   iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
00144   const_iterator begin() const { return const_iterator(&_M_iter_list,this->_M_start); }
00145   iterator end() { return iterator(&_M_iter_list,this->_M_finish); }
00146   const_iterator end() const { return const_iterator(&_M_iter_list,this->_M_finish); }
00147   void _M_deallocate_block() {
00148     _M_iter_list._Invalidate_all();
00149     _Base::_M_deallocate_block();
00150   }
00151 
00152   reverse_iterator rbegin()             
00153     { return reverse_iterator(iterator(&_M_iter_list,this->_M_finish)); }
00154   reverse_iterator rend()               
00155     { return reverse_iterator(iterator(&_M_iter_list,this->_M_start)); }
00156   const_reverse_iterator rbegin() const 
00157     { return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_finish)); }
00158   const_reverse_iterator rend()   const 
00159     { return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_start)); }
00160 
00161 public:                         // Size, capacity, etc.
00162 
00163   void resize(size_type __n, _CharT __c) {
00164     _Base::resize(__n, __c);
00165   }
00166   void resize(size_type __n) { resize(__n, this->_M_null()); }
00167 
00168   void reserve(size_type __s= 0) {
00169     _Base::reserve(__s);
00170   }
00171 
00172   void clear() {
00173     _M_iter_list._Invalidate_all();
00174     _Base::clear();
00175   } 
00176 
00177 public:                         // Element access.
00178 
00179   const_reference operator[](size_type __n) const
00180     { return *(begin() + __n); }
00181   reference operator[](size_type __n)
00182     { return *(begin() + __n); }
00183 
00184   const_reference at(size_type __n) const {
00185     if (__n >= this->size())
00186       this->_M_throw_out_of_range();
00187     return *(begin() + __n);
00188   }
00189 
00190   reference at(size_type __n) {
00191     if (__n >= this->size())
00192       this->_M_throw_out_of_range();
00193     return *(begin() + __n);
00194   }
00195 
00196 public:                         // Append, operator+=, push_back.
00197 
00198   _Self& operator+=(const _Self& __s) { return append(__s); }
00199   _Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }
00200   _Self& operator+=(_CharT __c) { push_back(__c); return *this; }
00201 
00202   _Self& append(const _Self& __s) { return append(__s._M_start, __s._M_finish); }
00203 
00204   _Self& append(const _Self& __s,
00205                        size_type __pos, size_type __n)
00206   {
00207     _Base::append(__s, __pos, __n);
00208     return *this;
00209   }
00210 
00211   _Self& append(const _CharT* __s, size_type __n) 
00212     { _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s+__n); }
00213 
00214   _Self& append(const _CharT* __s) 
00215     { _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s + _Traits::length(__s)); }
00216 
00217   _Self& append(size_type __n, _CharT __c){
00218           _Base::append(__n, __c);
00219           return *this;
00220   }
00221 
00222 #ifdef _STLP_MEMBER_TEMPLATES
00223 
00224   // Check to see if _InputIterator is an integer type.  If so, then
00225   // it can't be an iterator.
00226   template <class _InputIter>
00227   _Self& append(_InputIter __first, _InputIter __last) {
00228     _Base::append(__first, __last);
00229     return *this;
00230   }
00231 
00232 #else /* _STLP_MEMBER_TEMPLATES */
00233 
00234   _Self& append(const _CharT* __first, const _CharT* __last) {
00235     _Base::append(__first, __last);
00236     return *this;
00237   }
00238 
00239   _Self& append(const_iterator __first, const_iterator __last) {
00240     _Base::append(__first._M_iterator, __last._M_iterator);
00241     return *this;
00242   }
00243 #endif /* _STLP_MEMBER_TEMPLATES */
00244 
00245   void push_back(_CharT __c) {
00246     _Base::push_back(__c);
00247   }
00248 
00249   void pop_back() {
00250     __invalidate_iterator(&_M_iter_list,end());
00251     _Base::pop_back();
00252   }
00253 
00254 
00255 public:                         // Assign
00256   
00257   _Self& assign(const _Self& __s) {
00258     _Base::assign(__s); 
00259     return *this; 
00260   }
00261 
00262   _Self& assign(const _Self& __s, 
00263                        size_type __pos, size_type __n) {
00264     _Base::assign(__s, __pos, __n);
00265     return *this;
00266   }
00267 
00268   _Self& assign(const _CharT* __s, size_type __n)
00269     { _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + __n); }
00270 
00271   _Self& assign(const _CharT* __s)
00272     { _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + _Traits::length(__s)); }
00273 
00274   _Self& assign(size_type __n, _CharT __c) {
00275     _Base::assign(__n, __c);
00276     return *this;    
00277   }
00278 
00279 #ifdef _STLP_MEMBER_TEMPLATES
00280   template <class _InputIter>
00281   inline _Self& assign(_InputIter __first, _InputIter __last) {
00282       _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
00283       __check_range(__first, __last);
00284       _Base::assign(__first, __last);
00285       return *this;    
00286   }
00287 #else
00288   _Self& assign(const _CharT* __f, const _CharT* __l) {
00289     _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
00290       __check_range(__f, __l);
00291       _Base::assign(__f, __l);
00292     return *this;
00293   }
00294   _Self& assign(const_iterator __f, const_iterator __l) {
00295 
00296       _Base::assign(__f._M_iterator, __l._M_iterator);
00297     return *this;
00298   }
00299 #endif  /* _STLP_MEMBER_TEMPLATES */
00300     
00301 public:                         // Insert
00302 
00303   _Self& insert(size_type __pos, const _Self& __s) {
00304     _Base::insert(__pos, __s);
00305     return *this;
00306   }
00307 
00308   _Self& insert(size_type __pos, const _Self& __s,
00309                        size_type __beg, size_type __n) {
00310     _Base::insert(__pos, __s, __beg, __n);
00311     return *this;
00312   }
00313 
00314   _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
00315     _STLP_FIX_LITERAL_BUG(__s)
00316     _Base::insert(__pos, __s, __n);
00317     return *this;
00318   }
00319 
00320   _Self& insert(size_type __pos, const _CharT* __s) {
00321     _STLP_FIX_LITERAL_BUG(__s)
00322     _Base::insert(__pos, __s);      
00323     return *this;
00324   }
00325     
00326   _Self& insert(size_type __pos, size_type __n, _CharT __c) {
00327     _Base::insert(__pos, __n, __c);
00328     return *this;
00329   }
00330 
00331   iterator insert(iterator __p, _CharT __c) {
00332     _STLP_FIX_LITERAL_BUG(__p)
00333     __check_if_owner(&_M_iter_list,__p);
00334     return iterator(&_M_iter_list,_Base::insert(__p._M_iterator, __c));
00335   }
00336 
00337   void insert(iterator __p, size_t __n, _CharT __c) {
00338     __check_if_owner(&_M_iter_list,__p);
00339     _Base::insert(__p._M_iterator, __n, __c);
00340   }
00341 
00342 #ifdef _STLP_MEMBER_TEMPLATES
00343   template <class _InputIter>
00344   void insert(iterator __p, _InputIter __first, _InputIter __last) {
00345     __check_if_owner(&_M_iter_list,__p);
00346     __check_range(__first,__last);
00347     _Base::insert(__p._M_iterator, __first, __last);
00348   }
00349 #else /* _STLP_MEMBER_TEMPLATES */
00350   void insert(iterator __p, const _CharT* __first, const _CharT* __last) {
00351     _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
00352     __check_if_owner(&_M_iter_list,__p);
00353     __check_range(__first,__last);
00354     _Base::insert(__p._M_iterator, __first, __last);
00355   }
00356   void insert(iterator __p, const_iterator __first, const_iterator __last) {
00357     __check_range(__first,__last);
00358     _Base::insert(__p._M_iterator, __first._M_iterator, __last._M_iterator); 
00359   }
00360 #endif /* _STLP_MEMBER_TEMPLATES */
00361 
00362 public:                         // Erase.
00363   _Self& erase(size_type __pos = 0, size_type __n = _Base::npos) {
00364     _Base::erase(__pos, __n);
00365     return *this;
00366   }  
00367   iterator erase(iterator __position) {
00368     __check_if_owner(&_M_iter_list, __position);
00369     __invalidate_iterator(&_M_iter_list,end());
00370     return iterator(&_M_iter_list, _Base::erase(__position._M_iterator));
00371   }
00372   iterator erase(iterator __first, iterator __last) {
00373     __check_range(__first, __last)&&__check_if_owner(&_M_iter_list,__first);
00374     if (__first != __last) {
00375       __invalidate_range(&_M_iter_list, __last, end());
00376     }
00377     return iterator(&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));   
00378   }
00379 
00380 public:                         // Substring.
00381   _Self substr(size_type __pos = 0, size_type __n = _Base::npos) const {
00382     if (__pos > this->size())
00383       this->_M_throw_out_of_range();
00384     return _Self(this->begin() + __pos, 
00385                  this->begin() + __pos + min(__n, this->size() - __pos),
00386                  allocator_type());
00387   }
00388 public:                         // Replace.  (Conceptually equivalent
00389                                 // to erase followed by insert.)
00390   _Self& replace(size_type __pos, size_type __n, 
00391                         const _Self& __s) {
00392     _Base::replace(__pos, __n, __s);
00393     return *this;
00394   }
00395 
00396   _Self& replace(size_type __pos1, size_type __n1,
00397                         const _Self& __s,
00398                         size_type __pos2, size_type __n2) {
00399     _Base::replace(__pos1, __n1, (const _Base&)__s, __pos2, __n2);
00400     return *this;
00401   }
00402 
00403   _Self& replace(size_type __pos, size_type __n1,
00404                         const _CharT* __s, size_type __n2) {    
00405     _STLP_FIX_LITERAL_BUG(__s)
00406     _Base::replace(__pos, __n1, __s, __n2);
00407     return *this;
00408   }
00409 
00410   _Self& replace(size_type __pos, size_type __n1,
00411                         const _CharT* __s) {
00412     _STLP_FIX_LITERAL_BUG(__s)
00413     _Base::replace(__pos, __n1, __s);
00414     return *this;
00415   }
00416 
00417   _Self& replace(size_type __pos, size_type __n1,
00418                         size_type __n2, _CharT __c) {
00419     _Base::replace(__pos, __n1, __n2, __c);
00420     return *this;
00421   }
00422 
00423   _Self& replace(iterator __first, iterator __last, 
00424                         const _Self& __s) { 
00425     __check_if_owner(&_M_iter_list,__first);
00426     __check_range(__first, __last);
00427     _Base::replace(__first._M_iterator, __last._M_iterator,__s);
00428     return *this;
00429   }
00430 
00431   _Self& replace(iterator __first, iterator __last,
00432                         const _CharT* __s, size_type __n) { 
00433     _STLP_FIX_LITERAL_BUG(__s)
00434     __check_if_owner(&_M_iter_list,__first);
00435     __check_range(__first, __last);
00436     _Base::replace(__first._M_iterator, __last._M_iterator,__s, __n);
00437     return *this;
00438   }
00439 
00440   _Self& replace(iterator __first, iterator __last,
00441                         const _CharT* __s) {
00442     _STLP_FIX_LITERAL_BUG(__s)
00443     __check_if_owner(&_M_iter_list,__first);
00444     __check_range(__first, __last);
00445     _Base::replace(__first._M_iterator, __last._M_iterator,__s);
00446     return *this;
00447   }
00448 
00449   _Self& replace(iterator __first, iterator __last, 
00450                  size_type __n, _CharT __c) {
00451     __check_if_owner(&_M_iter_list,__first);
00452     __check_range(__first, __last);
00453     _Base::replace(__first._M_iterator, __last._M_iterator, __n, __c);
00454     return *this;
00455   }
00456 
00457 #ifdef _STLP_MEMBER_TEMPLATES
00458   template <class _InputIter>
00459   _Self& replace(iterator __first, iterator __last,
00460                         _InputIter __f, _InputIter __l) {
00461     __check_if_owner(&_M_iter_list, __first);
00462     __check_range(__first, __last);
00463     __check_range(__f, __l);
00464     _Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
00465     return *this;    
00466   }
00467 #else /* _STLP_MEMBER_TEMPLATES */
00468   _Self& replace(iterator __first, iterator __last,
00469                  const _CharT* __f, const _CharT* __l) {
00470     __check_if_owner(&_M_iter_list, __first);
00471     __check_range(__first, __last);
00472     __check_range(__f, __l);
00473     _Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
00474     return *this;    
00475   }
00476  
00477   _Self& replace(iterator __first, iterator __last,
00478                  const_iterator __f, const_iterator __l) {
00479     __check_if_owner(&_M_iter_list, __first);
00480     __check_range(__first, __last);
00481     __check_range(__f, __l);
00482     _Base::replace(__first._M_iterator, __last._M_iterator, 
00483                    __f._M_iterator, __l._M_iterator);
00484     return *this; 
00485   } 
00486 #endif /* _STLP_MEMBER_TEMPLATES */
00487 
00488 public:                         // Other modifier member functions.
00489 
00490   void swap(_Self& __s) {
00491     _M_iter_list._Swap_owners(__s._M_iter_list);
00492     _Base::swap(__s);
00493   }
00494 };
00495 
00496 
00497 // This is a hook to instantiate STLport exports in a designated DLL
00498 # if defined (_STLP_USE_TEMPLATE_EXPORT)
00499 _STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<char, char_traits<char>, allocator<char> >;
00500 #  if defined (_STLP_HAS_WCHAR_T)
00501 _STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
00502 #  endif
00503 # endif /* _STLP_USE_TEMPLATE_EXPORT */
00504 
00505 
00506 // ------------------------------------------------------------
00507 // Non-member functions.
00508 
00509 template <class _CharT, class _Traits, class _Alloc>
00510 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
00511 operator+(const basic_string<_CharT,_Traits,_Alloc>& __s,
00512           const basic_string<_CharT,_Traits,_Alloc>& __y)
00513 {
00514   return basic_string<_CharT,_Traits,_Alloc>(*__s._Get_base() + *__y._Get_base());
00515 }
00516 
00517 template <class _CharT, class _Traits, class _Alloc>
00518 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
00519 operator+(const _CharT* __s,
00520           const basic_string<_CharT,_Traits,_Alloc>& __y) {
00521   _STLP_FIX_LITERAL_BUG(__s)
00522   return basic_string<_CharT,_Traits,_Alloc>(__s + *__y._Get_base());
00523 }
00524 
00525 template <class _CharT, class _Traits, class _Alloc>
00526 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
00527 operator+(_CharT __c,
00528           const basic_string<_CharT,_Traits,_Alloc>& __y) {
00529   return basic_string<_CharT,_Traits,_Alloc>(__c + *__y._Get_base());
00530 }
00531 
00532 template <class _CharT, class _Traits, class _Alloc>
00533 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
00534 operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
00535           const _CharT* __s) {
00536   _STLP_FIX_LITERAL_BUG(__s)
00537   return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base()+ __s);
00538 }
00539 
00540 template <class _CharT, class _Traits, class _Alloc>
00541 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
00542 operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
00543           const _CharT __c) {
00544   return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base() + __c);
00545 }
00546 
00547 #ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
00548 
00549 // Operator== and operator!=
00550 
00551 template <class _CharT, class _Traits, class _Alloc>
00552 inline bool _STLP_CALL
00553 operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
00554            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00555   return (*__x._Get_base() == *__y._Get_base());
00556 }
00557 
00558 template <class _CharT, class _Traits, class _Alloc>
00559 inline bool _STLP_CALL
00560 operator==(const _CharT* __s,
00561            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00562   _STLP_FIX_LITERAL_BUG(__s)
00563   return (__s == *__y._Get_base());
00564 }
00565 
00566 template <class _CharT, class _Traits, class _Alloc>
00567 inline bool _STLP_CALL
00568 operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
00569            const _CharT* __s) {
00570   _STLP_FIX_LITERAL_BUG(__s)
00571   return (*__x._Get_base() == __s);
00572 }
00573 
00574 // Operator< (and also >, <=, and >=).
00575 
00576 template <class _CharT, class _Traits, class _Alloc>
00577 inline bool _STLP_CALL
00578 operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
00579           const basic_string<_CharT,_Traits,_Alloc>& __y) {
00580   return (*__x._Get_base() < *__y._Get_base());
00581 }
00582 
00583 template <class _CharT, class _Traits, class _Alloc>
00584 inline bool _STLP_CALL
00585 operator<(const _CharT* __s,
00586           const basic_string<_CharT,_Traits,_Alloc>& __y) {
00587   _STLP_FIX_LITERAL_BUG(__s)
00588   return (__s < *__y._Get_base());    
00589 }
00590 
00591 template <class _CharT, class _Traits, class _Alloc>
00592 inline bool _STLP_CALL
00593 operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
00594           const _CharT* __s) {
00595   _STLP_FIX_LITERAL_BUG(__s)
00596   return (*__x._Get_base() < __s);
00597 }
00598 
00599 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
00600 
00601 template <class _CharT, class _Traits, class _Alloc>
00602 inline bool _STLP_CALL
00603 operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
00604            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00605   return !(__x == __y);
00606 }
00607 
00608 template <class _CharT, class _Traits, class _Alloc>
00609 inline bool _STLP_CALL
00610 operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
00611           const basic_string<_CharT,_Traits,_Alloc>& __y) {
00612   return __y < __x;
00613 }
00614 
00615 template <class _CharT, class _Traits, class _Alloc>
00616 inline bool _STLP_CALL
00617 operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
00618            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00619   return !(__y < __x);
00620 }
00621 
00622 template <class _CharT, class _Traits, class _Alloc>
00623 inline bool _STLP_CALL
00624 operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
00625            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00626   return !(__x < __y);
00627 }
00628 
00629 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
00630 
00631 template <class _CharT, class _Traits, class _Alloc>
00632 inline bool _STLP_CALL
00633 operator!=(const _CharT* __s,
00634            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00635   _STLP_FIX_LITERAL_BUG(__s)
00636   return !(__s == __y);
00637 }
00638 
00639 template <class _CharT, class _Traits, class _Alloc>
00640 inline bool _STLP_CALL
00641 operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
00642            const _CharT* __s) {
00643   _STLP_FIX_LITERAL_BUG(__s)
00644   return !(__x == __s);
00645 }
00646 
00647 template <class _CharT, class _Traits, class _Alloc>
00648 inline bool _STLP_CALL
00649 operator>(const _CharT* __s,
00650           const basic_string<_CharT,_Traits,_Alloc>& __y) {
00651   _STLP_FIX_LITERAL_BUG(__s)
00652   return __y < __s;
00653 }
00654 
00655 template <class _CharT, class _Traits, class _Alloc>
00656 inline bool _STLP_CALL
00657 operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
00658           const _CharT* __s) {
00659   _STLP_FIX_LITERAL_BUG(__s)
00660   return __s < __x;
00661 }
00662 
00663 template <class _CharT, class _Traits, class _Alloc>
00664 inline bool _STLP_CALL
00665 operator<=(const _CharT* __s,
00666            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00667   _STLP_FIX_LITERAL_BUG(__s)
00668   return !(__y < __s);
00669 }
00670 
00671 template <class _CharT, class _Traits, class _Alloc>
00672 inline bool _STLP_CALL
00673 operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
00674            const _CharT* __s) {
00675   _STLP_FIX_LITERAL_BUG(__s)
00676   return !(__s < __x);
00677 }
00678 
00679 template <class _CharT, class _Traits, class _Alloc>
00680 inline bool _STLP_CALL
00681 operator>=(const _CharT* __s,
00682            const basic_string<_CharT,_Traits,_Alloc>& __y) {
00683   _STLP_FIX_LITERAL_BUG(__s)
00684   return !(__s < __y);
00685 }
00686 
00687 template <class _CharT, class _Traits, class _Alloc>
00688 inline bool _STLP_CALL
00689 operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
00690            const _CharT* __s) {
00691   _STLP_FIX_LITERAL_BUG(__s)
00692   return !(__x < __s);
00693 }
00694 #endif /*  if 0 */
00695 
00696 // Swap.
00697 #ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
00698 template <class _CharT, class _Traits, class _Alloc>
00699 inline void swap(basic_string<_CharT,_Traits,_Alloc>& __x,
00700                  basic_string<_CharT,_Traits,_Alloc>& __y) {
00701   __x.swap(__y);
00702 }
00703 #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
00704 
00705 // I/O.  
00706 
00707 #ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
00708 #if defined (_STLP_USE_NEW_IOSTREAMS) && ! defined (_STLP_OWN_IOSTREAMS)
00709 
00710 template <class _CharT, class _Traits, class _Alloc>
00711 basic_ostream<_CharT, _Traits>& _STLP_CALL
00712 operator<<(basic_ostream<_CharT, _Traits>& __os, 
00713            const basic_string<_CharT,_Traits,_Alloc>& __s) {
00714   return __os << *__s._Get_base();
00715 }
00716 
00717 template <class _CharT, class _Traits, class _Alloc>
00718 basic_istream<_CharT, _Traits>&  _STLP_CALL
00719 operator>>(basic_istream<_CharT, _Traits>& __is,
00720            basic_string<_CharT,_Traits,_Alloc>& __s) {
00721     return __is >> *__s._Get_base();
00722 }
00723 
00724 #elif ! defined ( _STLP_USE_NO_IOSTREAMS )
00725 
00726 template <class _CharT, class _Traits, class _Alloc>
00727 ostream& _STLP_CALL operator<<(ostream& __os, 
00728                     const basic_string<_CharT,_Traits,_Alloc>& __s) {
00729   return __os << *__s._Get_base();
00730 }
00731 
00732 template <class _CharT, class _Traits, class _Alloc>
00733 istream& _STLP_CALL operator>>(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s) {
00734     return __is >> *__s._Get_base();
00735 }
00736 
00737 #endif /* _STLP_USE_NEW_IOSTREAMS */
00738 #endif /* if _STLP_EXTRA_OPERATORS_FOR_DEBUG */
00739 
00740 
00741 _STLP_END_NAMESPACE
00742 
00743 #endif /* _STLP_DBG_STRING */
00744 
00745 
00746 // Local Variables:
00747 // mode:C++
00748 // End:
00749 

Generated on Mon Jun 5 10:20:47 2006 for Intelligence.kdevelop by  doxygen 1.4.6