STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | List of all members
money_get< _Elem, _InIt > Class Template Reference
Inheritance diagram for money_get< _Elem, _InIt >:
locale::facet _Facet_base

Public Types

typedef _Elem char_type
 
typedef _InIt iter_type
 
typedef basic_string< _Elem, char_traits< _Elem >, allocator< _Elem > > string_type
 

Public Member Functions

_InIt get (_InIt _First, _InIt _Last, bool _Intl, ios_base &_Iosbase, ios_base::iostate &_State, long double &_Val) const
 
_InIt get (_InIt _First, _InIt _Last, bool _Intl, ios_base &_Iosbase, ios_base::iostate &_State, string_type &_Val) const
 
 money_get (size_t _Refs=0)
 
 money_get (const _Locinfo &_Lobj, size_t _Refs=0)
 
- Public Member Functions inherited from locale::facet
virtual void __CLR_OR_THIS_CALL _Incref ()
 
virtual _Facet_base *__CLR_OR_THIS_CALL _Decref ()
 
__CLR_OR_THIS_CALL facet (const facet &)=delete
 
facet &__CLR_OR_THIS_CALL operator= (const facet &)=delete
 
- Public Member Functions inherited from _Facet_base
virtual __CLR_OR_THIS_CALL ~_Facet_base () _NOEXCEPT
 

Static Public Member Functions

static size_t _Getcat (const locale::facet **_Ppf=0, const locale *_Ploc=0)
 
- Static Public Member Functions inherited from locale::facet
static size_t __CLRCALL_OR_CDECL _Getcat (const facet **=0, const locale *=0)
 

Static Public Attributes

__PURE_APPDOMAIN_GLOBAL static _CRTIMP2_PURE locale::id id
 

Protected Member Functions

virtual __CLR_OR_THIS_CALL ~money_get () _NOEXCEPT
 
void _Init (const _Locinfo &)
 
virtual _InIt __CLR_OR_THIS_CALL do_get (_InIt _First, _InIt _Last, bool _Intl, ios_base &_Iosbase, ios_base::iostate &_State, long double &_Val) const
 
virtual _InIt __CLR_OR_THIS_CALL do_get (_InIt _First, _InIt _Last, bool _Intl, ios_base &_Iosbase, ios_base::iostate &_State, string_type &_Val) const
 
- Protected Member Functions inherited from locale::facet
__CLR_OR_THIS_CALL facet (size_t _Initrefs=0)
 
virtual __CLR_OR_THIS_CALL ~facet () _NOEXCEPT
 

Private Types

typedef moneypunct< _Elem, false_Mypunct0
 
typedef moneypunct< _Elem, true_Mypunct1
 

Private Member Functions

string _Getmfld (_InIt &_First, _InIt &_Last, bool _Intl, ios_base &_Iosbase, _Elem *_Atoms) const
 

Member Typedef Documentation

template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef moneypunct<_Elem, false> money_get< _Elem, _InIt >::_Mypunct0
private
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef moneypunct<_Elem, true> money_get< _Elem, _InIt >::_Mypunct1
private
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef _Elem money_get< _Elem, _InIt >::char_type
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef _InIt money_get< _Elem, _InIt >::iter_type
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> > money_get< _Elem, _InIt >::string_type

Constructor & Destructor Documentation

template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
money_get< _Elem, _InIt >::money_get ( size_t  _Refs = 0)
inlineexplicit
378  { // construct from current locale
379  _BEGIN_LOCINFO(_Lobj)
380  _Init(_Lobj);
381  _END_LOCINFO()
382  }
Definition: xlocale:102
_Atomic_counter_t _Refs
Definition: xlocale:157
void _Init(const _Locinfo &)
Definition: xlocmon:404
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
money_get< _Elem, _InIt >::money_get ( const _Locinfo _Lobj,
size_t  _Refs = 0 
)
inline
386  { // construct from specified locale
387  _Init(_Lobj);
388  }
Definition: xlocale:102
_Atomic_counter_t _Refs
Definition: xlocale:157
void _Init(const _Locinfo &)
Definition: xlocmon:404
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
virtual __CLR_OR_THIS_CALL money_get< _Elem, _InIt >::~money_get ( )
inlineprotectedvirtual
401  { // destroy the object
402  }

Member Function Documentation

template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
static size_t money_get< _Elem, _InIt >::_Getcat ( const locale::facet **  _Ppf = 0,
const locale _Ploc = 0 
)
inlinestatic
392  { // return locale category mask and construct standard facet
393  if (_Ppf != 0 && *_Ppf == 0)
395  _Locinfo(_Ploc->c_str()));
396  return (_X_MONETARY);
397  }
#define _NEW_CRT
Definition: xdebug:69
Definition: xlocinfo:54
const char * c_str() const
Definition: xlocale:460
Definition: xlocmon:348
#define _X_MONETARY
Definition: xlocinfo.h:40
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
string money_get< _Elem, _InIt >::_Getmfld ( _InIt &  _First,
_InIt &  _Last,
bool  _Intl,
ios_base _Iosbase,
_Elem *  _Atoms 
) const
inlineprivate
462  { // get monetary field from [_First, _Last) into string_type
463  _DEBUG_RANGE(_First, _Last);
464  const _Mpunct<_Elem> *_Ppunct_fac;
465  if (_Intl)
466  _Ppunct_fac =
467  &_USE(_Iosbase.getloc(), _Mypunct1); // international
468  else
469  _Ppunct_fac =
470  &_USE(_Iosbase.getloc(), _Mypunct0); // local
471 
472  bool _Bad = false, _Neg = false;
473  string_type _Sign;
474  const money_base::pattern _Pattern = _Ppunct_fac->neg_format();
475  string _Val;
476  size_t _Idx;
477  static const char _Src[] = {"0123456789-"};
478  const ctype<_Elem>& _Ctype_fac =
479  _USE(_Iosbase.getloc(), ctype<_Elem>);
480  _Ctype_fac.widen(&_Src[0], &_Src[sizeof (_Src) - 1], _Atoms);
481 
482  for (size_t _Off = 0; !_Bad && _Off < 4; ++_Off)
483  switch (_Pattern.field[_Off])
484  { // parse a format component
485  case money_base::symbol:
486  { // parse currency symbol
487  string_type _Symbol = _Ppunct_fac->curr_symbol();
489 
490  if (!(_Iosbase.flags() & ios_base::showbase)
491  && _First != _Last && *_First != *_Symbol.c_str())
492  _Symbol.erase(); // showbase ==> mandatory symbol
493  else if (_Off == 3 && _Sign.size() <= 1
494  && (_First == _Last || *_First != *_Symbol.c_str()))
495  _Symbol.erase(); // currency symbol optional at end
496 
497  for (_Source = _Symbol.begin();
498  _First != _Last && _Source != _Symbol.end()
499  && *_First == *_Source; ++_Source, ++_First)
500  ; // still matching currency symbol
501 
502  if (_Source != _Symbol.end())
503  _Bad = true; // currency symbol match failed
504  break;
505  }
506 
507  case money_base::sign: // parse sign
508  if (_First == _Last)
509  ; // assume no sign
510  else if (0 < (_Ppunct_fac->positive_sign()).size()
511  && _Ppunct_fac->positive_sign()[0] == *_First)
512  { // match positive sign
513  ++_First;
514  _Sign = _Ppunct_fac->positive_sign();
515  }
516  else if (0 < (_Ppunct_fac->negative_sign()).size()
517  && _Ppunct_fac->negative_sign()[0] == *_First)
518  { // match negative sign
519  ++_First;
520  _Sign = _Ppunct_fac->negative_sign();
521  _Neg = true;
522  }
523  else if (0 == (_Ppunct_fac->positive_sign()).size())
524  ;
525  else if (0 == (_Ppunct_fac->negative_sign()).size())
526  _Neg = true;
527  break; // sign match can't fail
528 
529  case money_base::value:
530  { // parse value field
531  int _Fracdigseen = 0;
532  int _Fracdigits = _Ppunct_fac->frac_digits();
533  const string _Grouping = _Ppunct_fac->grouping();
534  const _Elem _Kseparator = _Grouping.size() == 0
535  ? (_Elem)0 : _Ppunct_fac->thousands_sep();
536 
537  if (_Kseparator == (_Elem)0
538  || CHAR_MAX <= (unsigned char)*_Grouping.c_str())
539  for (; _First != _Last
540  && (_Idx = _Find_elem(_Atoms, *_First)) < 10;
541  ++_First)
542  _Val += _Src[_Idx]; // no grouping, just gather digits
543  else
544  { // grouping specified, gather digits and group sizes
545  string _Groups((size_t)1, '\0');
546  size_t _Group = 0;
547 
548  for (; _First != _Last; ++_First)
549  if ((_Idx = _Find_elem(_Atoms, *_First)) < 10)
550  { // got a digit, add to group size
551  _Val += _Src[_Idx];
552  if (_Groups[_Group] != CHAR_MAX)
553  ++_Groups[_Group];
554  }
555  else if (_Groups[_Group] == '\0'
556  || *_First != _Kseparator)
557  break; // not a group separator, done
558  else
559  { // add a new group to _Groups string
560  _Groups.append((size_t)1, '\0');
561  ++_Group;
562  }
563 
564  if (_Group == 0)
565  ; // no thousands separators seen
566  else if ('\0' < _Groups[_Group])
567  ++_Group; // add trailing group to group count
568  else
569  _Bad = true; // trailing separator, fail
570 
571  for (const char *_Pg = _Grouping.c_str();
572  !_Bad && 0 < _Group; )
573  if (*_Pg == CHAR_MAX)
574  break; // end of grouping constraints to check
575  else if ((0 < --_Group && *_Pg != _Groups[_Group])
576  || (0 == _Group && *_Pg < _Groups[_Group]))
577  _Bad = true; // bad group size, fail
578  else if ('\0' < _Pg[1])
579  ++_Pg; // group size okay, advance to next test
580  if (_Bad)
581  break; // bad grouping, give up
582  }
583 
584  const _Elem _Point = _Ppunct_fac->decimal_point();
585  if (_First != _Last
586  && _Point != (_Elem)0
587  && *_First == _Point)
588  { // seen decimal point, gather fraction digits
589  while (++_First != _Last
590  && _Fracdigseen < _Fracdigits
591  && (_Idx = _Find_elem(_Atoms, *_First)) < 10)
592  _Val += _Src[_Idx], ++_Fracdigseen;
593 
594  if (_Fracdigseen < _Fracdigits)
595  _Bad = true; // short fraction
596  }
597 
598  if (_Val.size() == 0)
599  _Bad = true; // fail if no elements parsed
600  else
601  for (; _Fracdigseen < _Fracdigits; ++_Fracdigseen)
602  _Val += '0'; // pad out fraction with zeros
603  break;
604  }
605 
606  case money_base::space:
607  case money_base::none:
608  { // parse optional space
609  if (_Off == 3)
610  break; // ignore space at end
611 
612  bool _Seen = false;
613 
614  for (; _First != _Last
615  && _Ctype_fac.is(ctype_base::space, *_First); ++_First)
616  _Seen = true; // skip any space
617  if (_Pattern.field[_Off] == money_base::space && !_Seen)
618  _Bad = true; // fail if no space seen
619  }
620  }
621 
622  if (!_Bad && 1 < _Sign.size())
623  { // match rest of sign string
625 
626  for (_Source = _Sign.begin(); ++_Source != _Sign.end()
627  && _First != _Last && *_First == *_Source; ++_First)
628  ;
629  if (_Source != _Sign.end())
630  _Bad = true; // rest of sign doesn't match, fail
631  }
632 
633  if (_Bad)
634  _Val.erase(); // bad input, return empty string
635  else if (_Neg)
636  _Val.insert((size_t)0, (size_t)1, '-'); // minus sign
637  return (_Val);
638  }
_Mybase::const_iterator const_iterator
Definition: xstring:714
moneypunct< _Elem, true > _Mypunct1
Definition: xlocmon:352
Definition: xlocmon:22
#define _DEBUG_RANGE(first, last)
Definition: xutility:467
bool __CLR_OR_THIS_CALL is(mask _Maskval, _Elem _Ch) const
Definition: xlocale:2119
#define _USE(loc, fac)
Definition: xlocale:555
moneypunct< _Elem, false > _Mypunct0
Definition: xlocmon:351
_END_C_LIB_DECL _STD_BEGIN size_t _Find_elem(_Elem *_Base, _Elem _Ch)
Definition: xlocnum:54
_In_ size_t _In_z_ const char * _Source
Definition: tchar.h:2379
const _Elem * c_str() const _NOEXCEPT
Definition: xstring:1737
locale __CLR_OR_THIS_CALL getloc() const
Definition: xiosbase:422
_In_ size_t _In_z_ const unsigned char * _Src
Definition: mbstring.h:95
Definition: xlocmon:22
fmtflags __CLR_OR_THIS_CALL flags() const
Definition: xiosbase:365
Definition: xlocale:2113
basic_string< _Elem, char_traits< _Elem >, allocator< _Elem > > string_type
Definition: xlocmon:358
iterator insert(const_iterator _Where, _XSTD initializer_list< _Elem > _Ilist)
Definition: xstring:977
Definition: xlocmon:22
Definition: xlocale:2095
static const _Fmtflags showbase
Definition: xiosbase:59
Definition: xlocmon:25
_Elem __CLR_OR_THIS_CALL widen(char _Byte) const
Definition: xlocale:2162
char field[4]
Definition: xlocmon:27
_Myt & erase(size_type _Off=0)
Definition: xstring:1333
#define CHAR_MAX
Definition: limits.h:29
size_type size() const _NOEXCEPT
Definition: xstring:1752
Definition: xlocmon:22
_Myt & append(_XSTD initializer_list< _Elem > _Ilist)
Definition: xstring:972
_FwdIt const _Ty _Val
Definition: algorithm:1938
Definition: xlocmon:22
_FwdIt _Last
Definition: algorithm:1936
Definition: xlocmon:38
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
void money_get< _Elem, _InIt >::_Init ( const _Locinfo )
inlineprotected
405  { // initialize from _Locinfo object
406  }
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
virtual _InIt __CLR_OR_THIS_CALL money_get< _Elem, _InIt >::do_get ( _InIt  _First,
_InIt  _Last,
bool  _Intl,
ios_base _Iosbase,
ios_base::iostate &  _State,
long double &  _Val 
) const
inlineprotectedvirtual
411  { // get long double from [_First, _Last) into _Val
412  _Elem _Atoms[sizeof ("0123456789-") - 1];
413  string _Str = _Getmfld(_First, _Last, _Intl, _Iosbase, _Atoms);
414 
415  if (_First == _Last)
416  _State |= ios_base::eofbit;
417  if (_Str.size() == 0)
418  _State |= ios_base::failbit; // _Getmfld failed
419  else
420  { // convert to long double
421  const char *_Eb = _Str.c_str();
422  char *_Ep;
423  int _Errno = 0;
424  const long double _Ans =
425  _CSTD _Stoldx(_Eb, &_Ep, 0, &_Errno); // convert
426 
427  if (_Ep == _Eb || _Errno != 0)
428  _State |= ios_base::failbit;
429  else
430  _Val = _Ans; // deliver value
431  }
432  return (_First);
433  }
static const _Iostate failbit
Definition: xiosbase:89
_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _Stoldx(const char *, _Out_opt_ _Deref_post_opt_valid_ char **, long, int *)
string _Getmfld(_InIt &_First, _InIt &_Last, bool _Intl, ios_base &_Iosbase, _Elem *_Atoms) const
Definition: xlocmon:460
#define _CSTD
Definition: yvals.h:559
_FwdIt const _Ty _Val
Definition: algorithm:1938
_FwdIt _Last
Definition: algorithm:1936
static const _Iostate eofbit
Definition: xiosbase:88
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
virtual _InIt __CLR_OR_THIS_CALL money_get< _Elem, _InIt >::do_get ( _InIt  _First,
_InIt  _Last,
bool  _Intl,
ios_base _Iosbase,
ios_base::iostate &  _State,
string_type _Val 
) const
inlineprotectedvirtual
438  { // get string_type from [_First, _Last) into _Val
439  _Elem _Atoms[sizeof ("0123456789-") - 1];
440  string _Str = _Getmfld(_First, _Last, _Intl, _Iosbase, _Atoms);
441  size_t _Len = _Str.size();
442 
443  if (_First == _Last)
444  _State |= ios_base::eofbit;
445  if (_Len == 0)
446  _State |= ios_base::failbit; // _Getmfld failed
447  else
448  { // deliver value
449  size_t _Idx = 0;
450  _Val.resize(_Len);
451  if (_Str[0] == '-')
452  _Val[_Idx++] = _Atoms[10];
453  for (; _Idx < _Len; ++_Idx)
454  _Val[_Idx] = _Atoms[_Str[_Idx] - '0']; // map digits
455  }
456  return (_First);
457  }
static const _Iostate failbit
Definition: xiosbase:89
string _Getmfld(_InIt &_First, _InIt &_Last, bool _Intl, ios_base &_Iosbase, _Elem *_Atoms) const
Definition: xlocmon:460
_FwdIt const _Ty _Val
Definition: algorithm:1938
_FwdIt _Last
Definition: algorithm:1936
static const _Iostate eofbit
Definition: xiosbase:88
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
_InIt money_get< _Elem, _InIt >::get ( _InIt  _First,
_InIt  _Last,
bool  _Intl,
ios_base _Iosbase,
ios_base::iostate &  _State,
long double &  _Val 
) const
inline
363  { // get long double from [_First, _Last) into _Val
364  return (do_get(_First, _Last, _Intl, _Iosbase, _State, _Val));
365  }
virtual _InIt __CLR_OR_THIS_CALL do_get(_InIt _First, _InIt _Last, bool _Intl, ios_base &_Iosbase, ios_base::iostate &_State, long double &_Val) const
Definition: xlocmon:408
_FwdIt const _Ty _Val
Definition: algorithm:1938
_FwdIt _Last
Definition: algorithm:1936
template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
_InIt money_get< _Elem, _InIt >::get ( _InIt  _First,
_InIt  _Last,
bool  _Intl,
ios_base _Iosbase,
ios_base::iostate &  _State,
string_type _Val 
) const
inline
370  { // get string_type from [_First, _Last) into _Val
371  return (do_get(_First, _Last, _Intl, _Iosbase, _State, _Val));
372  }
virtual _InIt __CLR_OR_THIS_CALL do_get(_InIt _First, _InIt _Last, bool _Intl, ios_base &_Iosbase, ios_base::iostate &_State, long double &_Val) const
Definition: xlocmon:408
_FwdIt const _Ty _Val
Definition: algorithm:1938
_FwdIt _Last
Definition: algorithm:1936

Member Data Documentation

template<class _Elem , class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> >>
__PURE_APPDOMAIN_GLOBAL locale::id money_get< _Elem, _InIt >::id
static

The documentation for this class was generated from the following file: