xref: /openbsd-src/gnu/gcc/libstdc++-v3/include/bits/codecvt.h (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert // Locale support (codecvt) -*- C++ -*-
2*404b540aSrobert 
3*404b540aSrobert // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
4*404b540aSrobert //  Free Software Foundation, Inc.
5*404b540aSrobert //
6*404b540aSrobert // This file is part of the GNU ISO C++ Library.  This library is free
7*404b540aSrobert // software; you can redistribute it and/or modify it under the
8*404b540aSrobert // terms of the GNU General Public License as published by the
9*404b540aSrobert // Free Software Foundation; either version 2, or (at your option)
10*404b540aSrobert // any later version.
11*404b540aSrobert 
12*404b540aSrobert // This library is distributed in the hope that it will be useful,
13*404b540aSrobert // but WITHOUT ANY WARRANTY; without even the implied warranty of
14*404b540aSrobert // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*404b540aSrobert // GNU General Public License for more details.
16*404b540aSrobert 
17*404b540aSrobert // You should have received a copy of the GNU General Public License along
18*404b540aSrobert // with this library; see the file COPYING.  If not, write to the Free
19*404b540aSrobert // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20*404b540aSrobert // USA.
21*404b540aSrobert 
22*404b540aSrobert // As a special exception, you may use this file as part of a free software
23*404b540aSrobert // library without restriction.  Specifically, if other files instantiate
24*404b540aSrobert // templates or use macros or inline functions from this file, or you compile
25*404b540aSrobert // this file and link it with other files to produce an executable, this
26*404b540aSrobert // file does not by itself cause the resulting executable to be covered by
27*404b540aSrobert // the GNU General Public License.  This exception does not however
28*404b540aSrobert // invalidate any other reasons why the executable file might be covered by
29*404b540aSrobert // the GNU General Public License.
30*404b540aSrobert 
31*404b540aSrobert /** @file bits/codecvt.h
32*404b540aSrobert  *  This is an internal header file, included by other library headers.
33*404b540aSrobert  *  You should not attempt to use it directly.
34*404b540aSrobert  */
35*404b540aSrobert 
36*404b540aSrobert //
37*404b540aSrobert // ISO C++ 14882: 22.2.1.5 Template class codecvt
38*404b540aSrobert //
39*404b540aSrobert 
40*404b540aSrobert // Written by Benjamin Kosnik <bkoz@redhat.com>
41*404b540aSrobert 
42*404b540aSrobert #ifndef _CODECVT_H
43*404b540aSrobert #define _CODECVT_H 1
44*404b540aSrobert 
45*404b540aSrobert #pragma GCC system_header
46*404b540aSrobert 
_GLIBCXX_BEGIN_NAMESPACE(std)47*404b540aSrobert _GLIBCXX_BEGIN_NAMESPACE(std)
48*404b540aSrobert 
49*404b540aSrobert   /// @brief  Empty base class for codecvt facet [22.2.1.5].
50*404b540aSrobert   class codecvt_base
51*404b540aSrobert   {
52*404b540aSrobert   public:
53*404b540aSrobert     enum result
54*404b540aSrobert     {
55*404b540aSrobert       ok,
56*404b540aSrobert       partial,
57*404b540aSrobert       error,
58*404b540aSrobert       noconv
59*404b540aSrobert     };
60*404b540aSrobert   };
61*404b540aSrobert 
62*404b540aSrobert   /**
63*404b540aSrobert    *  @brief  Common base for codecvt functions.
64*404b540aSrobert    *
65*404b540aSrobert    *  This template class provides implementations of the public functions
66*404b540aSrobert    *  that forward to the protected virtual functions.
67*404b540aSrobert    *
68*404b540aSrobert    *  This template also provides abstract stubs for the protected virtual
69*404b540aSrobert    *  functions.
70*404b540aSrobert   */
71*404b540aSrobert   template<typename _InternT, typename _ExternT, typename _StateT>
72*404b540aSrobert     class __codecvt_abstract_base
73*404b540aSrobert     : public locale::facet, public codecvt_base
74*404b540aSrobert     {
75*404b540aSrobert     public:
76*404b540aSrobert       // Types:
77*404b540aSrobert       typedef codecvt_base::result	result;
78*404b540aSrobert       typedef _InternT			intern_type;
79*404b540aSrobert       typedef _ExternT			extern_type;
80*404b540aSrobert       typedef _StateT			state_type;
81*404b540aSrobert 
82*404b540aSrobert       // 22.2.1.5.1 codecvt members
83*404b540aSrobert       /**
84*404b540aSrobert        *  @brief  Convert from internal to external character set.
85*404b540aSrobert        *
86*404b540aSrobert        *  Converts input string of intern_type to output string of
87*404b540aSrobert        *  extern_type.  This is analogous to wcsrtombs.  It does this by
88*404b540aSrobert        *  calling codecvt::do_out.
89*404b540aSrobert        *
90*404b540aSrobert        *  The source and destination character sets are determined by the
91*404b540aSrobert        *  facet's locale, internal and external types.
92*404b540aSrobert        *
93*404b540aSrobert        *  The characters in [from,from_end) are converted and written to
94*404b540aSrobert        *  [to,to_end).  from_next and to_next are set to point to the
95*404b540aSrobert        *  character following the last successfully converted character,
96*404b540aSrobert        *  respectively.  If the result needed no conversion, from_next and
97*404b540aSrobert        *  to_next are not affected.
98*404b540aSrobert        *
99*404b540aSrobert        *  The @a state argument should be intialized if the input is at the
100*404b540aSrobert        *  beginning and carried from a previous call if continuing
101*404b540aSrobert        *  conversion.  There are no guarantees about how @a state is used.
102*404b540aSrobert        *
103*404b540aSrobert        *  The result returned is a member of codecvt_base::result.  If
104*404b540aSrobert        *  all the input is converted, returns codecvt_base::ok.  If no
105*404b540aSrobert        *  conversion is necessary, returns codecvt_base::noconv.  If
106*404b540aSrobert        *  the input ends early or there is insufficient space in the
107*404b540aSrobert        *  output, returns codecvt_base::partial.  Otherwise the
108*404b540aSrobert        *  conversion failed and codecvt_base::error is returned.
109*404b540aSrobert        *
110*404b540aSrobert        *  @param  state  Persistent conversion state data.
111*404b540aSrobert        *  @param  from  Start of input.
112*404b540aSrobert        *  @param  from_end  End of input.
113*404b540aSrobert        *  @param  from_next  Returns start of unconverted data.
114*404b540aSrobert        *  @param  to  Start of output buffer.
115*404b540aSrobert        *  @param  to_end  End of output buffer.
116*404b540aSrobert        *  @param  to_next  Returns start of unused output area.
117*404b540aSrobert        *  @return  codecvt_base::result.
118*404b540aSrobert       */
119*404b540aSrobert       result
out(state_type & __state,const intern_type * __from,const intern_type * __from_end,const intern_type * & __from_next,extern_type * __to,extern_type * __to_end,extern_type * & __to_next)120*404b540aSrobert       out(state_type& __state, const intern_type* __from,
121*404b540aSrobert 	  const intern_type* __from_end, const intern_type*& __from_next,
122*404b540aSrobert 	  extern_type* __to, extern_type* __to_end,
123*404b540aSrobert 	  extern_type*& __to_next) const
124*404b540aSrobert       {
125*404b540aSrobert 	return this->do_out(__state, __from, __from_end, __from_next,
126*404b540aSrobert 			    __to, __to_end, __to_next);
127*404b540aSrobert       }
128*404b540aSrobert 
129*404b540aSrobert       /**
130*404b540aSrobert        *  @brief  Reset conversion state.
131*404b540aSrobert        *
132*404b540aSrobert        *  Writes characters to output that would restore @a state to initial
133*404b540aSrobert        *  conditions.  The idea is that if a partial conversion occurs, then
134*404b540aSrobert        *  the converting the characters written by this function would leave
135*404b540aSrobert        *  the state in initial conditions, rather than partial conversion
136*404b540aSrobert        *  state.  It does this by calling codecvt::do_unshift().
137*404b540aSrobert        *
138*404b540aSrobert        *  For example, if 4 external characters always converted to 1 internal
139*404b540aSrobert        *  character, and input to in() had 6 external characters with state
140*404b540aSrobert        *  saved, this function would write two characters to the output and
141*404b540aSrobert        *  set the state to initialized conditions.
142*404b540aSrobert        *
143*404b540aSrobert        *  The source and destination character sets are determined by the
144*404b540aSrobert        *  facet's locale, internal and external types.
145*404b540aSrobert        *
146*404b540aSrobert        *  The result returned is a member of codecvt_base::result.  If the
147*404b540aSrobert        *  state could be reset and data written, returns codecvt_base::ok.  If
148*404b540aSrobert        *  no conversion is necessary, returns codecvt_base::noconv.  If the
149*404b540aSrobert        *  output has insufficient space, returns codecvt_base::partial.
150*404b540aSrobert        *  Otherwise the reset failed and codecvt_base::error is returned.
151*404b540aSrobert        *
152*404b540aSrobert        *  @param  state  Persistent conversion state data.
153*404b540aSrobert        *  @param  to  Start of output buffer.
154*404b540aSrobert        *  @param  to_end  End of output buffer.
155*404b540aSrobert        *  @param  to_next  Returns start of unused output area.
156*404b540aSrobert        *  @return  codecvt_base::result.
157*404b540aSrobert       */
158*404b540aSrobert       result
unshift(state_type & __state,extern_type * __to,extern_type * __to_end,extern_type * & __to_next)159*404b540aSrobert       unshift(state_type& __state, extern_type* __to, extern_type* __to_end,
160*404b540aSrobert 	      extern_type*& __to_next) const
161*404b540aSrobert       { return this->do_unshift(__state, __to,__to_end,__to_next); }
162*404b540aSrobert 
163*404b540aSrobert       /**
164*404b540aSrobert        *  @brief  Convert from external to internal character set.
165*404b540aSrobert        *
166*404b540aSrobert        *  Converts input string of extern_type to output string of
167*404b540aSrobert        *  intern_type.  This is analogous to mbsrtowcs.  It does this by
168*404b540aSrobert        *  calling codecvt::do_in.
169*404b540aSrobert        *
170*404b540aSrobert        *  The source and destination character sets are determined by the
171*404b540aSrobert        *  facet's locale, internal and external types.
172*404b540aSrobert        *
173*404b540aSrobert        *  The characters in [from,from_end) are converted and written to
174*404b540aSrobert        *  [to,to_end).  from_next and to_next are set to point to the
175*404b540aSrobert        *  character following the last successfully converted character,
176*404b540aSrobert        *  respectively.  If the result needed no conversion, from_next and
177*404b540aSrobert        *  to_next are not affected.
178*404b540aSrobert        *
179*404b540aSrobert        *  The @a state argument should be intialized if the input is at the
180*404b540aSrobert        *  beginning and carried from a previous call if continuing
181*404b540aSrobert        *  conversion.  There are no guarantees about how @a state is used.
182*404b540aSrobert        *
183*404b540aSrobert        *  The result returned is a member of codecvt_base::result.  If
184*404b540aSrobert        *  all the input is converted, returns codecvt_base::ok.  If no
185*404b540aSrobert        *  conversion is necessary, returns codecvt_base::noconv.  If
186*404b540aSrobert        *  the input ends early or there is insufficient space in the
187*404b540aSrobert        *  output, returns codecvt_base::partial.  Otherwise the
188*404b540aSrobert        *  conversion failed and codecvt_base::error is returned.
189*404b540aSrobert        *
190*404b540aSrobert        *  @param  state  Persistent conversion state data.
191*404b540aSrobert        *  @param  from  Start of input.
192*404b540aSrobert        *  @param  from_end  End of input.
193*404b540aSrobert        *  @param  from_next  Returns start of unconverted data.
194*404b540aSrobert        *  @param  to  Start of output buffer.
195*404b540aSrobert        *  @param  to_end  End of output buffer.
196*404b540aSrobert        *  @param  to_next  Returns start of unused output area.
197*404b540aSrobert        *  @return  codecvt_base::result.
198*404b540aSrobert       */
199*404b540aSrobert       result
in(state_type & __state,const extern_type * __from,const extern_type * __from_end,const extern_type * & __from_next,intern_type * __to,intern_type * __to_end,intern_type * & __to_next)200*404b540aSrobert       in(state_type& __state, const extern_type* __from,
201*404b540aSrobert 	 const extern_type* __from_end, const extern_type*& __from_next,
202*404b540aSrobert 	 intern_type* __to, intern_type* __to_end,
203*404b540aSrobert 	 intern_type*& __to_next) const
204*404b540aSrobert       {
205*404b540aSrobert 	return this->do_in(__state, __from, __from_end, __from_next,
206*404b540aSrobert 			   __to, __to_end, __to_next);
207*404b540aSrobert       }
208*404b540aSrobert 
209*404b540aSrobert       int
encoding()210*404b540aSrobert       encoding() const throw()
211*404b540aSrobert       { return this->do_encoding(); }
212*404b540aSrobert 
213*404b540aSrobert       bool
always_noconv()214*404b540aSrobert       always_noconv() const throw()
215*404b540aSrobert       { return this->do_always_noconv(); }
216*404b540aSrobert 
217*404b540aSrobert       int
length(state_type & __state,const extern_type * __from,const extern_type * __end,size_t __max)218*404b540aSrobert       length(state_type& __state, const extern_type* __from,
219*404b540aSrobert 	     const extern_type* __end, size_t __max) const
220*404b540aSrobert       { return this->do_length(__state, __from, __end, __max); }
221*404b540aSrobert 
222*404b540aSrobert       int
max_length()223*404b540aSrobert       max_length() const throw()
224*404b540aSrobert       { return this->do_max_length(); }
225*404b540aSrobert 
226*404b540aSrobert     protected:
227*404b540aSrobert       explicit
facet(__refs)228*404b540aSrobert       __codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { }
229*404b540aSrobert 
230*404b540aSrobert       virtual
~__codecvt_abstract_base()231*404b540aSrobert       ~__codecvt_abstract_base() { }
232*404b540aSrobert 
233*404b540aSrobert       /**
234*404b540aSrobert        *  @brief  Convert from internal to external character set.
235*404b540aSrobert        *
236*404b540aSrobert        *  Converts input string of intern_type to output string of
237*404b540aSrobert        *  extern_type.  This function is a hook for derived classes to change
238*404b540aSrobert        *  the value returned.  @see out for more information.
239*404b540aSrobert       */
240*404b540aSrobert       virtual result
241*404b540aSrobert       do_out(state_type& __state, const intern_type* __from,
242*404b540aSrobert 	     const intern_type* __from_end, const intern_type*& __from_next,
243*404b540aSrobert 	     extern_type* __to, extern_type* __to_end,
244*404b540aSrobert 	     extern_type*& __to_next) const = 0;
245*404b540aSrobert 
246*404b540aSrobert       virtual result
247*404b540aSrobert       do_unshift(state_type& __state, extern_type* __to,
248*404b540aSrobert 		 extern_type* __to_end, extern_type*& __to_next) const = 0;
249*404b540aSrobert 
250*404b540aSrobert       virtual result
251*404b540aSrobert       do_in(state_type& __state, const extern_type* __from,
252*404b540aSrobert 	    const extern_type* __from_end, const extern_type*& __from_next,
253*404b540aSrobert 	    intern_type* __to, intern_type* __to_end,
254*404b540aSrobert 	    intern_type*& __to_next) const = 0;
255*404b540aSrobert 
256*404b540aSrobert       virtual int
257*404b540aSrobert       do_encoding() const throw() = 0;
258*404b540aSrobert 
259*404b540aSrobert       virtual bool
260*404b540aSrobert       do_always_noconv() const throw() = 0;
261*404b540aSrobert 
262*404b540aSrobert       virtual int
263*404b540aSrobert       do_length(state_type&, const extern_type* __from,
264*404b540aSrobert 		const extern_type* __end, size_t __max) const = 0;
265*404b540aSrobert 
266*404b540aSrobert       virtual int
267*404b540aSrobert       do_max_length() const throw() = 0;
268*404b540aSrobert     };
269*404b540aSrobert 
270*404b540aSrobert   /// @brief class codecvt [22.2.1.5].
271*404b540aSrobert   /// NB: Generic, mostly useless implementation.
272*404b540aSrobert   template<typename _InternT, typename _ExternT, typename _StateT>
273*404b540aSrobert     class codecvt
274*404b540aSrobert     : public __codecvt_abstract_base<_InternT, _ExternT, _StateT>
275*404b540aSrobert     {
276*404b540aSrobert     public:
277*404b540aSrobert       // Types:
278*404b540aSrobert       typedef codecvt_base::result	result;
279*404b540aSrobert       typedef _InternT			intern_type;
280*404b540aSrobert       typedef _ExternT			extern_type;
281*404b540aSrobert       typedef _StateT			state_type;
282*404b540aSrobert 
283*404b540aSrobert     protected:
284*404b540aSrobert       __c_locale			_M_c_locale_codecvt;
285*404b540aSrobert 
286*404b540aSrobert     public:
287*404b540aSrobert       static locale::id			id;
288*404b540aSrobert 
289*404b540aSrobert       explicit
290*404b540aSrobert       codecvt(size_t __refs = 0)
291*404b540aSrobert       : __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs) { }
292*404b540aSrobert 
293*404b540aSrobert       explicit
294*404b540aSrobert       codecvt(__c_locale __cloc, size_t __refs = 0);
295*404b540aSrobert 
296*404b540aSrobert     protected:
297*404b540aSrobert       virtual
~codecvt()298*404b540aSrobert       ~codecvt() { }
299*404b540aSrobert 
300*404b540aSrobert       virtual result
301*404b540aSrobert       do_out(state_type& __state, const intern_type* __from,
302*404b540aSrobert 	     const intern_type* __from_end, const intern_type*& __from_next,
303*404b540aSrobert 	     extern_type* __to, extern_type* __to_end,
304*404b540aSrobert 	     extern_type*& __to_next) const;
305*404b540aSrobert 
306*404b540aSrobert       virtual result
307*404b540aSrobert       do_unshift(state_type& __state, extern_type* __to,
308*404b540aSrobert 		 extern_type* __to_end, extern_type*& __to_next) const;
309*404b540aSrobert 
310*404b540aSrobert       virtual result
311*404b540aSrobert       do_in(state_type& __state, const extern_type* __from,
312*404b540aSrobert 	    const extern_type* __from_end, const extern_type*& __from_next,
313*404b540aSrobert 	    intern_type* __to, intern_type* __to_end,
314*404b540aSrobert 	    intern_type*& __to_next) const;
315*404b540aSrobert 
316*404b540aSrobert       virtual int
317*404b540aSrobert       do_encoding() const throw();
318*404b540aSrobert 
319*404b540aSrobert       virtual bool
320*404b540aSrobert       do_always_noconv() const throw();
321*404b540aSrobert 
322*404b540aSrobert       virtual int
323*404b540aSrobert       do_length(state_type&, const extern_type* __from,
324*404b540aSrobert 		const extern_type* __end, size_t __max) const;
325*404b540aSrobert 
326*404b540aSrobert       virtual int
327*404b540aSrobert       do_max_length() const throw();
328*404b540aSrobert     };
329*404b540aSrobert 
330*404b540aSrobert   template<typename _InternT, typename _ExternT, typename _StateT>
331*404b540aSrobert     locale::id codecvt<_InternT, _ExternT, _StateT>::id;
332*404b540aSrobert 
333*404b540aSrobert   /// @brief class codecvt<char, char, mbstate_t> specialization.
334*404b540aSrobert   template<>
335*404b540aSrobert     class codecvt<char, char, mbstate_t>
336*404b540aSrobert     : public __codecvt_abstract_base<char, char, mbstate_t>
337*404b540aSrobert     {
338*404b540aSrobert     public:
339*404b540aSrobert       // Types:
340*404b540aSrobert       typedef char			intern_type;
341*404b540aSrobert       typedef char			extern_type;
342*404b540aSrobert       typedef mbstate_t			state_type;
343*404b540aSrobert 
344*404b540aSrobert     protected:
345*404b540aSrobert       __c_locale			_M_c_locale_codecvt;
346*404b540aSrobert 
347*404b540aSrobert     public:
348*404b540aSrobert       static locale::id id;
349*404b540aSrobert 
350*404b540aSrobert       explicit
351*404b540aSrobert       codecvt(size_t __refs = 0);
352*404b540aSrobert 
353*404b540aSrobert       explicit
354*404b540aSrobert       codecvt(__c_locale __cloc, size_t __refs = 0);
355*404b540aSrobert 
356*404b540aSrobert     protected:
357*404b540aSrobert       virtual
358*404b540aSrobert       ~codecvt();
359*404b540aSrobert 
360*404b540aSrobert       virtual result
361*404b540aSrobert       do_out(state_type& __state, const intern_type* __from,
362*404b540aSrobert 	     const intern_type* __from_end, const intern_type*& __from_next,
363*404b540aSrobert 	     extern_type* __to, extern_type* __to_end,
364*404b540aSrobert 	     extern_type*& __to_next) const;
365*404b540aSrobert 
366*404b540aSrobert       virtual result
367*404b540aSrobert       do_unshift(state_type& __state, extern_type* __to,
368*404b540aSrobert 		 extern_type* __to_end, extern_type*& __to_next) const;
369*404b540aSrobert 
370*404b540aSrobert       virtual result
371*404b540aSrobert       do_in(state_type& __state, const extern_type* __from,
372*404b540aSrobert 	    const extern_type* __from_end, const extern_type*& __from_next,
373*404b540aSrobert 	    intern_type* __to, intern_type* __to_end,
374*404b540aSrobert 	    intern_type*& __to_next) const;
375*404b540aSrobert 
376*404b540aSrobert       virtual int
377*404b540aSrobert       do_encoding() const throw();
378*404b540aSrobert 
379*404b540aSrobert       virtual bool
380*404b540aSrobert       do_always_noconv() const throw();
381*404b540aSrobert 
382*404b540aSrobert       virtual int
383*404b540aSrobert       do_length(state_type&, const extern_type* __from,
384*404b540aSrobert 		const extern_type* __end, size_t __max) const;
385*404b540aSrobert 
386*404b540aSrobert       virtual int
387*404b540aSrobert       do_max_length() const throw();
388*404b540aSrobert   };
389*404b540aSrobert 
390*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
391*404b540aSrobert   /// @brief  class codecvt<wchar_t, char, mbstate_t> specialization.
392*404b540aSrobert   template<>
393*404b540aSrobert     class codecvt<wchar_t, char, mbstate_t>
394*404b540aSrobert     : public __codecvt_abstract_base<wchar_t, char, mbstate_t>
395*404b540aSrobert     {
396*404b540aSrobert     public:
397*404b540aSrobert       // Types:
398*404b540aSrobert       typedef wchar_t			intern_type;
399*404b540aSrobert       typedef char			extern_type;
400*404b540aSrobert       typedef mbstate_t			state_type;
401*404b540aSrobert 
402*404b540aSrobert     protected:
403*404b540aSrobert       __c_locale			_M_c_locale_codecvt;
404*404b540aSrobert 
405*404b540aSrobert     public:
406*404b540aSrobert       static locale::id			id;
407*404b540aSrobert 
408*404b540aSrobert       explicit
409*404b540aSrobert       codecvt(size_t __refs = 0);
410*404b540aSrobert 
411*404b540aSrobert       explicit
412*404b540aSrobert       codecvt(__c_locale __cloc, size_t __refs = 0);
413*404b540aSrobert 
414*404b540aSrobert     protected:
415*404b540aSrobert       virtual
416*404b540aSrobert       ~codecvt();
417*404b540aSrobert 
418*404b540aSrobert       virtual result
419*404b540aSrobert       do_out(state_type& __state, const intern_type* __from,
420*404b540aSrobert 	     const intern_type* __from_end, const intern_type*& __from_next,
421*404b540aSrobert 	     extern_type* __to, extern_type* __to_end,
422*404b540aSrobert 	     extern_type*& __to_next) const;
423*404b540aSrobert 
424*404b540aSrobert       virtual result
425*404b540aSrobert       do_unshift(state_type& __state,
426*404b540aSrobert 		 extern_type* __to, extern_type* __to_end,
427*404b540aSrobert 		 extern_type*& __to_next) const;
428*404b540aSrobert 
429*404b540aSrobert       virtual result
430*404b540aSrobert       do_in(state_type& __state,
431*404b540aSrobert 	     const extern_type* __from, const extern_type* __from_end,
432*404b540aSrobert 	     const extern_type*& __from_next,
433*404b540aSrobert 	     intern_type* __to, intern_type* __to_end,
434*404b540aSrobert 	     intern_type*& __to_next) const;
435*404b540aSrobert 
436*404b540aSrobert       virtual
437*404b540aSrobert       int do_encoding() const throw();
438*404b540aSrobert 
439*404b540aSrobert       virtual
440*404b540aSrobert       bool do_always_noconv() const throw();
441*404b540aSrobert 
442*404b540aSrobert       virtual
443*404b540aSrobert       int do_length(state_type&, const extern_type* __from,
444*404b540aSrobert 		    const extern_type* __end, size_t __max) const;
445*404b540aSrobert 
446*404b540aSrobert       virtual int
447*404b540aSrobert       do_max_length() const throw();
448*404b540aSrobert     };
449*404b540aSrobert #endif //_GLIBCXX_USE_WCHAR_T
450*404b540aSrobert 
451*404b540aSrobert   /// @brief class codecvt_byname [22.2.1.6].
452*404b540aSrobert   template<typename _InternT, typename _ExternT, typename _StateT>
453*404b540aSrobert     class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT>
454*404b540aSrobert     {
455*404b540aSrobert     public:
456*404b540aSrobert       explicit
457*404b540aSrobert       codecvt_byname(const char* __s, size_t __refs = 0)
458*404b540aSrobert       : codecvt<_InternT, _ExternT, _StateT>(__refs)
459*404b540aSrobert       {
460*404b540aSrobert 	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
461*404b540aSrobert 	  {
462*404b540aSrobert 	    this->_S_destroy_c_locale(this->_M_c_locale_codecvt);
463*404b540aSrobert 	    this->_S_create_c_locale(this->_M_c_locale_codecvt, __s);
464*404b540aSrobert 	  }
465*404b540aSrobert       }
466*404b540aSrobert 
467*404b540aSrobert     protected:
468*404b540aSrobert       virtual
~codecvt_byname()469*404b540aSrobert       ~codecvt_byname() { }
470*404b540aSrobert     };
471*404b540aSrobert 
472*404b540aSrobert _GLIBCXX_END_NAMESPACE
473*404b540aSrobert 
474*404b540aSrobert #endif // _CODECVT_H
475