📄 _punct.h
字号:
unsigned long _C_parse_decimal (const char *__beg, const char *__end);
// parse a string of digits and interpret it as a floating point value
void _C_parse_float (const char *__end, const char *__fmt, void *__val);
};
inline char* __rw_digit_reader_base::_C_realloc ()
{
// compute offsets into buffer
_RWSTD_C::ptrdiff_t __frac_off = _C_frac_beg - _C_digits;
_RWSTD_C::ptrdiff_t __exp_off = _C_exp_beg - _C_digits;
char *__cur = _C_realloc (this->_C_digits, this->_C_buffer,
this->_C_bufsize);
// adjust pointers into buffer
if (_C_frac_beg)
_C_frac_beg = _C_digits + __frac_off;
if (_C_exp_beg)
_C_exp_beg = _C_digits + __exp_off;
return __cur;
}
// ------------------------------------------------------------------
// Implementation class template -- __rw_digit_reader_base_1<_CharT>.
// ------------------------------------------------------------------
// Contains parts of digit_reader that depend on _CharT but not on the iterator
// type.
template <class _CharT>
class __rw_digit_reader_base_1
: public __rw_digit_reader_base,
public __rw_digit_handler_base_1<_CharT>
{
public:
typedef _CharT char_type;
typedef _STD::char_traits<char_type> traits_type;
typedef _STD::basic_string<char_type, traits_type,
_STD::allocator<char_type> >
string_type;
protected:
// Constructor for general numerics, gets punct from loc's numpunct<_CharT>.
__rw_digit_reader_base_1 (const _STD::locale &__loc, int __radix = 0)
: __rw_digit_reader_base (__radix),
__rw_digit_handler_base_1<_CharT>(__loc) { }
// Constructor for use by derived __rw_money_reader, caller passes punct,
// which in fact is loc's moneypunct<_CharT, true|false> facet.
__rw_digit_reader_base_1 (const _STD::locale &__loc,
const __rw_punct_data<_CharT> &__mp)
: __rw_digit_handler_base_1<_CharT>(__loc, __mp) { }
};
// ---------------------------------------------------------------------
// Implementation class template -- digit_reader<_CharT, _InputIter>.
// ---------------------------------------------------------------------
// Facets that do numeric input use temporary objects of this class to
// extract keywords and strings of digits and punctuation from the input
// stream.
template <class _CharT, class _InputIter>
class __rw_digit_reader
: public __rw_digit_reader_base_1<_CharT>
{
public:
// Constructor for reading general numerics.
__rw_digit_reader (_InputIter &__first,
_InputIter &__last,
_STD::ios_base &__flags)
: __rw_digit_reader_base_1<_CharT> (__flags.getloc (),
__flags._C_base ()),
_C_io (__flags), _C_in (__first), _C_end (__last) { }
protected:
// Constructor for use by derived __rw_money_reader class.
__rw_digit_reader (_InputIter &__first, _InputIter &__last,
_STD::ios_base &__flags,
const __rw_punct_data<_CharT> &__mp)
: __rw_digit_reader_base_1<_CharT>(__flags.getloc (), __mp),
_C_io (__flags), _C_in (__first), _C_end (__last) { }
public:
char *_C_get_digits (int); // Get integer-format digits
// overloads provided for genericity
char *_C_get_digits (short) {
return _C_get_digits (0);
}
char *_C_get_digits (unsigned short) {
return _C_get_digits (0);
}
char *_C_get_digits (unsigned int) {
return _C_get_digits (0);
}
char *_C_get_digits (long) {
return _C_get_digits (0);
}
char *_C_get_digits (unsigned long) {
return _C_get_digits (0);
}
#ifdef _RWSTD_LONG_LONG
char *_C_get_digits (_RWSTD_LONG_LONG) {
return _C_get_digits (0);
}
char *_C_get_digits (unsigned _RWSTD_LONG_LONG) {
return _C_get_digits (0);
}
#endif // _RWSTD_LONG_LONG
char *_C_get_digits (double) __softfp; // Get floating point-format digits
// overloads provided for genericity
char *_C_get_digits (float) {
return _C_get_digits (0.0);
}
char *_C_get_digits (long double) {
return _C_get_digits (0.0);
}
char *_C_get_digits (void*) { // Get pointer-format digits
this->_C_base = 16;
return _C_get_digits (0);
}
// Parse keyword from input, return associated integer value
int _C_get_keyword (const __rw_keyword_map<_CharT>&);
bool eof () const {
return _C_in == _C_end;
}
protected:
_STD::ios_base &_C_io;
_InputIter &_C_in;
_InputIter &_C_end;
const char *_C_grouping;
_CharT thousands_sep;
char _C_groups[40];
char *_C_gpos;
// get a string of digits optionally discarding leading zeros
char *_C_get_digit_string (char*, bool = false);
char *_C_get_digit_groups (char*); // Get grouped digits (recursive)
};
_RWSTD_INSTANTIATE_3 (
class _RWSTD_EXPORT
__rw_digit_reader<char,
_STD::istreambuf_iterator<char, _STD::char_traits<char> > >
);
#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_INSTANTIATE_3 (
class _RWSTD_EXPORT
__rw_digit_reader<wchar_t,
_STD::istreambuf_iterator<wchar_t, _STD::char_traits<wchar_t> > >
);
#endif // _RWSTD_NO_WCHAR_T
// ------------------------------------------------
// Implementation class -- __rw_digit_writer_base.
// ------------------------------------------------
// Contains the parts of __rw_digit_writer that do not depend on the template
// parameters.
class _RWSTD_EXPORT __rw_digit_writer_base
: public __rw_digit_map_base
{
public:
__rw_digit_writer_base (_STD::ios_base&);
virtual ~__rw_digit_writer_base () {
if (_C_start != _C_buffer)
delete[] _C_start;
}
void _C_get_pattern (char*, const char*, bool);
bool _C_get_f_pattern(char*, char);
void _C_digitize (unsigned long, bool __is_signed, const char *__fmat);
void _C_digitize (const void *__val);
void _C_digitize (unsigned short __val) {
_C_digitize (_RWSTD_STATIC_CAST (unsigned long, __val), false, "h");
}
void _C_digitize (short __val) {
_C_digitize (_RWSTD_STATIC_CAST (unsigned long, __val), true, "h");
}
void _C_digitize (unsigned int __val) {
_C_digitize (_RWSTD_STATIC_CAST (unsigned long, __val), false, "");
}
void _C_digitize (int __val) {
_C_digitize (_RWSTD_STATIC_CAST (unsigned long, __val), true, "");
}
void _C_digitize (long __val) {
_C_digitize (_RWSTD_STATIC_CAST (unsigned long, __val), true, "l");
}
void _C_digitize (unsigned long __val) {
_C_digitize (_RWSTD_STATIC_CAST (unsigned long, __val), false, "l");
}
#ifdef _RWSTD_LONG_LONG
void _C_digitize (unsigned _RWSTD_LONG_LONG, bool = false);
void _C_digitize (_RWSTD_LONG_LONG __val) {
_C_digitize (_RWSTD_STATIC_CAST (unsigned _RWSTD_LONG_LONG, __val), !0);
}
// convert to a binary string
void _C_to_binary (unsigned _RWSTD_LONG_LONG);
#endif
void _C_digitize (double) __softfp;
#ifndef _RWSTD_NO_LONG_DOUBLE
void _C_digitize (long double) __softfp;
#endif
// convert to a binary string
void _C_to_binary (unsigned long);
_STD::ios_base &_C_io; // associated stream
_STD::ios_base::fmtflags _C_flags; // modified flags from _C_io
int _C_precision, _C_width, _C_base, _C_iprecision, _C_num_groups;
enum { _C_left, _C_internal, _C_right } _C_adjust;
bool _C_fractional, _C_separable;
char *_C_start, *_C_end, *_C_group;
enum { _C_DEF_BUFSIZE = 65 }; // large enough for a 64 bit int
char _C_buffer [_C_DEF_BUFSIZE ]; // default buffer
char _C_groups[150];
int _C_calc_groups (int, const char*);
};
inline
__rw_digit_writer_base::__rw_digit_writer_base (_STD::ios_base &__b)
: _C_io(__b), _C_flags(__b.flags()), _C_precision(int(__b.precision())),
_C_width(int(__b.width())), _C_iprecision(0), _C_num_groups(0),
_C_fractional(false), _C_separable(true), _C_start(_C_buffer),
_C_end(_C_buffer) {
_C_base = __b._C_base ();
switch (_C_flags & _STD::ios_base::adjustfield) {
case _STD::ios_base::left:
_C_adjust = _C_left;
break;
case _STD::ios_base::internal:
_C_adjust = _C_internal;
break;
default:
_C_adjust = _C_right;
break;
}
}
// ------------------------------------------------------------------
// Implementation class template -- __rw_digit_writer_base_1<_CharT>.
// ------------------------------------------------------------------
// Contains parts of __rw_digit_writer<_CharT, OutputWriter>
// that depend only on the _CharT parameter.
template <class _CharT>
class __rw_digit_writer_base_1
: public __rw_digit_writer_base,
public __rw_digit_handler_base_1<_CharT>
{
public:
typedef _STD::char_traits<_CharT> traits_type;
typedef _STD::basic_string<_CharT, traits_type, _STD::allocator<_CharT> >
string_type;
protected:
// Constructor for general numerics, gets punct from loc's numpunct<_CharT>.
__rw_digit_writer_base_1(ios_base &__b, const _STD::locale &__loc)
: __rw_digit_writer_base (__b), __rw_digit_handler_base_1<_CharT>(__loc)
{ }
// Constructor for money, passed punct is really a moneypunct<_CharT, Intl>.
__rw_digit_writer_base_1 (_STD::ios_base&, const __rw_punct_data<_CharT>&);
};
_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_digit_writer_base_1<char>);
#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_digit_writer_base_1<wchar_t>);
#endif // _RWSTD_NO_WCHAR_T
// --------------------------------------------------------------------------
// Implementation class template -- __rw_digit_writer<_CharT, _OutputIter>.
// --------------------------------------------------------------------------
// Facets that do numeric output use temporary objects of this type (on the
// stack) to convert numeric quantities into sequences of digits and other
// punctuation.
template <class _CharT, class _OutputIter>
class __rw_digit_writer
: public __rw_digit_writer_base_1<_CharT>
{
public:
typedef _STD::char_traits<_CharT> traits_type;
typedef _STD::basic_string<_CharT, traits_type, _STD::allocator<_CharT> >
string_type;
// Constructor for general numerics.
__rw_digit_writer (_OutputIter& __it, _STD::ios_base& __flags)
: __rw_digit_writer_base_1<_CharT>(__flags, __flags.getloc ()),
_C_out (__it) { }
protected:
// Constructor for use by derived __rw_money_writer classes,
// passed __rw_punct_data is really a moneypunct<_CharT, Intl> facet.
__rw_digit_writer (_OutputIter &__it, _STD::ios_base &__flags,
const __rw_punct_data<_CharT> &__mp)
: __rw_digit_writer_base_1<_CharT>(__flags, __mp), _C_out (__it)
{ }
public:
void _C_put_digits (_CharT);
void _C_put_keyword (const string_type&, _CharT);
protected:
_OutputIter &_C_out;
};
_RWSTD_INSTANTIATE_3 (
class _RWSTD_EXPORT
__rw_digit_writer<char,
_STD::ostreambuf_iterator<char, _STD::char_traits<char> > >
);
#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_INSTANTIATE_3 (
class _RWSTD_EXPORT
__rw_digit_writer<wchar_t,
_STD::ostreambuf_iterator<wchar_t, _STD::char_traits<wchar_t> > >
);
#endif // _RWSTD_NO_WCHAR_T
_RWSTD_NAMESPACE_END // __rw
#if _RWSTD_DEFINE_TEMPLATE (PUNCT)
# include <rw/_punct.cc>
#endif
#endif // _RWSTD_PUNCT_H_INCLUDED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -