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 
00036 #ifndef _VSTRING_UTIL_H
00037 #define _VSTRING_UTIL_H 1
00038 
00039 #pragma GCC system_header
00040 
00041 #include <ext/vstring_fwd.h>
00042 #include <debug/debug.h>
00043 #include <bits/stl_function.h>  
00044 #include <bits/functexcept.h>
00045 #include <locale>
00046 #include <algorithm> 
00047 
00048 namespace __gnu_cxx
00049 {
00050   template<typename _CharT, typename _Traits, typename _Alloc>
00051     struct __vstring_utility
00052     {
00053       typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
00054 
00055       typedef _Traits                       traits_type;      
00056       typedef typename _Traits::char_type           value_type;
00057       typedef typename _CharT_alloc_type::size_type     size_type;
00058       typedef typename _CharT_alloc_type::pointer       pointer;
00059       typedef typename _CharT_alloc_type::const_pointer     const_pointer;
00060 
00061       
00062       typedef __gnu_cxx::
00063       __normal_iterator<pointer, __gnu_cxx::
00064             __versa_string<_CharT, _Traits, _Alloc,
00065                        __sso_string_base> >
00066         __sso_iterator;
00067       typedef __gnu_cxx::
00068       __normal_iterator<const_pointer, __gnu_cxx::
00069             __versa_string<_CharT, _Traits, _Alloc,
00070                        __sso_string_base> >
00071         __const_sso_iterator;
00072 
00073       
00074       typedef __gnu_cxx::
00075       __normal_iterator<pointer, __gnu_cxx::
00076             __versa_string<_CharT, _Traits, _Alloc,
00077                        __rc_string_base> >
00078         __rc_iterator;
00079       typedef __gnu_cxx::
00080       __normal_iterator<const_pointer, __gnu_cxx::
00081             __versa_string<_CharT, _Traits, _Alloc,
00082                        __rc_string_base> >
00083         __const_rc_iterator;
00084 
00085       
00086       
00087       template<typename _Alloc1>
00088         struct _Alloc_hider
00089     : public _Alloc1
00090     {
00091       _Alloc_hider(const _Alloc1& __a, _CharT* __ptr)
00092       : _Alloc1(__a), _M_p(__ptr) { }
00093 
00094       _CharT*  _M_p; 
00095     };
00096 
00097       
00098       template<typename _Type>
00099         static bool
00100         _S_is_null_pointer(_Type* __ptr)
00101         { return __ptr == 0; }
00102 
00103       template<typename _Type>
00104         static bool
00105         _S_is_null_pointer(_Type)
00106         { return false; }
00107 
00108       
00109       
00110       static void
00111       _S_copy(_CharT* __d, const _CharT* __s, size_type __n)
00112       {
00113     if (__n == 1)
00114       traits_type::assign(*__d, *__s);
00115     else
00116       traits_type::copy(__d, __s, __n);
00117       }
00118 
00119       static void
00120       _S_move(_CharT* __d, const _CharT* __s, size_type __n)
00121       {
00122     if (__n == 1)
00123       traits_type::assign(*__d, *__s);
00124     else
00125       traits_type::move(__d, __s, __n);   
00126       }
00127 
00128       static void
00129       _S_assign(_CharT* __d, size_type __n, _CharT __c)
00130       {
00131     if (__n == 1)
00132       traits_type::assign(*__d, __c);
00133     else
00134       traits_type::assign(__d, __n, __c);     
00135       }
00136 
00137       
00138       
00139       template<typename _Iterator>
00140         static void
00141         _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
00142         {
00143       for (; __k1 != __k2; ++__k1, ++__p)
00144         traits_type::assign(*__p, *__k1); 
00145     }
00146 
00147       static void
00148       _S_copy_chars(_CharT* __p, __sso_iterator __k1, __sso_iterator __k2)
00149       { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00150 
00151       static void
00152       _S_copy_chars(_CharT* __p, __const_sso_iterator __k1,
00153             __const_sso_iterator __k2)
00154       { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00155 
00156       static void
00157       _S_copy_chars(_CharT* __p, __rc_iterator __k1, __rc_iterator __k2)
00158       { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00159 
00160       static void
00161       _S_copy_chars(_CharT* __p, __const_rc_iterator __k1,
00162             __const_rc_iterator __k2)
00163       { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00164 
00165       static void
00166       _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
00167       { _S_copy(__p, __k1, __k2 - __k1); }
00168 
00169       static void
00170       _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
00171       { _S_copy(__p, __k1, __k2 - __k1); }
00172     };
00173 } 
00174 
00175 namespace std
00176 {
00177   
00178   template<typename _Alloc, bool = std::__is_empty<_Alloc>::__value>
00179     struct __alloc_swap
00180     { static void _S_do_it(_Alloc&, _Alloc&) { } };
00181 
00182   template<typename _Alloc>
00183     struct __alloc_swap<_Alloc, false>
00184     {
00185       static void
00186       _S_do_it(_Alloc& __one, _Alloc& __two)
00187       {
00188     
00189     if (__one != __two)
00190       swap(__one, __two);
00191       }
00192     };
00193 }
00194 
00195 #endif