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