17 #ifndef VCSN_MISC_CHAR_TRAITS_HXX
18 # define VCSN_MISC_CHAR_TRAITS_HXX
32 template <
class CharT>
33 generic_int_type<CharT>::generic_int_type () :
39 template <
class CharT>
40 generic_int_type<CharT>::generic_int_type (
const char_type& val) :
41 val_ (val), eof_ (false)
45 template <
class CharT>
46 generic_int_type<CharT>::operator CharT ()
const
51 template <
class CharT>
53 generic_int_type<CharT>::
54 operator== (
const generic_int_type<CharT>& rhs)
const
59 return not eof_ and (rhs.val_ == val_);
62 template <
class CharT>
64 generic_int_type<CharT>::eof ()
const
73 template <
typename CharT>
75 char_traits<CharT>::assign (char_type& lhs,
const char_type& rhs)
80 template <
typename CharT>
82 char_traits<CharT>::eq (
const char_type& lhs,
const char_type& rhs)
87 template <
typename CharT>
89 char_traits<CharT>::lt (
const char_type& lhs,
const char_type& rhs)
94 template <
typename CharT>
96 char_traits<CharT>::compare (
const char_type* p,
102 for (i = 0; (i < n) and eq (p[i], q[i]); ++i)
107 return lt (p[i], q[i]) ? -1 : 1;
110 template <
typename CharT>
112 char_traits<CharT>::length (
const char_type* p)
115 while (not eq (p[i], char_type ()))
120 template <
typename CharT>
121 const typename char_traits<CharT>::char_type*
122 char_traits<CharT>::find (
const char_type* p,
128 for (i = 0; (i < n) and not eq (p[i], c); ++i)
130 return i < n ? p + i: 0;
133 template <
typename CharT>
134 typename char_traits<CharT>::char_type*
135 char_traits<CharT>::move (char_type* s,
const char_type* p,
size_t n)
141 char_type* tmp =
new char_type[n];
148 template <
typename CharT>
149 typename char_traits<CharT>::char_type*
150 char_traits<CharT>::copy (char_type* s,
const char_type* p,
size_t n)
152 precondition ((p < s) or (p > s + n));
154 for (
size_t i = 0; i < n; ++i)
159 template <
typename CharT>
160 typename char_traits<CharT>::char_type*
161 char_traits<CharT>::assign (char_type* s,
size_t n, char_type c)
163 for (
size_t i = 0; i < n; ++i)
168 template <
typename CharT>
169 typename char_traits<CharT>::int_type
170 char_traits<CharT>::not_eof (
const int_type& e)
172 return eq_int_type (e, eof ()) ? int_type (char_type ()) : e;
175 template <
typename CharT>
176 typename char_traits<CharT>::char_type
177 char_traits<CharT>::to_char_type (
const int_type& e)
182 template <
typename CharT>
183 typename char_traits<CharT>::int_type
184 char_traits<CharT>::to_int_type (
const char_type& e)
189 template <
typename CharT>
191 char_traits<CharT>::eq_int_type (
const int_type& e,
const int_type& f)
196 template <
typename CharT>
197 typename char_traits<CharT>::int_type
198 char_traits<CharT>::eof ()
206 #endif // ! VCSN_MISC_CHAR_TRAITS_HXX