locale_facets.tcc: Formatting tweaks.

2000-08-10  Benjamin Kosnik  <bkoz@purist.soma.redhat.com>

        * bits/locale_facets.tcc: Formatting tweaks.
        * bits/locale_facets.h (__enc_traits): Start integrating this
        into codecvt, ctype. Formatting tweaks.

From-SVN: r35621
This commit is contained in:
Benjamin Kosnik 2000-08-11 07:32:37 +00:00 committed by Benjamin Kosnik
parent 4b48731a0d
commit 9c683c2adc
3 changed files with 67 additions and 23 deletions

View File

@ -1,3 +1,9 @@
2000-08-10 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* bits/locale_facets.tcc: Formatting tweaks.
* bits/locale_facets.h (__enc_traits): Start integrating this
into codecvt, ctype. Formatting tweaks.
2000-08-09 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
Preliminary wchar_t implementation, with trivial encodings.

View File

@ -84,24 +84,67 @@ namespace std
#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 codecvt and possibly
// ctype will use.
// 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 iconv_t __conv_type;
typedef _IntT __intc_type;
typedef _ExtT __extc_type;
typedef iconv_t __conv_type;
typedef mbstate_t __state_type;
// max size of charset encoding name
// Data Members:
// Max size of charset encoding name
static const int __max_size = 32;
// name of internal character set encoding.
// Name of internal character set encoding.
char __intc_enc[__max_size];
// name of external character set encoding.
// 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; }
@ -118,18 +161,13 @@ namespace std
_M_set_extc_enc(const char* __c)
{ strcpy(__extc_enc, __c); }
__enc_traits(const char* __int, const char* __ext)
{
// __intc_end = whatever we are using internally, which is
// almost alwyas UCS4 (linux) or UCS2 (microsoft, aix,
// whatever...)
// __extc_end = nl_langinfo(CODESET)
strcpy(__intc_enc, __int);
strcpy(__extc_enc, __ext);
}
protected:
__enc_traits();
// 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