|
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 # ifndef _STLP_NO_MBSTATE_T |
|
21 |
|
22 #include <stl/_codecvt.h> |
|
23 #include <stl/_algobase.h> |
|
24 |
|
25 _STLP_BEGIN_NAMESPACE |
|
26 |
|
27 //---------------------------------------------------------------------- |
|
28 // codecvt<char, char, mbstate_t> |
|
29 |
|
30 _STLP_EXP_DECLSPEC codecvt<char, char, mbstate_t>::~codecvt() {} |
|
31 |
|
32 _STLP_EXP_DECLSPEC int codecvt<char, char, mbstate_t>::do_length(const mbstate_t&, |
|
33 const char* from, |
|
34 const char* end, |
|
35 size_t mx) const |
|
36 { |
|
37 return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); |
|
38 } |
|
39 |
|
40 _STLP_EXP_DECLSPEC int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW |
|
41 { |
|
42 return 1; |
|
43 } |
|
44 |
|
45 bool _STLP_EXP_DECLSPEC |
|
46 codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW |
|
47 { |
|
48 return true; |
|
49 } |
|
50 |
|
51 _STLP_EXP_DECLSPEC int |
|
52 codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW |
|
53 { |
|
54 return 1; |
|
55 } |
|
56 |
|
57 |
|
58 _STLP_EXP_DECLSPEC codecvt_base::result |
|
59 codecvt<char, char, mbstate_t>::do_unshift(mbstate_t& /* __state */, |
|
60 char* __to, |
|
61 char* /* __to_limit */, |
|
62 char*& __to_next) const |
|
63 { __to_next = __to; return noconv; } |
|
64 |
|
65 _STLP_EXP_DECLSPEC codecvt_base::result |
|
66 codecvt<char, char, mbstate_t>::do_in (mbstate_t& /* __state */ , |
|
67 const char* __from, |
|
68 const char* /* __from_end */, |
|
69 const char*& __from_next, |
|
70 char* __to, |
|
71 char* /* __to_end */, |
|
72 char*& __to_next) const |
|
73 { __from_next = __from; __to_next = __to; return noconv; } |
|
74 |
|
75 _STLP_EXP_DECLSPEC codecvt_base::result |
|
76 codecvt<char, char, mbstate_t>::do_out(mbstate_t& /* __state */, |
|
77 const char* __from, |
|
78 const char* /* __from_end */, |
|
79 const char*& __from_next, |
|
80 char* __to, |
|
81 char* /* __to_limit */, |
|
82 char*& __to_next) const |
|
83 { __from_next = __from; __to_next = __to; return noconv; } |
|
84 |
|
85 |
|
86 # ifndef _STLP_NO_WCHAR_T |
|
87 //---------------------------------------------------------------------- |
|
88 // codecvt<wchar_t, char, mbstate_t> |
|
89 |
|
90 _STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::~codecvt() {} |
|
91 |
|
92 |
|
93 _STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result |
|
94 codecvt<wchar_t, char, mbstate_t>::do_out(state_type& /* state */, |
|
95 const intern_type* from, |
|
96 const intern_type* from_end, |
|
97 const intern_type*& from_next, |
|
98 extern_type* to, |
|
99 extern_type* to_limit, |
|
100 extern_type*& to_next) const |
|
101 { |
|
102 ptrdiff_t len = (min) (from_end - from, to_limit - to); |
|
103 copy(from, from + len, to); |
|
104 from_next = from + len; |
|
105 to_next = to + len; |
|
106 return ok; |
|
107 } |
|
108 |
|
109 _STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result |
|
110 codecvt<wchar_t, char, mbstate_t>::do_in (state_type& /* state */, |
|
111 const extern_type* from, |
|
112 const extern_type* from_end, |
|
113 const extern_type*& from_next, |
|
114 intern_type* to, |
|
115 intern_type* to_limit, |
|
116 intern_type*& to_next) const |
|
117 { |
|
118 ptrdiff_t len = (min) (from_end - from, to_limit - to); |
|
119 copy(from, from + len, to); |
|
120 from_next = from + len; |
|
121 to_next = to + len; |
|
122 return ok; |
|
123 } |
|
124 |
|
125 _STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result |
|
126 codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& /* state */, |
|
127 extern_type* to, |
|
128 extern_type* , |
|
129 extern_type*& to_next) const |
|
130 { |
|
131 to_next = to; |
|
132 return noconv; |
|
133 } |
|
134 |
|
135 _STLP_EXP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW { |
|
136 //return 1; |
|
137 return 0;//don't know how many char required to make wchar_t, depends on locale |
|
138 } |
|
139 |
|
140 |
|
141 _STLP_EXP_DECLSPEC bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW |
|
142 { |
|
143 // return true; //gnu bug fix |
|
144 return false; |
|
145 } |
|
146 |
|
147 _STLP_EXP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_length(const state_type&, |
|
148 const extern_type* from, |
|
149 const extern_type* end, |
|
150 size_t mx) const |
|
151 { |
|
152 return (int)(min) ((size_t) (end - from), mx); |
|
153 } |
|
154 |
|
155 _STLP_EXP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW { |
|
156 return 1; |
|
157 } |
|
158 # endif /* wchar_t */ |
|
159 |
|
160 _STLP_END_NAMESPACE |
|
161 |
|
162 # endif /* _STLP_NO_MBSTATE_T */ |
|
163 |
|
164 // Local Variables: |
|
165 // mode:C++ |
|
166 // End: |
|
167 |