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