aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@purist.soma.redhat.com>2000-08-16 04:12:51 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2000-08-16 04:12:51 +0000
commit63511623299e3fd5994f1f96d956e21bf380aa4f (patch)
treee19f71e078697043ffd4a59617c22e4290adf158
parentfec1ce0a00615fde6d338965a44ebc12db3e1be4 (diff)
downloadgcc-63511623299e3fd5994f1f96d956e21bf380aa4f.zip
gcc-63511623299e3fd5994f1f96d956e21bf380aa4f.tar.gz
gcc-63511623299e3fd5994f1f96d956e21bf380aa4f.tar.bz2
codecvt.h: New file.
2000-08-15 Benjamin Kosnik <bkoz@purist.soma.redhat.com> * bits/codecvt.h: New file. * src/codecvt.cc: New file. * bits/std_locale.h: Add include here. * src/Makefile.am (headers): Add codecvt.h (sources): Add codecvt.cc. * src/Makefile.in: Regenerate. * bits/locale_facets.h (codecvt): Re-implement. Rename _Codecvt to __codecvt_abstract_base in an attempt to point some light this way... Move __enc_traits and codecvt bits to codecvt.h. * src/locale-inst.cc: Remove codecvt<wchar_t, wchar_t, mbstate_t> explicit instantiation. Separate out codecvt instantations, simplify. * src/locale.cc: Move codecvt bits to codecvt.cc From-SVN: r35737
-rw-r--r--libstdc++-v3/ChangeLog15
-rw-r--r--libstdc++-v3/bits/codecvt.h438
-rw-r--r--libstdc++-v3/bits/locale_facets.h348
-rw-r--r--libstdc++-v3/bits/locale_facets.tcc3
-rw-r--r--libstdc++-v3/bits/std_locale.h1
-rw-r--r--libstdc++-v3/src/Makefile.am6
-rw-r--r--libstdc++-v3/src/codecvt.cc186
-rw-r--r--libstdc++-v3/src/locale-inst.cc9
-rw-r--r--libstdc++-v3/src/locale.cc148
9 files changed, 647 insertions, 507 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e2fdf41..3fe296f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,18 @@
+2000-08-15 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
+
+ * bits/codecvt.h: New file.
+ * src/codecvt.cc: New file.
+ * bits/std_locale.h: Add include here.
+ * src/Makefile.am (headers): Add codecvt.h
+ (sources): Add codecvt.cc.
+ * src/Makefile.in: Regenerate.
+ * bits/locale_facets.h (codecvt): Re-implement. Rename _Codecvt to
+ __codecvt_abstract_base in an attempt to point some light this way...
+ Move __enc_traits and codecvt bits to codecvt.h.
+ * src/locale-inst.cc: Remove codecvt<wchar_t, wchar_t, mbstate_t>
+ explicit instantiation. Separate out codecvt instantations, simplify.
+ * src/locale.cc: Move codecvt bits to codecvt.cc
+
2000-08-15 Alexandre Oliva <aoliva@redhat.com>
* src/Makefile.am (INCLUDES): New target file, with all -I flags.
diff --git a/libstdc++-v3/bits/codecvt.h b/libstdc++-v3/bits/codecvt.h
new file mode 100644
index 0000000..90245d6
--- /dev/null
+++ b/libstdc++-v3/bits/codecvt.h
@@ -0,0 +1,438 @@
+// Locale support (codecvt) -*- C++ -*-
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+//
+// ISO C++ 14882: 22.2.1.5 Template class codecvt
+//
+
+// Warning: this file is not meant for user inclusion. Use <locale>.
+
+// Written by Benjamin Kosnik <bkoz@cygnus.com>
+
+#ifndef _CPP_BITS_CODECVT_H
+#define _CPP_BITS_CODECVT_H 1
+
+#ifdef _GLIBCPP_USE_WCHAR_T
+// #include <localefwd.h>
+// XXX include iconv here or higher up....
+#include <iconv.h> // For iconv, iconv_t
+#endif
+
+namespace std
+{
+ // XXX __enc_traits may need to move up the locale header heirarchy,
+ // depending on if ctype ends up using it.
+#ifdef _GLIBCPP_USE_WCHAR_T
+ // Extensions to use icov for dealing with character encodings,
+ // including conversions and comparisons between various character
+ // sets. This object encapsulates data that may need to be shared between
+ // char_traits, codecvt and ctype.
+ template<typename _InternT, typename _ExternT>
+ class __enc_traits
+ {
+ public:
+ // Types:
+ typedef _InternT __intc_type;
+ typedef _ExternT __extc_type;
+ typedef iconv_t __conv_type;
+ typedef mbstate_t __state_type;
+
+ // Data Members:
+ // Max size of charset encoding name
+ static const int __max_size = 32;
+ // Name of internal character set encoding.
+ char __intc_enc[__max_size];
+ // Name of external character set encoding.
+ char __extc_enc[__max_size];
+
+ // Conversion descriptor between external encoding to internal encoding.
+ __conv_type __in_conv;
+ // Conversion descriptor between internal encoding to external encoding.
+ __conv_type __out_conv;
+
+ __enc_traits()
+ {
+ // __intc_end = whatever we are using internally, which is
+ // UCS4 (linux)
+ // UCS2 (microsoft, java, aix, whatever...)
+ // XXX Currently don't know how to get this data from target system...
+ strcpy(__intc_enc, "UCS4");
+
+ // __extc_end = external codeset in current locale
+ strcpy(__extc_enc, nl_langinfo(CODESET));
+ __in_conv = iconv_open(__intc_enc, __extc_enc);
+ __out_conv = iconv_open(__extc_enc, __intc_enc);
+ if (__out_conv == (iconv_t) -1 || __in_conv == (iconv_t) -1)
+ {
+ // XXX Extended error checking.
+ }
+ }
+
+ __enc_traits(const char* __int, const char* __ext)
+ {
+ strcpy(__intc_enc, __int);
+ strcpy(__extc_enc, __ext);
+ __in_conv = iconv_open(__intc_enc, __extc_enc);
+ __out_conv = iconv_open(__extc_enc, __intc_enc);
+ if (__out_conv == (iconv_t) -1 || __in_conv == (iconv_t) -1)
+ {
+ // XXX Extended error checking.
+ }
+ }
+
+ ~__enc_traits()
+ {
+ iconv_close(__in_conv);
+ iconv_close(__out_conv);
+ }
+
+ const char*
+ _M_get_intc_enc(void)
+ { return __intc_enc; }
+
+ void
+ _M_set_intc_enc(const char* __c)
+ { strcpy(__intc_enc, __c); }
+
+ const char*
+ _M_get_extc_enc(void)
+ { return __extc_enc; }
+
+ void
+ _M_set_extc_enc(const char* __c)
+ { strcpy(__extc_enc, __c); }
+
+ protected:
+ // 21.1.2 traits typedefs
+ // p4
+ // typedef STATE_T state_type
+ // requires: state_type shall meet the requirements of
+ // CopyConstructible types (20.1.3)
+ // XXX because of this, these might actually need to be filled out.
+ __enc_traits(const __enc_traits&);
+ };
+#endif //_GLIBCPP_USE_WCHAR_T
+
+
+ // 22.2.1.5 Template class codecvt
+ class codecvt_base
+ {
+ public:
+ enum result
+ {
+ ok,
+ partial,
+ error,
+ noconv
+ };
+ };
+
+ // Template class __codecvt_abstract_base
+ // NB: An abstract base class that fills in the public inlines, so
+ // that the specializations don't have to re-copy the public
+ // interface.
+ template<typename _InternT, typename _ExternT, typename _StateT>
+ class __codecvt_abstract_base
+ : public locale::facet, public codecvt_base
+ {
+ public:
+ // Types:
+ typedef _InternT intern_type;
+ typedef _ExternT extern_type;
+ typedef _StateT state_type;
+
+ // 22.2.1.5.1 codecvt members
+ 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_limit,
+ extern_type*& __to_next) const
+ {
+ return this->do_out(__state, __from, __from_end, __from_next,
+ __to, __to_limit, __to_next);
+ }
+
+ result
+ unshift(state_type& __state, extern_type* __to, extern_type* __to_limit,
+ extern_type*& __to_next) const
+ { return this->do_unshift(__state, __to,__to_limit,__to_next); }
+
+ 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_limit,
+ intern_type*& __to_next) const
+ {
+ return this->do_in(__state, __from, __from_end, __from_next,
+ __to, __to_limit, __to_next);
+ }
+
+ int
+ encoding() const throw()
+ { return this->do_encoding(); }
+
+ bool
+ always_noconv() const throw()
+ { return this->do_always_noconv(); }
+
+ int
+ length(const state_type& __state, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+ { return this->do_length(__state, __from, __end, __max); }
+
+ int
+ max_length() const throw()
+ { return this->do_max_length(); }
+
+ protected:
+ explicit
+ __codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { }
+
+ virtual
+ ~__codecvt_abstract_base() { }
+
+ virtual result
+ do_out(state_type& __state, 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) const = 0;
+
+ virtual result
+ do_unshift(state_type& __state, extern_type* __to,
+ extern_type* __to_limit, extern_type*& __to_next) const = 0;
+
+ virtual result
+ do_in(state_type& __state, 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) const = 0;
+
+ virtual int
+ do_encoding() const throw() = 0;
+
+ virtual bool
+ do_always_noconv() const throw() = 0;
+
+ virtual int
+ do_length(const state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const = 0;
+
+ virtual int
+ do_max_length() const throw() = 0;
+ };
+
+ // 22.2.1.5 Template class codecvt
+ // NB: Generic, mostly useless implementation.
+ template<typename _InternT, typename _ExternT, typename _StateT>
+ class codecvt
+ : public __codecvt_abstract_base<_InternT, _ExternT, _StateT>
+ {
+ public:
+ // Types:
+ typedef _InternT intern_type;
+ typedef _ExternT extern_type;
+ typedef _StateT state_type;
+
+ // Data Members:
+ static locale::id id;
+
+ explicit
+ codecvt(size_t __refs = 0)
+ : __codecvt_abstract_base<_InternT,_ExternT,_StateT> (__refs) { }
+
+ protected:
+ virtual
+ ~codecvt() { }
+ };
+
+ template<typename _InternT, typename _ExternT, typename _StateT>
+ locale::id codecvt<_InternT, _ExternT, _StateT>::id;
+
+ // partial specialization
+ template<typename _InternT, typename _ExternT>
+ class codecvt<_InternT, _ExternT, __enc_traits<_InternT, _ExternT> >
+ : public __codecvt_abstract_base<_InternT,
+ _ExternT, __enc_traits<_InternT, _ExternT> >
+ { };
+
+ // codecvt<char, char, mbstate_t> required specialization
+ template<>
+ class codecvt<char, char, mbstate_t>
+ : public __codecvt_abstract_base<char, char, mbstate_t>
+ {
+ public:
+ // Types:
+ typedef char intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ // Data Members:
+ static locale::id id;
+
+ explicit
+ codecvt(size_t __refs = 0);
+
+ protected:
+ virtual
+ ~codecvt();
+
+ virtual result
+ do_out(state_type& __state, 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) const;
+
+ virtual result
+ do_unshift(state_type& __state, extern_type* __to,
+ extern_type* __to_limit, extern_type*& __to_next) const;
+
+ virtual result
+ do_in(state_type& __state, 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) const;
+
+ virtual int
+ do_encoding() const throw();
+
+ virtual bool
+ do_always_noconv() const throw();
+
+ virtual int
+ do_length(const state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const;
+
+ virtual int
+ do_max_length() const throw();
+ };
+
+#ifdef _GLIBCPP_USE_WCHAR_T
+ // codecvt<wchar_t, char, mbstate_t> required specialization
+ template<>
+ class codecvt<wchar_t, char, mbstate_t>
+ : public __codecvt_abstract_base<wchar_t, char, mbstate_t>
+ {
+ public:
+ // Types:
+ typedef wchar_t intern_type;
+ typedef char extern_type;
+ typedef mbstate_t state_type;
+
+ // Data Members:
+ static locale::id id;
+
+ explicit
+ codecvt(size_t __refs = 0);
+
+ protected:
+ virtual
+ ~codecvt();
+
+ virtual result
+ do_out(state_type& __state, 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) const;
+
+ virtual result
+ do_unshift(state_type& __state,
+ extern_type* __to, extern_type* __to_limit,
+ extern_type*& __to_next) const;
+
+ virtual result
+ do_in(state_type& __state,
+ 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) const;
+
+ virtual
+ int do_encoding() const throw();
+
+ virtual
+ bool do_always_noconv() const throw();
+
+ virtual
+ int do_length(const state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const;
+
+ virtual int
+ do_max_length() const throw();
+ };
+#endif //_GLIBCPP_USE_WCHAR_T
+
+ // 22.2.1.6 Template class codecvt_byname
+ template<typename _InternT, typename _ExternT, typename _StateT>
+ class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT>
+ {
+ public:
+ explicit
+ codecvt_byname(const char*, size_t __refs = 0)
+ : codecvt<_InternT,_ExternT,_StateT> (__refs) { }
+ protected:
+ virtual
+ ~codecvt_byname() { }
+ };
+
+ template<>
+ class codecvt_byname<char, char, mbstate_t>
+ : public codecvt<char, char, mbstate_t>
+ {
+ public:
+ explicit
+ codecvt_byname(const char*, size_t __refs = 0);
+
+ protected:
+ virtual
+ ~codecvt_byname();
+ };
+
+#ifdef _GLIBCPP_USE_WCHAR_T
+ template<>
+ class codecvt_byname<wchar_t, char, mbstate_t>
+ : public codecvt<wchar_t, char, mbstate_t>
+ {
+ public:
+ explicit
+ codecvt_byname(const char*, size_t __refs = 0);
+
+ protected:
+ virtual
+ ~codecvt_byname();
+ };
+#endif
+
+} // namespace std
+
+#endif // _CPP_BITS_CODECVT_H
+
+// Local Variables:
+// mode:c++
+// End:
+
diff --git a/libstdc++-v3/bits/locale_facets.h b/libstdc++-v3/bits/locale_facets.h
index 2bec595..a8bf7bb 100644
--- a/libstdc++-v3/bits/locale_facets.h
+++ b/libstdc++-v3/bits/locale_facets.h
@@ -39,14 +39,9 @@
#include <bits/std_ctime.h> // For struct tm
#include <bits/std_typeinfo.h> // For bad_cast, which shouldn't be here.
#include <bits/std_ios.h> // For ios_base
-#ifdef _GLIBCPP_USE_WCHAR_T
-// XXX should break this out??
-#include <iconv.h> // For iconv, iconv_t
-#endif
namespace std
{
-
// XXX This function is to be specialized for the "required" facets to
// be constructed lazily. The specializations must be declared after
// the definitions of the facets themselves; but they shouldn't be
@@ -80,98 +75,6 @@ namespace std
_Use_facet_failure_handler(const locale&)
{ throw _Bad_use_facet(); }
-
-#ifdef _GLIBCPP_USE_WCHAR_T
- // Extensions to use icov for dealing with character encodings,
- // including conversions and comparisons between various character
- // sets. This object encapsulates data that may need to be shared between
- // char_traits, codecvt and ctype.
- template<typename _IntT, typename _ExtT>
- class __enc_traits
- {
- public:
- // Types:
- typedef _IntT __intc_type;
- typedef _ExtT __extc_type;
- typedef iconv_t __conv_type;
- typedef mbstate_t __state_type;
-
- // Data Members:
- // Max size of charset encoding name
- static const int __max_size = 32;
- // Name of internal character set encoding.
- char __intc_enc[__max_size];
- // Name of external character set encoding.
- char __extc_enc[__max_size];
-
- // Conversion descriptor between external encoding to internal encoding.
- __conv_type __in_conv;
- // Conversion descriptor between internal encoding to external encoding.
- __conv_type __out_conv;
-
- __enc_traits()
- {
- // __intc_end = whatever we are using internally, which is
- // UCS4 (linux)
- // UCS2 (microsoft, java, aix, whatever...)
- // XXX Currently don't know how to get this data from target system...
- strcpy(__intc_enc, "UCS4");
-
- // __extc_end = external codeset in current locale
- strcpy(__extc_enc, nl_langinfo(CODESET));
- __in_conv = iconv_open(__intc_enc, __extc_enc);
- __out_conv = iconv_open(__extc_enc, __intc_enc);
- if (__out_conv == (iconv_t) -1 || __in_conv == (iconv_t) -1)
- {
- // XXX Extended error checking.
- }
- }
-
- __enc_traits(const char* __int, const char* __ext)
- {
- strcpy(__intc_enc, __int);
- strcpy(__extc_enc, __ext);
- __in_conv = iconv_open(__intc_enc, __extc_enc);
- __out_conv = iconv_open(__extc_enc, __intc_enc);
- if (__out_conv == (iconv_t) -1 || __in_conv == (iconv_t) -1)
- {
- // XXX Extended error checking.
- }
- }
-
- ~__enc_traits()
- {
- iconv_close(__in_conv);
- iconv_close(__out_conv);
- }
-
- const char*
- _M_get_intc_enc(void)
- { return __intc_enc; }
-
- void
- _M_set_intc_enc(const char* __c)
- { strcpy(__intc_enc, __c); }
-
- const char*
- _M_get_extc_enc(void)
- { return __extc_enc; }
-
- void
- _M_set_extc_enc(const char* __c)
- { strcpy(__extc_enc, __c); }
-
- protected:
- // 21.1.2 traits typedefs
- // p4
- // typedef STATE_T state_type
- // requires: state_type shall meet the requirements of
- // CopyConstructible types (20.1.3)
- // XXX because of this, these might actually need to be filled out.
- __enc_traits(const __enc_traits&);
- };
-#endif //_GLIBCPP_USE_WCHAR_T
-
// 22.2.1 The ctype category
// Include host-specific ctype enums for ctype_base.
#include <bits/ctype_base.h>
@@ -582,257 +485,6 @@ namespace std
#endif
- // 22.2.1.5 Template class codecvt
- class codecvt_base
- {
- public:
- enum result
- {
- ok,
- partial,
- error,
- noconv
- };
- };
-
- template<typename _InternT, typename _ExternT, typename _StateT>
- class _Codecvt : public locale::facet, public codecvt_base
- {
- public:
- // Types:
- typedef _InternT intern_type;
- typedef _ExternT extern_type;
- typedef _StateT state_type;
-
- protected:
- explicit
- _Codecvt (size_t __refs = 0) : locale::facet(__refs) { }
-
- public:
- 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_limit,
- extern_type*& __to_next) const
- {
- return do_out(__state, __from, __from_end, __from_next, __to,
- __to_limit, __to_next);
- }
-
- result
- unshift(state_type& __state, extern_type* __to, extern_type* __to_limit,
- extern_type*& __to_next) const
- { return do_unshift(__state, __to,__to_limit,__to_next); }
-
- 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_limit,
- intern_type*& __to_next) const
- {
- return do_in(__state, __from, __from_end, __from_next,
- __to, __to_limit, __to_next);
- }
-
- int
- encoding() const throw()
- { return do_encoding(); }
-
- bool
- always_noconv() const throw()
- { return do_always_noconv(); }
-
- int
- length(const state_type& __state, const extern_type* __from,
- const extern_type* __end, size_t __max) const
- { return do_length(__state, __from, __end, __max); }
-
- int
- max_length() const throw()
- { return do_max_length(); }
-
- protected:
- virtual
- ~_Codecvt() { }
-
- virtual result
- do_out(state_type& __state,
- 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) const = 0;
-
- virtual result
- do_unshift(state_type& __state,
- extern_type* __to, extern_type* __to_limit,
- extern_type*& __to_next) const = 0;
-
- virtual result
- do_in(state_type& __state,
- 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) const = 0;
-
- virtual int
- do_encoding() const throw() = 0;
-
- virtual bool
- do_always_noconv() const throw() = 0;
-
- virtual int
- do_length(const state_type&, const extern_type* __from,
- const extern_type* __end, size_t __max) const = 0;
-
- virtual int
- do_max_length() const throw() = 0;
- };
-
-
- template<typename _InternT, typename _ExternT, typename _StateT>
- class codecvt : public _Codecvt<_InternT, _ExternT, _StateT>
- {
- public:
- // Types:
- typedef _InternT intern_type;
- typedef _ExternT extern_type;
- typedef _StateT state_type;
-
- // Data Members:
- static locale::id id;
-
- explicit
- codecvt(size_t __refs = 0)
- : _Codecvt<_InternT, _ExternT, _StateT> (__refs) { }
-
- protected:
- virtual
- ~codecvt() { }
- };
-
- // codecvt<char, char, mbstate_t> specialization
- template<>
- class codecvt<char, char, mbstate_t>
- : public _Codecvt<char, char, mbstate_t>
- {
- public:
- // Types:
- typedef char intern_type;
- typedef char extern_type;
- typedef mbstate_t state_type;
-
- explicit codecvt (size_t __refs = 0);
- static locale::id id;
-
- protected:
- virtual ~codecvt();
- virtual result
- do_out(state_type& __state, 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) const;
-
- virtual result
- do_unshift(state_type& __state, extern_type* __to,
- extern_type* __to_limit, extern_type*& __to_next) const;
-
- virtual result
- do_in(state_type& __state, 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) const;
-
- virtual int do_encoding() const throw();
- virtual bool do_always_noconv() const throw();
- virtual int do_length(const state_type&, const extern_type* __from,
- const extern_type* __end, size_t __max) const;
- virtual int do_max_length() const throw();
- };
-
-#ifdef _GLIBCPP_USE_WCHAR_T
- template<>
- class codecvt<wchar_t, char, mbstate_t>
- : public _Codecvt<wchar_t, char, mbstate_t>
- {
- public:
- // Types:
- typedef wchar_t intern_type;
- typedef char extern_type;
- typedef mbstate_t state_type;
-
- explicit codecvt(size_t __refs = 0);
- static locale::id id;
-
- protected:
- virtual ~codecvt();
- virtual result
- do_out(state_type& __state, 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) const;
-
- virtual result
- do_unshift(state_type& __state,
- extern_type* __to, extern_type* __to_limit,
- extern_type*& __to_next) const;
-
- virtual result
- do_in(state_type& __state,
- 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) const;
-
- virtual int do_encoding() const throw();
- virtual bool do_always_noconv() const throw();
- virtual int do_length(const state_type&, const extern_type* __from,
- const extern_type* __end, size_t __max) const;
- virtual int do_max_length() const throw();
- };
-#endif //_GLIBCPP_USE_WCHAR_T
-
-
- // 22.2.1.6 Template class codecvt_byname
- template<typename _InternT, typename _ExternT, typename _StateT>
- class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT>
- {
- public:
- explicit
- codecvt_byname(const char*, size_t __refs = 0)
- : codecvt<_InternT,_ExternT,_StateT> (__refs) { }
- protected:
- virtual
- ~codecvt_byname() { }
- };
-
- template<>
- class codecvt_byname<char, char, mbstate_t>
- : public codecvt<char, char, mbstate_t>
- {
- public:
- explicit
- codecvt_byname(const char*, size_t __refs = 0);
-
- protected:
- virtual
- ~codecvt_byname();
- };
-
-#ifdef _GLIBCPP_USE_WCHAR_T
- template<>
- class codecvt_byname<wchar_t, char, mbstate_t>
- : public codecvt<wchar_t, char, mbstate_t>
- {
- public:
- explicit
- codecvt_byname(const char*, size_t __refs = 0);
-
- protected:
- virtual
- ~codecvt_byname();
- };
-#endif
-
template<typename _CharT, typename _InIter>
class _Numeric_get; // forward
diff --git a/libstdc++-v3/bits/locale_facets.tcc b/libstdc++-v3/bits/locale_facets.tcc
index ce6bb88..9d98612 100644
--- a/libstdc++-v3/bits/locale_facets.tcc
+++ b/libstdc++-v3/bits/locale_facets.tcc
@@ -160,9 +160,6 @@ namespace std
template<typename _CharT>
locale::id ctype<_CharT>::id;
- template<typename _InternT, typename _ExternT, typename _StateT>
- locale::id codecvt<_InternT, _ExternT, _StateT>::id;
-
template<typename _CharT>
int _Format_cache<_CharT>::_S_pword_ix;
diff --git a/libstdc++-v3/bits/std_locale.h b/libstdc++-v3/bits/std_locale.h
index 8510044..dc3c9aa 100644
--- a/libstdc++-v3/bits/std_locale.h
+++ b/libstdc++-v3/bits/std_locale.h
@@ -36,6 +36,7 @@
#include <bits/localefwd.h>
#include <bits/locale_facets.h>
+#include <bits/codecvt.h>
#endif
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 468d642..e1950aa 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -21,7 +21,7 @@
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
## USA.
-## $Id: Makefile.am,v 1.25 2000/07/26 21:30:45 pme Exp $
+## $Id: Makefile.am,v 1.26 2000/08/15 07:42:36 aoliva Exp $
AUTOMAKE_OPTIONS = 1.3 gnits
MAINT_CHARSET = latin1
@@ -106,7 +106,7 @@ CXXLINK = $(LIBTOOL) --mode=link "$(CC)" @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CX
headers = \
bits/cpp_type_traits.h \
bits/std_cctype.h bits/ctype_base.h bits/ctype_specializations.h \
- bits/char_traits.h \
+ bits/char_traits.h bits/codecvt.h \
bits/basic_string.h bits/std_string.h bits/string.tcc \
bits/generic_shadow.h bits/std_utility.h \
bits/std_complex.h \
@@ -207,7 +207,7 @@ sources = \
complex.cc complexf.cc complexl.cc complex_io.cc \
stdexcept.cc \
c++io.cc ios.cc stdstreams.cc strstream.cc \
- locale.cc localename.cc \
+ locale.cc localename.cc codecvt.cc \
locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc
wstring_sources = \
diff --git a/libstdc++-v3/src/codecvt.cc b/libstdc++-v3/src/codecvt.cc
new file mode 100644
index 0000000..c456b00
--- /dev/null
+++ b/libstdc++-v3/src/codecvt.cc
@@ -0,0 +1,186 @@
+// Copyright (C) 2000 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Written by Benjamin Kosnik <bkoz@cygnus.com>
+
+#include <bits/std_locale.h>
+
+namespace std {
+
+ locale::id codecvt<char, char, mbstate_t>::id;
+
+ codecvt<char, char, mbstate_t>::
+ codecvt(size_t __refs)
+ : __codecvt_abstract_base<char, char, mbstate_t>(__refs)
+ { }
+
+ codecvt<char, char, mbstate_t>::
+ ~codecvt() { }
+
+ codecvt_base::result
+ codecvt<char, char, mbstate_t>::
+ do_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) const
+ {
+ size_t __sizefrom = __from_end - __from;
+ size_t __sizeto = __to_end - __to;
+ size_t __length = __sizefrom <= __sizeto ? __sizefrom : __sizeto;
+ memcpy(__to, __from, __length);
+ __from_next = __from;
+ __to_next = __to;
+ return noconv;
+ }
+
+ codecvt_base::result
+ codecvt<char, char, mbstate_t>::
+ do_unshift(state_type& /*__state*/, extern_type* __to,
+ extern_type* /*__to_limit*/, extern_type*& __to_next) const
+ {
+ __to_next = __to;
+ return noconv;
+ }
+
+ codecvt_base::result
+ codecvt<char, char, mbstate_t>::
+ do_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) const
+ {
+ size_t __sizefrom = __from_end - __from;
+ size_t __sizeto = __to_end - __to;
+ size_t __length = __sizefrom <= __sizeto ? __sizefrom : __sizeto;
+ memcpy(__to, __from, __length);
+ __from_next = __from;
+ __to_next = __to;
+ return noconv;
+ }
+
+ int
+ codecvt<char, char, mbstate_t>::
+ do_encoding() const throw() { return 1; }
+
+ bool
+ codecvt<char, char, mbstate_t>::
+ do_always_noconv() const throw() { return true; }
+
+ int
+ codecvt<char, char, mbstate_t>::
+ do_length (const state_type& /*__state*/, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+ { return (__max < size_t(__end - __from)) ? __max : __end - __from; }
+
+ int
+ codecvt<char, char, mbstate_t>::
+ do_max_length() const throw() { return 1; }
+
+ codecvt_byname<char, char, mbstate_t>::
+ codecvt_byname(const char* /*__s*/, size_t __refs)
+ : codecvt<char, char, mbstate_t>(__refs) { }
+
+ codecvt_byname<char, char, mbstate_t>::
+ ~codecvt_byname() { }
+
+#ifdef _GLIBCPP_USE_WCHAR_T
+ locale::id codecvt<wchar_t, char, mbstate_t>::id;
+
+ codecvt<wchar_t, char, mbstate_t>::
+ codecvt(size_t __refs)
+ : __codecvt_abstract_base<wchar_t, char, mbstate_t>(__refs) { }
+
+ codecvt<wchar_t, char, mbstate_t>::
+ ~codecvt() { }
+
+ codecvt_base::result
+ codecvt<wchar_t, char, mbstate_t>::
+ do_out(state_type& /*__state*/, 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) const
+ {
+ for (; __from < __from_end && __to < __to_limit; ++__from, ++__to)
+ *__to = static_cast<char>(*__from);
+ __from_next = __from; __to_next = __to;
+ return __from == __from_end ? ok : partial;
+ }
+
+ codecvt_base::result
+ codecvt<wchar_t, char, mbstate_t>::
+ do_unshift (state_type& /*__state*/, extern_type* __to,
+ extern_type* /*__to_limit*/, extern_type*& __to_next) const
+ {
+ __to_next = __to;
+ return noconv;
+ }
+
+ codecvt_base::result
+ codecvt<wchar_t, char, mbstate_t>::
+ do_in(state_type& /*__state*/, 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) const
+ {
+ for (; __from < __from_end && __to < __to_limit; ++__from, ++__to)
+ *__to = static_cast<wchar_t>(*__from);
+ __from_next = __from;
+ __to_next = __to;
+ return __from == __from_end ? ok : partial;
+ }
+
+ int
+ codecvt<wchar_t, char, mbstate_t>::
+ do_encoding() const throw()
+ { return 1; }
+
+ bool
+ codecvt<wchar_t, char, mbstate_t>::
+ do_always_noconv() const throw()
+ { return false; }
+
+ int
+ codecvt<wchar_t, char, mbstate_t>::
+ do_length(const state_type& /*__state*/, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+ { return (__max < size_t(__end - __from)) ? __max : __end - __from; }
+
+ int
+ codecvt<wchar_t, char, mbstate_t>::do_max_length() const throw()
+ { return 1; }
+
+ codecvt_byname<wchar_t, char, mbstate_t>::
+ codecvt_byname(const char* /*__s*/, size_t __refs)
+ : codecvt<wchar_t, char, mbstate_t> (__refs) { }
+
+ codecvt_byname<wchar_t, char, mbstate_t>::
+ ~codecvt_byname() { }
+#endif // _GLIBCPP_USE_WCHAR_T
+
+} // namespace std
+
+
diff --git a/libstdc++-v3/src/locale-inst.cc b/libstdc++-v3/src/locale-inst.cc
index 81fb209..a313aaf 100644
--- a/libstdc++-v3/src/locale-inst.cc
+++ b/libstdc++-v3/src/locale-inst.cc
@@ -126,14 +126,16 @@ namespace std {
template class _Ctype<char>;
template class _Ctype_nois<char>;
template class ctype_byname<char>;
- template class _Codecvt<char, char, mbstate_t>;
#ifdef _GLIBCPP_USE_WCHAR_T
template class _Ctype<wchar_t>;
template class _Ctype_nois<wchar_t>;
template class ctype_byname<wchar_t>;
- template class _Codecvt<wchar_t, char, mbstate_t>;
#endif
+ // codecvt
+ template class __codecvt_abstract_base<char, char, mbstate_t>;
+ template class __codecvt_abstract_base<wchar_t, char, mbstate_t>;
+
// collate
template class _Collate<char>;
template class collate_byname<char>;
@@ -174,9 +176,6 @@ namespace std {
const ctype<wchar_t>&
use_facet<ctype<wchar_t> >(const locale& __loc);
template
- const codecvt<wchar_t, wchar_t, mbstate_t>&
- use_facet<codecvt<wchar_t, wchar_t, mbstate_t> >(locale const &);
- template
const codecvt<wchar_t, char, mbstate_t>&
use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const &);
template
diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc
index 15dcf99..6ceaf12 100644
--- a/libstdc++-v3/src/locale.cc
+++ b/libstdc++-v3/src/locale.cc
@@ -501,82 +501,6 @@ namespace std {
: ctype<char>(new mask[table_size], true, __refs)
{ }
- locale::id codecvt<char, char, mbstate_t>::id;
-
- codecvt<char, char, mbstate_t>::
- codecvt(size_t __refs)
- : _Codecvt<char, char, mbstate_t>(__refs)
- { }
-
- codecvt<char, char, mbstate_t>::
- ~codecvt() { }
-
- codecvt_base::result
- codecvt<char, char, mbstate_t>::
- do_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) const
- {
- size_t __sizefrom = __from_end - __from;
- size_t __sizeto = __to_end - __to;
- size_t __length = __sizefrom <= __sizeto ? __sizefrom : __sizeto;
- memcpy(__to, __from, __length);
- __from_next = __from;
- __to_next = __to;
- return noconv;
- }
-
- codecvt_base::result
- codecvt<char, char, mbstate_t>::
- do_unshift(state_type& /*__state*/, extern_type* __to,
- extern_type* /*__to_limit*/, extern_type*& __to_next) const
- {
- __to_next = __to;
- return noconv;
- }
-
- codecvt_base::result
- codecvt<char, char, mbstate_t>::
- do_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) const
- {
- size_t __sizefrom = __from_end - __from;
- size_t __sizeto = __to_end - __to;
- size_t __length = __sizefrom <= __sizeto ? __sizefrom : __sizeto;
- memcpy(__to, __from, __length);
- __from_next = __from;
- __to_next = __to;
- return noconv;
- }
-
-
- int
- codecvt<char, char, mbstate_t>::
- do_encoding() const throw() { return 1; }
-
- bool
- codecvt<char, char, mbstate_t>::
- do_always_noconv() const throw() { return true; }
-
- int
- codecvt<char, char, mbstate_t>::
- do_length (const state_type& /*__state*/, const extern_type* __from,
- const extern_type* __end, size_t __max) const
- { return (__max < size_t(__end - __from)) ? __max : __end - __from; }
-
- int
- codecvt<char, char, mbstate_t>::
- do_max_length() const throw() { return 1; }
-
- codecvt_byname<char, char, mbstate_t>::
- codecvt_byname(const char* /*__s*/, size_t __refs)
- : codecvt<char, char, mbstate_t>(__refs) { }
-
- codecvt_byname<char, char, mbstate_t>::
- ~codecvt_byname() { }
locale::id collate<char>::id;
@@ -748,78 +672,6 @@ namespace std {
ctype_byname(const char* /*__s*/, size_t __refs)
: ctype<wchar_t>(__refs) { }
- locale::id codecvt<wchar_t, char, mbstate_t>::id;
-
- codecvt<wchar_t, char, mbstate_t>::
- codecvt(size_t __refs)
- : _Codecvt<wchar_t, char, mbstate_t>(__refs) { }
-
- codecvt<wchar_t, char, mbstate_t>::
- ~codecvt() { }
-
- codecvt_base::result
- codecvt<wchar_t, char, mbstate_t>::
- do_out(state_type& /*__state*/, 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) const
- {
- for (; __from < __from_end && __to < __to_limit; ++__from, ++__to)
- *__to = static_cast<char>(*__from);
- __from_next = __from; __to_next = __to;
- return __from == __from_end ? ok : partial;
- }
-
- codecvt_base::result
- codecvt<wchar_t, char, mbstate_t>::
- do_unshift (state_type& /*__state*/, extern_type* __to,
- extern_type* /*__to_limit*/, extern_type*& __to_next) const
- {
- __to_next = __to;
- return noconv;
- }
-
- codecvt_base::result
- codecvt<wchar_t, char, mbstate_t>::
- do_in(state_type& /*__state*/, 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) const
- {
- for (; __from < __from_end && __to < __to_limit; ++__from, ++__to)
- *__to = static_cast<wchar_t>(*__from);
- __from_next = __from;
- __to_next = __to;
- return __from == __from_end ? ok : partial;
- }
-
- int
- codecvt<wchar_t, char, mbstate_t>::
- do_encoding() const throw()
- { return 1; }
-
- bool
- codecvt<wchar_t, char, mbstate_t>::
- do_always_noconv() const throw()
- { return false; }
-
- int
- codecvt<wchar_t, char, mbstate_t>::
- do_length(const state_type& /*__state*/, const extern_type* __from,
- const extern_type* __end, size_t __max) const
- { return (__max < size_t(__end - __from)) ? __max : __end - __from; }
-
- int
- codecvt<wchar_t, char, mbstate_t>::do_max_length() const throw()
- { return 1; }
-
- codecvt_byname<wchar_t, char, mbstate_t>::
- codecvt_byname(const char* /*__s*/, size_t __refs)
- : codecvt<wchar_t, char, mbstate_t> (__refs) { }
-
- codecvt_byname<wchar_t, char, mbstate_t>::
- ~codecvt_byname() { }
-
locale::id collate<wchar_t>::id;
collate<wchar_t>::