Commit 63511623 by Benjamin Kosnik Committed by Benjamin Kosnik

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
parent fec1ce0a
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.
......
......@@ -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;
......
......@@ -36,6 +36,7 @@
#include <bits/localefwd.h>
#include <bits/locale_facets.h>
#include <bits/codecvt.h>
#endif
......
......@@ -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 = \
......
// 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
......@@ -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
......
......@@ -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>::
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment