/**
* @brief Narrow wchar_t to char
*
- * This virtual function converts the argument to char using the
- * simplest reasonable transformation. If the conversion fails, dfault
- * is returned instead. For an underived ctype<wchar_t> facet, @a c will
- * be cast to char and returned.
+ * This virtual function converts the argument to char using
+ * the simplest reasonable transformation. If the conversion
+ * fails, dfault is returned instead. For an underived
+ * ctype<wchar_t> facet, @a c will be cast to char and
+ * returned.
*
- * do_narrow() is a hook for a derived facet to change the behavior of
- * narrowing. do_narrow() must always return the same result for the
- * same input.
+ * do_narrow() is a hook for a derived facet to change the
+ * behavior of narrowing. do_narrow() must always return the
+ * same result for the same input.
*
* Note: this is not what you want for codepage conversions. See
* codecvt for that.
};
template<typename _CharT>
- void
- __numpunct_cache<_CharT>::_M_cache(const locale& __loc)
- {
- _M_allocated = true;
-
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
-
- _M_grouping_size = __np.grouping().size();
- char* __grouping = new char[_M_grouping_size];
- __np.grouping().copy(__grouping, _M_grouping_size);
- _M_grouping = __grouping;
- _M_use_grouping = _M_grouping_size && __np.grouping()[0] != 0;
-
- _M_truename_size = __np.truename().size();
- _CharT* __truename = new _CharT[_M_truename_size];
- __np.truename().copy(__truename, _M_truename_size);
- _M_truename = __truename;
-
- _M_falsename_size = __np.falsename().size();
- _CharT* __falsename = new _CharT[_M_falsename_size];
- __np.falsename().copy(__falsename, _M_falsename_size);
- _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);
- }
-
- template<typename _CharT>
__numpunct_cache<_CharT>::~__numpunct_cache()
{
if (_M_allocated)
/**
* @brief Return thousands separator character.
*
- * This function returns a char_type to use as a thousands separator. It
- * does so by returning returning
+ * This function returns a char_type to use as a thousands
+ * separator. It does so by returning returning
* numpunct<char_type>::do_thousands_sep().
*
* @return char_type representing a thousands separator.
* integer part of a number. Groupings indicate where thousands
* separators should be inserted in the integer part of a number.
*
- * Each char in the return string is interpret as an integer rather
- * than a character. These numbers represent the number of digits in a
- * group. The first char in the string represents the number of digits
- * in the least significant group. If a char is negative, it indicates
- * an unlimited number of digits for the group. If more chars from the
+ * Each char in the return string is interpret as an integer
+ * rather than a character. These numbers represent the number
+ * of digits in a group. The first char in the string
+ * represents the number of digits in the least significant
+ * group. If a char is negative, it indicates an unlimited
+ * number of digits for the group. If more chars from the
* string are required to group a number, the last char is used
* repeatedly.
*
- * For example, if the grouping() returns "\003\002" and is applied to
- * the number 123456789, this corresponds to 12,34,56,789. Note that
- * if the string was "32", this would put more than 50 digits into the
- * least significant group if the character set is ASCII.
+ * For example, if the grouping() returns "\003\002" and is
+ * applied to the number 123456789, this corresponds to
+ * 12,34,56,789. Note that if the string was "32", this would
+ * put more than 50 digits into the least significant group if
+ * the character set is ASCII.
*
* The string is returned by calling
* numpunct<char_type>::do_grouping().
* implement the behavior they require from the num_get facet.
*/
template<typename _CharT, typename _InIter>
- class num_get : public locale::facet, public __num_base
+ class num_get : public locale::facet
{
public:
// Types:
* Parses the input stream into the bool @a v. It does so by calling
* num_put::do_put().
*
- * If ios_base::boolalpha is set, attempts to read ctype<CharT>::truename() or
- * ctype<CharT>::falsename(). Sets @a v to true or false if
- * successful. Sets err to ios_base::failbit if reading the string
- * fails. Sets err to ios_base::eofbit if the stream is emptied.
+ * If ios_base::boolalpha is set, attempts to read
+ * ctype<CharT>::truename() or ctype<CharT>::falsename(). Sets
+ * @a v to true or false if successful. Sets err to
+ * ios_base::failbit if reading the string fails. Sets err to
+ * ios_base::eofbit if the stream is emptied.
*
* If ios_base::boolalpha is not set, proceeds as with reading a long,
* except if the value is 1, sets @a v to true, if the value is 0, sets
* implement the behavior they require from the num_put facet.
*/
template<typename _CharT, typename _OutIter>
- class num_put : public locale::facet, public __num_base
+ class num_put : public locale::facet
{
public:
// Types:
/**
* @brief Numeric formatting.
*
- * Formats the integral value @a v and inserts it into a stream. It does so
- * by calling num_put::do_put().
+ * Formats the integral value @a v and inserts it into a
+ * stream. It does so by calling num_put::do_put().
*
* Formatting is affected by the flag settings in @a io.
*
{
if (_M_allocated)
{
- // XXX.
+ // Unused.
}
}
}
void
- _M_ampm(const _CharT** __ampm) const
- {
- __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.
}
void
+ _M_am_pm_format(const _CharT* __ampm) const
+ { __ampm = _M_data->_M_am_pm_format; }
+
+ void
+ _M_am_pm(const _CharT** __ampm) const
+ {
+ __ampm[0] = _M_data->_M_am;
+ __ampm[1] = _M_data->_M_pm;
+ }
+
+ void
_M_days(const _CharT** __days) const
{
__days[0] = _M_data->_M_day1;
ios_base::iostate& __err, tm* __tm) const;
// Extract numeric component of length __len.
- void
- _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
+ iter_type
+ _M_extract_num(iter_type __beg, iter_type __end, int& __member,
int __min, int __max, size_t __len,
- const ctype<_CharT>& __ctype,
- ios_base::iostate& __err) const;
+ ios_base& __io, ios_base::iostate& __err) const;
// Extract day or month name, or any unique array of string
// literals in a const _CharT* array.
- void
- _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
+ iter_type
+ _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;
+ ios_base& __io, ios_base::iostate& __err) const;
// Extract on a component-by-component basis, via __format argument.
- void
- _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
+ iter_type
+ _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm,
const _CharT* __format) const;
};
* implement the behavior they require from the time_put facet.
*/
template<typename _CharT, typename _OutIter>
- class time_put : public locale::facet, public time_base
+ class time_put : public locale::facet
{
public:
// Types:
static const pattern _S_default_pattern;
+ enum
+ {
+ _S_minus,
+ _S_zero,
+ _S_end = 11
+ };
+
+ // String literal of acceptable (narrow) input/output, for
+ // money_get/money_put. "-0123456789"
+ static const char* _S_atoms;
+
// Construct and return valid pattern consisting of some combination of:
// space none symbol sign value
static pattern
_S_construct_pattern(char __precedes, char __space, char __posn);
};
- template<typename _CharT>
+ template<typename _CharT, bool _Intl>
struct __moneypunct_cache : public locale::facet
{
const char* _M_grouping;
+ size_t _M_grouping_size;
bool _M_use_grouping;
_CharT _M_decimal_point;
_CharT _M_thousands_sep;
const _CharT* _M_curr_symbol;
+ size_t _M_curr_symbol_size;
const _CharT* _M_positive_sign;
+ size_t _M_positive_sign_size;
const _CharT* _M_negative_sign;
+ size_t _M_negative_sign_size;
int _M_frac_digits;
money_base::pattern _M_pos_format;
money_base::pattern _M_neg_format;
+ // A list of valid numeric literals for input and output: in the standard
+ // "C" locale, this is "-0123456789". This array contains the chars after
+ // having been passed through the current locale's ctype<_CharT>.widen().
+ _CharT _M_atoms[money_base::_S_end];
+
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_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
+ _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()),
+ _M_curr_symbol(NULL), _M_curr_symbol_size(0),
+ _M_positive_sign(NULL), _M_positive_sign_size(0),
+ _M_negative_sign(NULL), _M_negative_sign_size(0),
+ _M_frac_digits(0),
_M_pos_format(money_base::pattern()),
_M_neg_format(money_base::pattern()), _M_allocated(false)
{ }
_M_cache(const locale& __loc);
};
- template<typename _CharT>
- __moneypunct_cache<_CharT>::~__moneypunct_cache()
+ template<typename _CharT, bool _Intl>
+ __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache()
{
if (_M_allocated)
{
- // XXX.
+ delete [] _M_grouping;
+ delete [] _M_curr_symbol;
+ delete [] _M_positive_sign;
+ delete [] _M_negative_sign;
}
}
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
//@}
- typedef __moneypunct_cache<_CharT> __cache_type;
+ typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
private:
__cache_type* _M_data;
/**
* @brief Return thousands separator character.
*
- * This function returns a char_type to use as a thousands separator. It
- * does so by returning returning
+ * This function returns a char_type to use as a thousands
+ * separator. It does so by returning returning
* moneypunct<char_type>::do_thousands_sep().
*
* @return char_type representing a thousands separator.
do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __digits) const;
- iter_type
- _M_extract(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
- ios_base::iostate& __err, string_type& __digits) const;
+ template<bool _Intl>
+ iter_type
+ _M_extract(iter_type __s, iter_type __end, ios_base& __io,
+ ios_base::iostate& __err, string& __digits) const;
};
template<typename _CharT, typename _InIter>
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
const string_type& __digits) const;
- iter_type
- _M_insert(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
- const string_type& __digits) const;
+ template<bool _Intl>
+ iter_type
+ _M_insert(iter_type __s, ios_base& __io, char_type __fill,
+ const string_type& __digits) const;
};
template<typename _CharT, typename _OutIter>