1 /*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18 #include "stlport_prefix.h"
19
20 #include <locale>
21 #include <algorithm>
22
23 _STLP_BEGIN_NAMESPACE
24
25 //----------------------------------------------------------------------
26 // codecvt<char, char, mbstate_t>
27
~codecvt()28 codecvt<char, char, mbstate_t>::~codecvt() {}
29
do_length(state_type &,const char * from,const char * end,size_t mx) const30 int codecvt<char, char, mbstate_t>::do_length(state_type&,
31 const char* from,
32 const char* end,
33 size_t mx) const
34 { return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
35
do_max_length() const36 int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
37 { return 1; }
38
39 bool
do_always_noconv() const40 codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
41 { return true; }
42
43 int
do_encoding() const44 codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
45 { return 1; }
46
47 codecvt_base::result
do_unshift(state_type &,char * __to,char *,char * & __to_next) const48 codecvt<char, char, mbstate_t>::do_unshift(state_type& /* __state */,
49 char* __to,
50 char* /* __to_limit */,
51 char*& __to_next) const
52 { __to_next = __to; return noconv; }
53
54 codecvt_base::result
do_in(state_type &,const char * __from,const char *,const char * & __from_next,char * __to,char *,char * & __to_next) const55 codecvt<char, char, mbstate_t>::do_in (state_type& /* __state */ ,
56 const char* __from,
57 const char* /* __from_end */,
58 const char*& __from_next,
59 char* __to,
60 char* /* __to_end */,
61 char*& __to_next) const
62 { __from_next = __from; __to_next = __to; return noconv; }
63
64 codecvt_base::result
do_out(state_type &,const char * __from,const char *,const char * & __from_next,char * __to,char *,char * & __to_next) const65 codecvt<char, char, mbstate_t>::do_out(state_type& /* __state */,
66 const char* __from,
67 const char* /* __from_end */,
68 const char*& __from_next,
69 char* __to,
70 char* /* __to_limit */,
71 char*& __to_next) const
72 { __from_next = __from; __to_next = __to; return noconv; }
73
74
75 #if !defined (_STLP_NO_WCHAR_T)
76 //----------------------------------------------------------------------
77 // codecvt<wchar_t, char, mbstate_t>
78
~codecvt()79 codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
80
81
82 codecvt<wchar_t, char, mbstate_t>::result
do_out(state_type &,const intern_type * from,const intern_type * from_end,const intern_type * & from_next,extern_type * to,extern_type * to_limit,extern_type * & to_next) const83 codecvt<wchar_t, char, mbstate_t>::do_out(state_type& /* state */,
84 const intern_type* from,
85 const intern_type* from_end,
86 const intern_type*& from_next,
87 extern_type* to,
88 extern_type* to_limit,
89 extern_type*& to_next) const {
90 ptrdiff_t len = (min) (from_end - from, to_limit - to);
91 copy(from, from + len, to);
92 from_next = from + len;
93 to_next = to + len;
94 return ok;
95 }
96
97 codecvt<wchar_t, char, mbstate_t>::result
do_in(state_type &,const extern_type * from,const extern_type * from_end,const extern_type * & from_next,intern_type * to,intern_type * to_limit,intern_type * & to_next) const98 codecvt<wchar_t, char, mbstate_t>::do_in (state_type& /* state */,
99 const extern_type* from,
100 const extern_type* from_end,
101 const extern_type*& from_next,
102 intern_type* to,
103 intern_type* to_limit,
104 intern_type*& to_next) const {
105 ptrdiff_t len = (min) (from_end - from, to_limit - to);
106 copy(__REINTERPRET_CAST(const unsigned char*, from),
107 __REINTERPRET_CAST(const unsigned char*, from) + len, to);
108 from_next = from + len;
109 to_next = to + len;
110 return ok;
111 }
112
113 codecvt<wchar_t, char, mbstate_t>::result
do_unshift(state_type &,extern_type * to,extern_type *,extern_type * & to_next) const114 codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& /* state */,
115 extern_type* to,
116 extern_type* ,
117 extern_type*& to_next) const {
118 to_next = to;
119 return noconv;
120 }
121
do_encoding() const122 int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
123 { return 1; }
124
do_always_noconv() const125 bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
126 { return true; }
127
do_length(state_type &,const extern_type * from,const extern_type * end,size_t mx) const128 int codecvt<wchar_t, char, mbstate_t>::do_length(state_type&,
129 const extern_type* from,
130 const extern_type* end,
131 size_t mx) const
132 { return (int)(min) ((size_t) (end - from), mx); }
133
do_max_length() const134 int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
135 { return 1; }
136 #endif /* wchar_t */
137
138 _STLP_END_NAMESPACE
139
140 // Local Variables:
141 // mode:C++
142 // End:
143
144