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
00030
00031
00032
00033
00034
00035
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 <bits/localefwd.h>
00046 #include <bits/ostream_insert.h>
00047 #include <bits/stl_iterator.h>
00048 #include <ext/numeric_traits.h>
00049 #include <bits/stl_move.h>
00050
00051 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00052
00053 template<typename _CharT, typename _Traits, typename _Alloc>
00054 struct __vstring_utility
00055 {
00056 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
00057
00058 typedef _Traits traits_type;
00059 typedef typename _Traits::char_type value_type;
00060 typedef typename _CharT_alloc_type::size_type size_type;
00061 typedef typename _CharT_alloc_type::difference_type difference_type;
00062 typedef typename _CharT_alloc_type::pointer pointer;
00063 typedef typename _CharT_alloc_type::const_pointer const_pointer;
00064
00065
00066 typedef __gnu_cxx::
00067 __normal_iterator<pointer, __gnu_cxx::
00068 __versa_string<_CharT, _Traits, _Alloc,
00069 __sso_string_base> >
00070 __sso_iterator;
00071 typedef __gnu_cxx::
00072 __normal_iterator<const_pointer, __gnu_cxx::
00073 __versa_string<_CharT, _Traits, _Alloc,
00074 __sso_string_base> >
00075 __const_sso_iterator;
00076
00077
00078 typedef __gnu_cxx::
00079 __normal_iterator<pointer, __gnu_cxx::
00080 __versa_string<_CharT, _Traits, _Alloc,
00081 __rc_string_base> >
00082 __rc_iterator;
00083 typedef __gnu_cxx::
00084 __normal_iterator<const_pointer, __gnu_cxx::
00085 __versa_string<_CharT, _Traits, _Alloc,
00086 __rc_string_base> >
00087 __const_rc_iterator;
00088
00089
00090
00091 template<typename _Alloc1>
00092 struct _Alloc_hider
00093 : public _Alloc1
00094 {
00095 _Alloc_hider(_CharT* __ptr)
00096 : _Alloc1(), _M_p(__ptr) { }
00097
00098 _Alloc_hider(const _Alloc1& __a, _CharT* __ptr)
00099 : _Alloc1(__a), _M_p(__ptr) { }
00100
00101 _CharT* _M_p;
00102 };
00103
00104
00105
00106 static void
00107 _S_copy(_CharT* __d, const _CharT* __s, size_type __n)
00108 {
00109 if (__n == 1)
00110 traits_type::assign(*__d, *__s);
00111 else
00112 traits_type::copy(__d, __s, __n);
00113 }
00114
00115 static void
00116 _S_move(_CharT* __d, const _CharT* __s, size_type __n)
00117 {
00118 if (__n == 1)
00119 traits_type::assign(*__d, *__s);
00120 else
00121 traits_type::move(__d, __s, __n);
00122 }
00123
00124 static void
00125 _S_assign(_CharT* __d, size_type __n, _CharT __c)
00126 {
00127 if (__n == 1)
00128 traits_type::assign(*__d, __c);
00129 else
00130 traits_type::assign(__d, __n, __c);
00131 }
00132
00133
00134
00135 template<typename _Iterator>
00136 static void
00137 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
00138 {
00139 for (; __k1 != __k2; ++__k1, ++__p)
00140 traits_type::assign(*__p, *__k1);
00141 }
00142
00143 static void
00144 _S_copy_chars(_CharT* __p, __sso_iterator __k1, __sso_iterator __k2)
00145 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00146
00147 static void
00148 _S_copy_chars(_CharT* __p, __const_sso_iterator __k1,
00149 __const_sso_iterator __k2)
00150 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00151
00152 static void
00153 _S_copy_chars(_CharT* __p, __rc_iterator __k1, __rc_iterator __k2)
00154 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00155
00156 static void
00157 _S_copy_chars(_CharT* __p, __const_rc_iterator __k1,
00158 __const_rc_iterator __k2)
00159 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
00160
00161 static void
00162 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
00163 { _S_copy(__p, __k1, __k2 - __k1); }
00164
00165 static void
00166 _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
00167 { _S_copy(__p, __k1, __k2 - __k1); }
00168
00169 static int
00170 _S_compare(size_type __n1, size_type __n2)
00171 {
00172 const difference_type __d = difference_type(__n1 - __n2);
00173
00174 if (__d > __numeric_traits_integer<int>::__max)
00175 return __numeric_traits_integer<int>::__max;
00176 else if (__d < __numeric_traits_integer<int>::__min)
00177 return __numeric_traits_integer<int>::__min;
00178 else
00179 return int(__d);
00180 }
00181 };
00182
00183 _GLIBCXX_END_NAMESPACE
00184
00185 #endif