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