template<typename _Tv>
void
__convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
- const __c_locale& __cloc, int __base = 10);
+ const __c_locale& __cloc);
// Explicit specializations for required types.
template<>
void
- __convert_to_v(const char*, long&, ios_base::iostate&,
- const __c_locale&, int);
-
- template<>
- void
- __convert_to_v(const char*, unsigned long&, ios_base::iostate&,
- const __c_locale&, int);
-
-#ifdef _GLIBCXX_USE_LONG_LONG
- template<>
- void
- __convert_to_v(const char*, long long&, ios_base::iostate&,
- const __c_locale&, int);
-
- template<>
- void
- __convert_to_v(const char*, unsigned long long&, ios_base::iostate&,
- const __c_locale&, int);
-#endif
-
- template<>
- void
__convert_to_v(const char*, float&, ios_base::iostate&,
- const __c_locale&, int);
+ const __c_locale&);
template<>
void
__convert_to_v(const char*, double&, ios_base::iostate&,
- const __c_locale&, int);
+ const __c_locale&);
- template<>
+ template<>
void
__convert_to_v(const char*, long double&, ios_base::iostate&,
- const __c_locale&, int);
+ const __c_locale&);
// NB: __pad is a struct, rather than a function, so it can be
// partially-specialized.
template<typename _CharT>
bool
__verify_grouping(const basic_string<_CharT>& __grouping,
- basic_string<_CharT>& __grouping_tmp);
+ const basic_string<_CharT>& __grouping_tmp);
// Used by both numeric and monetary facets.
// Inserts "group separator" characters into an array of characters.
protected:
explicit
- __ctype_abstract_base(size_t __refs = 0): locale::facet(__refs) { }
+ __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
virtual
~__ctype_abstract_base() { }
// 22.2.1.3 ctype<char> specialization.
template<>
- class ctype<char> : public __ctype_abstract_base<char>
+ class ctype<char> : public locale::facet, public ctype_base
{
public:
// Types:
inline const char*
scan_not(mask __m, const char* __lo, const char* __hi) const;
+ char_type
+ toupper(char_type __c) const
+ { return this->do_toupper(__c); }
+
+ const char_type*
+ toupper(char_type *__lo, const char_type* __hi) const
+ { return this->do_toupper(__lo, __hi); }
+
+ char_type
+ tolower(char_type __c) const
+ { return this->do_tolower(__c); }
+
+ const char_type*
+ tolower(char_type* __lo, const char_type* __hi) const
+ { return this->do_tolower(__lo, __hi); }
+
+ char_type
+ widen(char __c) const
+ { return this->do_widen(__c); }
+
+ const char*
+ widen(const char* __lo, const char* __hi, char_type* __to) const
+ { return this->do_widen(__lo, __hi, __to); }
+
+ char
+ narrow(char_type __c, char __dfault) const
+ { return this->do_narrow(__c, __dfault); }
+
+ const char_type*
+ narrow(const char_type* __lo, const char_type* __hi,
+ char __dfault, char *__to) const
+ { return this->do_narrow(__lo, __hi, __dfault, __to); }
+
protected:
const mask*
table() const throw()
virtual
~ctype();
- virtual bool
- do_is(mask __m, char_type __c) const;
-
- virtual const char_type*
- do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
-
- virtual const char_type*
- do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
-
- virtual const char_type*
- do_scan_not(mask __m, const char_type* __lo,
- const char_type* __hi) const;
-
virtual char_type
do_toupper(char_type) const;
do_tolower(char_type* __lo, const char_type* __hi) const;
virtual char_type
- do_widen(char) const;
+ do_widen(char __c) const
+ { return __c; }
virtual const char*
- do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
+ do_widen(const char* __lo, const char* __hi, char_type* __dest) const
+ {
+ memcpy(__dest, __lo, __hi - __lo);
+ return __hi;
+ }
virtual char
- do_narrow(char_type, char __dfault) const;
+ do_narrow(char_type __c, char) const
+ { return __c; }
virtual const char_type*
do_narrow(const char_type* __lo, const char_type* __hi,
- char __dfault, char* __dest) const;
+ char, char* __dest) const
+ {
+ memcpy(__dest, __lo, __hi - __lo);
+ return __hi;
+ }
};
template<>
protected:
__c_locale _M_c_locale_ctype;
+ // Pre-computed narrowed and widened chars in the range 0-127.
+ bool _M_narrow_ok;
+ char _M_narrow[128];
+ wint_t _M_widen[128];
+
public:
// Data Members:
static locale::id id;
do_narrow(const char_type* __lo, const char_type* __hi,
char __dfault, char* __dest) const;
+ // For use at construction time only.
+ void
+ _M_initialize_ctype();
};
template<>
static const char* _S_atoms_out;
// String literal of acceptable (narrow) input, for num_get.
- // "0123456789eEabcdfABCDF"
+ // "-+xX0123456789abcdefABCDEF"
static const char* _S_atoms_in;
enum
{
+ _S_iminus,
+ _S_iplus,
+ _S_ix,
+ _S_iX,
_S_izero,
- _S_ie = _S_izero + 10,
- _S_iE = _S_izero + 11,
- _S_iend = 21 + 1
+ _S_ie = _S_izero + 14,
+ _S_iE = _S_izero + 20,
+ _S_iend = 26
};
// num_put
template<typename _CharT>
struct __numpunct_cache : public locale::facet
{
- // Types:
- typedef _CharT char_type;
-
const char* _M_grouping;
bool _M_use_grouping;
- const char_type* _M_truename;
- const char_type* _M_falsename;
- char_type _M_decimal_point;
- char_type _M_thousands_sep;
+ const _CharT* _M_truename;
+ const _CharT* _M_falsename;
+ _CharT _M_decimal_point;
+ _CharT _M_thousands_sep;
// A list of valid numeric literals for output: in the standard
// "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_out[__num_base::_S_oend + 1];
- // A list of valid numeric literals for output: in the standard
- // "C" locale, this is "0123456789eEabcdfABCDF"
+ // A list of valid numeric literals for input: in the standard
+ // "C" locale, this is "-+xX0123456789abcdefABCDEF"
// This array contains the chars after having been passed
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_in[__num_base::_S_iend + 1];
bool _M_allocated;
- __numpunct_cache(size_t __refs = 0) : locale::facet(__refs),
+ __numpunct_cache(size_t __refs = 0) : facet(__refs),
_M_grouping(NULL), _M_use_grouping(false), _M_truename(NULL),
- _M_falsename(NULL), _M_decimal_point(char_type()),
- _M_thousands_sep(char_type()), _M_allocated(false)
+ _M_falsename(NULL), _M_decimal_point(_CharT()),
+ _M_thousands_sep(_CharT()), _M_allocated(false)
{ }
~__numpunct_cache();
void
__numpunct_cache<_CharT>::_M_cache(const locale& __loc)
{
+ _M_allocated = true;
+
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
- string __grouping = __np.grouping();
- char* __group = new char[__grouping.length() + 1];
- __grouping.copy(__group, __grouping.length());
- __group[__grouping.length()] = _CharT();
- _M_grouping = __group;
-
- _M_use_grouping = __grouping.length() != 0 && __grouping.data()[0] != 0;
- typedef basic_string<_CharT> __string_type;
+ const string::size_type __len = __np.grouping().size();
+ char* __grouping = new char[__len + 1];
+ __np.grouping().copy(__grouping, __len);
+ __grouping[__len] = char();
+ _M_grouping = __grouping;
+ _M_use_grouping = __len && __np.grouping()[0] != 0;
- __string_type __true = __np.truename();
- _CharT* __truename = new _CharT[__true.length() + 1];
- __true.copy(__truename, __true.length());
- __truename[__true.length()] = _CharT();
+ typedef basic_string<_CharT> __string_type;
+ typename __string_type::size_type __lentf = __np.truename().size();
+ _CharT* __truename = new _CharT[__lentf + 1];
+ __np.truename().copy(__truename, __lentf);
+ __truename[__lentf] = _CharT();
_M_truename = __truename;
-
- __string_type __false = __np.falsename();
- _CharT* __falsename = new _CharT[__false.length() + 1];
- __false.copy(__falsename, __false.length());
- __falsename[__false.length()] = _CharT();
+
+ __lentf = __np.falsename().size();
+ _CharT* __falsename = new _CharT[__lentf + 1];
+ __np.falsename().copy(__falsename, __lentf);
+ __falsename[__lentf] = _CharT();
_M_falsename = __falsename;
-
+
_M_decimal_point = __np.decimal_point();
_M_thousands_sep = __np.thousands_sep();
-
+
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
__ct.widen(__num_base::_S_atoms_out,
__num_base::_S_atoms_out + __num_base::_S_oend, _M_atoms_out);
__ct.widen(__num_base::_S_atoms_in,
__num_base::_S_atoms_in + __num_base::_S_iend, _M_atoms_in);
_M_atoms_in[__num_base::_S_iend] = _CharT();
-
- _M_allocated = true;
}
template<typename _CharT>
explicit
numpunct(__c_locale __cloc, size_t __refs = 0)
- : locale::facet(__refs), _M_data(NULL)
+ : facet(__refs), _M_data(NULL)
{ _M_initialize_numpunct(__cloc); }
char_type
template<typename _CharT>
class numpunct_byname : public numpunct<_CharT>
{
- // Data Member.
- __c_locale _M_c_locale_numpunct;
-
public:
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
numpunct_byname(const char* __s, size_t __refs = 0)
: numpunct<_CharT>(__refs)
{
- _S_create_c_locale(_M_c_locale_numpunct, __s);
- _M_initialize_numpunct(_M_c_locale_numpunct);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ __c_locale __tmp;
+ this->_S_create_c_locale(__tmp, __s);
+ this->_M_initialize_numpunct(__tmp);
+ this->_S_destroy_c_locale(__tmp);
+ }
}
protected:
virtual
- ~numpunct_byname()
- { _S_destroy_c_locale(_M_c_locale_numpunct); }
+ ~numpunct_byname() { }
};
template<typename _CharT, typename _InIter>
static locale::id id;
explicit
- num_get(size_t __refs = 0) : locale::facet(__refs) { }
+ num_get(size_t __refs = 0) : facet(__refs) { }
iter_type
get(iter_type __in, iter_type __end, ios_base& __io,
_M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
string& __xtrc) const;
- iter_type
- _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
- string& __xtrc, int& __base) const;
+ template<typename _ValueT>
+ iter_type
+ _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ _ValueT& __v) const;
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
template<typename _CharT, typename _InIter>
locale::id num_get<_CharT, _InIter>::id;
-#if 0
- // Partial specialization for istreambuf_iterator, so can use traits_type.
- template<typename _CharT>
- class num_get<_CharT, istreambuf_iterator<_CharT> >;
-
- iter_type
- _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
- string& __xtrc) const;
-
- iter_type
- _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
- string& __xtrc, int& __base) const;
-
- virtual iter_type
- do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
-#endif
template<typename _CharT, typename _OutIter>
class num_put : public locale::facet, public __num_base
static locale::id id;
explicit
- num_put(size_t __refs = 0) : locale::facet(__refs) { }
+ num_put(size_t __refs = 0) : facet(__refs) { }
iter_type
put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
protected:
template<typename _ValueT>
iter_type
- _M_convert_float(iter_type, ios_base& __io, char_type __fill,
- char __mod, _ValueT __v) const;
+ _M_insert_float(iter_type, ios_base& __io, char_type __fill,
+ char __mod, _ValueT __v) const;
void
_M_group_float(const string& __grouping, char_type __sep,
template<typename _ValueT>
iter_type
- _M_convert_int(iter_type, ios_base& __io, char_type __fill,
- _ValueT __v) const;
+ _M_insert_int(iter_type, ios_base& __io, char_type __fill,
+ _ValueT __v) const;
void
_M_group_int(const string& __grouping, char_type __sep,
explicit
collate(size_t __refs = 0)
- : locale::facet(__refs)
- { _M_c_locale_collate = _S_c_locale; }
+ : facet(__refs)
+ { _M_c_locale_collate = _S_get_c_locale(); }
explicit
collate(__c_locale __cloc, size_t __refs = 0)
- : locale::facet(__refs)
+ : facet(__refs)
{ _M_c_locale_collate = _S_clone_c_locale(__cloc); }
int
collate_byname(const char* __s, size_t __refs = 0)
: collate<_CharT>(__refs)
{
- _S_destroy_c_locale(this->_M_c_locale_collate);
- _S_create_c_locale(this->_M_c_locale_collate, __s);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ this->_S_destroy_c_locale(this->_M_c_locale_collate);
+ this->_S_create_c_locale(this->_M_c_locale_collate, __s);
+ }
}
protected:
};
template<typename _CharT>
- class __timepunct : public locale::facet
+ struct __timepunct_cache : public locale::facet
{
- public:
- // Types:
- typedef _CharT __char_type;
- typedef basic_string<_CharT> __string_type;
-
- static locale::id id;
-
// List of all known timezones, with GMT first.
static const _CharT* _S_timezones[14];
- protected:
- __c_locale _M_c_locale_timepunct;
- char* _M_name_timepunct;
const _CharT* _M_date_format;
const _CharT* _M_date_era_format;
const _CharT* _M_time_format;
const _CharT* _M_day7;
// Abbreviated day names, starting with "C"'s Sun.
- const _CharT* _M_day_a1;
- const _CharT* _M_day_a2;
- const _CharT* _M_day_a3;
- const _CharT* _M_day_a4;
- const _CharT* _M_day_a5;
- const _CharT* _M_day_a6;
- const _CharT* _M_day_a7;
+ const _CharT* _M_aday1;
+ const _CharT* _M_aday2;
+ const _CharT* _M_aday3;
+ const _CharT* _M_aday4;
+ const _CharT* _M_aday5;
+ const _CharT* _M_aday6;
+ const _CharT* _M_aday7;
// Month names, starting with "C"'s January.
const _CharT* _M_month01;
const _CharT* _M_month12;
// Abbreviated month names, starting with "C"'s Jan.
- const _CharT* _M_month_a01;
- const _CharT* _M_month_a02;
- const _CharT* _M_month_a03;
- const _CharT* _M_month_a04;
- const _CharT* _M_month_a05;
- const _CharT* _M_month_a06;
- const _CharT* _M_month_a07;
- const _CharT* _M_month_a08;
- const _CharT* _M_month_a09;
- const _CharT* _M_month_a10;
- const _CharT* _M_month_a11;
- const _CharT* _M_month_a12;
+ const _CharT* _M_amonth01;
+ const _CharT* _M_amonth02;
+ const _CharT* _M_amonth03;
+ const _CharT* _M_amonth04;
+ const _CharT* _M_amonth05;
+ const _CharT* _M_amonth06;
+ const _CharT* _M_amonth07;
+ const _CharT* _M_amonth08;
+ const _CharT* _M_amonth09;
+ const _CharT* _M_amonth10;
+ const _CharT* _M_amonth11;
+ const _CharT* _M_amonth12;
+
+ bool _M_allocated;
+
+ __timepunct_cache(size_t __refs = 0) : facet(__refs),
+ _M_date_format(NULL), _M_date_era_format(NULL), _M_time_format(NULL),
+ _M_time_era_format(NULL), _M_date_time_format(NULL),
+ _M_date_time_era_format(NULL), _M_am(NULL), _M_pm(NULL),
+ _M_am_pm_format(NULL), _M_day1(NULL), _M_day2(NULL), _M_day3(NULL),
+ _M_day4(NULL), _M_day5(NULL), _M_day6(NULL), _M_day7(NULL),
+ _M_aday1(NULL), _M_aday2(NULL), _M_aday3(NULL), _M_aday4(NULL),
+ _M_aday5(NULL), _M_aday6(NULL), _M_aday7(NULL), _M_month01(NULL),
+ _M_month02(NULL), _M_month03(NULL), _M_month04(NULL), _M_month05(NULL),
+ _M_month06(NULL), _M_month07(NULL), _M_month08(NULL), _M_month09(NULL),
+ _M_month10(NULL), _M_month11(NULL), _M_month12(NULL), _M_amonth01(NULL),
+ _M_amonth02(NULL), _M_amonth03(NULL), _M_amonth04(NULL),
+ _M_amonth05(NULL), _M_amonth06(NULL), _M_amonth07(NULL),
+ _M_amonth08(NULL), _M_amonth09(NULL), _M_amonth10(NULL),
+ _M_amonth11(NULL), _M_amonth12(NULL), _M_allocated(false)
+ { }
+
+ ~__timepunct_cache();
+
+ void
+ _M_cache(const locale& __loc);
+ };
+
+ template<typename _CharT>
+ __timepunct_cache<_CharT>::~__timepunct_cache()
+ {
+ if (_M_allocated)
+ {
+ // XXX.
+ }
+ }
+
+ // Specializations.
+ template<>
+ const char*
+ __timepunct_cache<char>::_S_timezones[14];
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template<>
+ const wchar_t*
+ __timepunct_cache<wchar_t>::_S_timezones[14];
+#endif
+
+ // Generic.
+ template<typename _CharT>
+ const _CharT* __timepunct_cache<_CharT>::_S_timezones[14];
+
+ template<typename _CharT>
+ class __timepunct : public locale::facet
+ {
+ public:
+ // Types:
+ typedef _CharT __char_type;
+ typedef basic_string<_CharT> __string_type;
+ typedef __timepunct_cache<_CharT> __cache_type;
+
+ protected:
+ __cache_type* _M_data;
+ __c_locale _M_c_locale_timepunct;
+ const char* _M_name_timepunct;
public:
+ static locale::id id;
+
explicit
__timepunct(size_t __refs = 0);
explicit
+ __timepunct(__cache_type* __cache, size_t __refs = 0);
+
+ explicit
__timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0);
void
_M_date_formats(const _CharT** __date) const
{
// Always have default first.
- __date[0] = _M_date_format;
- __date[1] = _M_date_era_format;
+ __date[0] = _M_data->_M_date_format;
+ __date[1] = _M_data->_M_date_era_format;
}
void
_M_time_formats(const _CharT** __time) const
{
// Always have default first.
- __time[0] = _M_time_format;
- __time[1] = _M_time_era_format;
+ __time[0] = _M_data->_M_time_format;
+ __time[1] = _M_data->_M_time_era_format;
}
void
_M_ampm(const _CharT** __ampm) const
{
- __ampm[0] = _M_am;
- __ampm[1] = _M_pm;
+ __ampm[0] = _M_data->_M_am;
+ __ampm[1] = _M_data->_M_pm;
}
void
_M_date_time_formats(const _CharT** __dt) const
{
// Always have default first.
- __dt[0] = _M_date_time_format;
- __dt[1] = _M_date_time_era_format;
+ __dt[0] = _M_data->_M_date_time_format;
+ __dt[1] = _M_data->_M_date_time_era_format;
}
void
_M_days(const _CharT** __days) const
{
- __days[0] = _M_day1;
- __days[1] = _M_day2;
- __days[2] = _M_day3;
- __days[3] = _M_day4;
- __days[4] = _M_day5;
- __days[5] = _M_day6;
- __days[6] = _M_day7;
+ __days[0] = _M_data->_M_day1;
+ __days[1] = _M_data->_M_day2;
+ __days[2] = _M_data->_M_day3;
+ __days[3] = _M_data->_M_day4;
+ __days[4] = _M_data->_M_day5;
+ __days[5] = _M_data->_M_day6;
+ __days[6] = _M_data->_M_day7;
}
void
_M_days_abbreviated(const _CharT** __days) const
{
- __days[0] = _M_day_a1;
- __days[1] = _M_day_a2;
- __days[2] = _M_day_a3;
- __days[3] = _M_day_a4;
- __days[4] = _M_day_a5;
- __days[5] = _M_day_a6;
- __days[6] = _M_day_a7;
+ __days[0] = _M_data->_M_aday1;
+ __days[1] = _M_data->_M_aday2;
+ __days[2] = _M_data->_M_aday3;
+ __days[3] = _M_data->_M_aday4;
+ __days[4] = _M_data->_M_aday5;
+ __days[5] = _M_data->_M_aday6;
+ __days[6] = _M_data->_M_aday7;
}
void
_M_months(const _CharT** __months) const
{
- __months[0] = _M_month01;
- __months[1] = _M_month02;
- __months[2] = _M_month03;
- __months[3] = _M_month04;
- __months[4] = _M_month05;
- __months[5] = _M_month06;
- __months[6] = _M_month07;
- __months[7] = _M_month08;
- __months[8] = _M_month09;
- __months[9] = _M_month10;
- __months[10] = _M_month11;
- __months[11] = _M_month12;
+ __months[0] = _M_data->_M_month01;
+ __months[1] = _M_data->_M_month02;
+ __months[2] = _M_data->_M_month03;
+ __months[3] = _M_data->_M_month04;
+ __months[4] = _M_data->_M_month05;
+ __months[5] = _M_data->_M_month06;
+ __months[6] = _M_data->_M_month07;
+ __months[7] = _M_data->_M_month08;
+ __months[8] = _M_data->_M_month09;
+ __months[9] = _M_data->_M_month10;
+ __months[10] = _M_data->_M_month11;
+ __months[11] = _M_data->_M_month12;
}
void
_M_months_abbreviated(const _CharT** __months) const
{
- __months[0] = _M_month_a01;
- __months[1] = _M_month_a02;
- __months[2] = _M_month_a03;
- __months[3] = _M_month_a04;
- __months[4] = _M_month_a05;
- __months[5] = _M_month_a06;
- __months[6] = _M_month_a07;
- __months[7] = _M_month_a08;
- __months[8] = _M_month_a09;
- __months[9] = _M_month_a10;
- __months[10] = _M_month_a11;
- __months[11] = _M_month_a12;
+ __months[0] = _M_data->_M_amonth01;
+ __months[1] = _M_data->_M_amonth02;
+ __months[2] = _M_data->_M_amonth03;
+ __months[3] = _M_data->_M_amonth04;
+ __months[4] = _M_data->_M_amonth05;
+ __months[5] = _M_data->_M_amonth06;
+ __months[6] = _M_data->_M_amonth07;
+ __months[7] = _M_data->_M_amonth08;
+ __months[8] = _M_data->_M_amonth09;
+ __months[9] = _M_data->_M_amonth10;
+ __months[10] = _M_data->_M_amonth11;
+ __months[11] = _M_data->_M_amonth12;
}
protected:
// Specializations.
template<>
- const char*
- __timepunct<char>::_S_timezones[14];
-
- template<>
void
__timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
- const wchar_t*
- __timepunct<wchar_t>::_S_timezones[14];
-
- template<>
void
__timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc);
const tm*) const;
#endif
- // Generic.
- template<typename _CharT>
- const _CharT* __timepunct<_CharT>::_S_timezones[14];
-
// Include host and configuration specific timepunct functions.
#include <bits/time_members.h>
explicit
time_get(size_t __refs = 0)
- : locale::facet (__refs) { }
+ : facet (__refs) { }
dateorder
date_order() const
void
_M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
const _CharT** __names, size_t __indexlen,
+ const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const;
// Extract on a component-by-component basis, via __format argument.
explicit
time_put(size_t __refs = 0)
- : locale::facet(__refs) { }
+ : facet(__refs) { }
iter_type
put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
typedef _OutIter iter_type;
explicit
- time_put_byname(const char* /*__s*/, size_t __refs = 0)
+ time_put_byname(const char*, size_t __refs = 0)
: time_put<_CharT, _OutIter>(__refs)
{ };
_S_construct_pattern(char __precedes, char __space, char __posn);
};
+ template<typename _CharT>
+ struct __moneypunct_cache : public locale::facet
+ {
+ const char* _M_grouping;
+ bool _M_use_grouping;
+ _CharT _M_decimal_point;
+ _CharT _M_thousands_sep;
+ const _CharT* _M_curr_symbol;
+ const _CharT* _M_positive_sign;
+ const _CharT* _M_negative_sign;
+ int _M_frac_digits;
+ money_base::pattern _M_pos_format;
+ money_base::pattern _M_neg_format;
+
+ bool _M_allocated;
+
+ __moneypunct_cache(size_t __refs = 0) : facet(__refs),
+ _M_grouping(NULL), _M_use_grouping(false), _M_decimal_point(_CharT()),
+ _M_thousands_sep(_CharT()), _M_curr_symbol(NULL), _M_positive_sign(NULL),
+ _M_negative_sign(NULL), _M_frac_digits(0),
+ _M_pos_format(money_base::pattern()),
+ _M_neg_format(money_base::pattern()), _M_allocated(false)
+ { }
+
+ ~__moneypunct_cache();
+
+ void
+ _M_cache(const locale& __loc);
+ };
+
+ template<typename _CharT>
+ __moneypunct_cache<_CharT>::~__moneypunct_cache()
+ {
+ if (_M_allocated)
+ {
+ // XXX.
+ }
+ }
+
template<typename _CharT, bool _Intl>
class moneypunct : public locale::facet, public money_base
{
public:
// Types:
- typedef _CharT char_type;
+ typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
+ typedef __moneypunct_cache<_CharT> __cache_type;
+
+ private:
+ __cache_type* _M_data;
+ public:
static const bool intl = _Intl;
static locale::id id;
- private:
- const char* _M_grouping;
- char_type _M_decimal_point;
- char_type _M_thousands_sep;
- const char_type* _M_curr_symbol;
- const char_type* _M_positive_sign;
- const char_type* _M_negative_sign;
- int _M_frac_digits;
- pattern _M_pos_format;
- pattern _M_neg_format;
+ explicit
+ moneypunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)
+ { _M_initialize_moneypunct(); }
- public:
explicit
- moneypunct(size_t __refs = 0) : locale::facet(__refs)
+ moneypunct(__cache_type* __cache, size_t __refs = 0)
+ : facet(__refs), _M_data(__cache)
{ _M_initialize_moneypunct(); }
explicit
moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
- : locale::facet(__refs)
+ : facet(__refs), _M_data(NULL)
{ _M_initialize_moneypunct(__cloc, __s); }
char_type
virtual char_type
do_decimal_point() const
- { return _M_decimal_point; }
+ { return _M_data->_M_decimal_point; }
virtual char_type
do_thousands_sep() const
- { return _M_thousands_sep; }
+ { return _M_data->_M_thousands_sep; }
virtual string
do_grouping() const
- { return _M_grouping; }
+ { return _M_data->_M_grouping; }
virtual string_type
do_curr_symbol() const
- { return _M_curr_symbol; }
+ { return _M_data->_M_curr_symbol; }
virtual string_type
do_positive_sign() const
- { return _M_positive_sign; }
+ { return _M_data->_M_positive_sign; }
virtual string_type
do_negative_sign() const
- { return _M_negative_sign; }
+ { return _M_data->_M_negative_sign; }
virtual int
do_frac_digits() const
- { return _M_frac_digits; }
+ { return _M_data->_M_frac_digits; }
virtual pattern
do_pos_format() const
- { return _M_pos_format; }
+ { return _M_data->_M_pos_format; }
virtual pattern
do_neg_format() const
- { return _M_neg_format; }
+ { return _M_data->_M_neg_format; }
// For use at construction time only.
void
template<typename _CharT, bool _Intl>
class moneypunct_byname : public moneypunct<_CharT, _Intl>
{
- __c_locale _M_c_locale_moneypunct;
-
public:
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
moneypunct_byname(const char* __s, size_t __refs = 0)
: moneypunct<_CharT, _Intl>(__refs)
{
- _S_create_c_locale(_M_c_locale_moneypunct, __s);
- _M_initialize_moneypunct(_M_c_locale_moneypunct);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ __c_locale __tmp;
+ this->_S_create_c_locale(__tmp, __s);
+ this->_M_initialize_moneypunct(__tmp);
+ this->_S_destroy_c_locale(__tmp);
+ }
}
protected:
virtual
- ~moneypunct_byname()
- { _S_destroy_c_locale(_M_c_locale_moneypunct); }
+ ~moneypunct_byname() { }
};
template<typename _CharT, bool _Intl>
static locale::id id;
explicit
- money_get(size_t __refs = 0) : locale::facet(__refs) { }
+ money_get(size_t __refs = 0) : facet(__refs) { }
iter_type
get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
static locale::id id;
explicit
- money_put(size_t __refs = 0) : locale::facet(__refs) { }
+ money_put(size_t __refs = 0) : facet(__refs) { }
iter_type
put(iter_type __s, bool __intl, ios_base& __io,
// Underlying "C" library locale information saved from
// initialization, needed by messages_byname as well.
__c_locale _M_c_locale_messages;
- char* _M_name_messages;
+ const char* _M_name_messages;
public:
static locale::id id;