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 | Static Private Member Functions | List of all members
money_put< _Elem, _OutIt > Class Template Reference
Inheritance diagram for money_put< _Elem, _OutIt >:
locale::facet _Facet_base _Crt_new_delete

Public Types

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

Public Member Functions

_OutIt put (_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, long double _Val) const
 
_OutIt put (_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, const string_type &_Val) const
 
 money_put (size_t _Refs=0)
 
 money_put (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_put () _NOEXCEPT
 
void _Init (const _Locinfo &)
 
virtual _OutIt __CLR_OR_THIS_CALL do_put (_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, long double _Val) const
 
virtual _OutIt __CLR_OR_THIS_CALL do_put (_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, const 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

_OutIt _Putmfld (_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, bool _Neg, string_type _Val, _Elem _E0) const
 

Static Private Member Functions

static _OutIt _Put (_OutIt _Dest, typename string_type::const_iterator _Source, size_t _Count)
 
static _OutIt _Rep (_OutIt _Dest, _Elem _Ch, size_t _Count)
 

Member Typedef Documentation

template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef moneypunct<_Elem, false> money_put< _Elem, _OutIt >::_Mypunct0
private
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef moneypunct<_Elem, true> money_put< _Elem, _OutIt >::_Mypunct1
private
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef _Elem money_put< _Elem, _OutIt >::char_type
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef _OutIt money_put< _Elem, _OutIt >::iter_type
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> > money_put< _Elem, _OutIt >::string_type

Constructor & Destructor Documentation

template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
money_put< _Elem, _OutIt >::money_put ( size_t  _Refs = 0)
inlineexplicit
678  : locale::facet(_Refs)
679  { // construct from current locale
680  _BEGIN_LOCINFO(_Lobj)
681  _Init(_Lobj);
682  _END_LOCINFO()
683  }
Definition: xlocale:138
void _Init(const _Locinfo &)
Definition: xlocmon:705
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
money_put< _Elem, _OutIt >::money_put ( const _Locinfo _Lobj,
size_t  _Refs = 0 
)
inline
686  : locale::facet(_Refs)
687  { // construct from specified locale
688  _Init(_Lobj);
689  }
Definition: xlocale:138
void _Init(const _Locinfo &)
Definition: xlocmon:705
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
virtual __CLR_OR_THIS_CALL money_put< _Elem, _OutIt >::~money_put ( )
inlineprotectedvirtual
702  { // destroy the object
703  }

Member Function Documentation

template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
static size_t money_put< _Elem, _OutIt >::_Getcat ( const locale::facet **  _Ppf = 0,
const locale _Ploc = 0 
)
inlinestatic
693  { // return locale category mask and construct standard facet
694  if (_Ppf != 0 && *_Ppf == 0)
695  *_Ppf = new money_put<_Elem, _OutIt>(
696  _Locinfo(_Ploc->c_str()));
697  return (_X_MONETARY);
698  }
Definition: xlocinfo:54
const char * c_str() const
Definition: xlocale:452
Definition: xlocmon:649
#define _X_MONETARY
Definition: xlocinfo.h:40
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
void money_put< _Elem, _OutIt >::_Init ( const _Locinfo )
inlineprotected
706  { // initialize from _Locinfo object
707  }
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
static _OutIt money_put< _Elem, _OutIt >::_Put ( _OutIt  _Dest,
typename string_type::const_iterator  _Source,
size_t  _Count 
)
inlinestaticprivate
917  { // put [_Source, _Source + _Count) to _Dest
918  for (; 0 < _Count; --_Count, (void)++_Dest, ++_Source)
919  *_Dest = *_Source;
920  return (_Dest);
921  }
unsigned int _Count
Definition: xcomplex:668
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *unexpected_handler)()
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
_OutIt money_put< _Elem, _OutIt >::_Putmfld ( _OutIt  _Dest,
bool  _Intl,
ios_base _Iosbase,
_Elem  _Fill,
bool  _Neg,
string_type  _Val,
_Elem  _E0 
) const
inlineprivate
771  { // put string_type with just digits to _Dest
772  _DEBUG_POINTER(_Dest);
773  const _Mpunct<_Elem> *_Ppunct_fac;
774  if (_Intl)
775  _Ppunct_fac =
776  &_USE(_Iosbase.getloc(), _Mypunct1); // international
777  else
778  _Ppunct_fac =
779  &_USE(_Iosbase.getloc(), _Mypunct0); // local
780 
781  const string _Grouping = _Ppunct_fac->grouping();
782  int _Ifracdigits = _Ppunct_fac->frac_digits();
783  unsigned int _Fracdigits = _Ifracdigits < 0 ? -_Ifracdigits
784  : _Ifracdigits;
785 
786  if (_Val.size() <= _Fracdigits)
787  _Val.insert((size_t)0, _Fracdigits - _Val.size() + 1, _E0);
788  else if (*_Grouping.c_str() != CHAR_MAX && '\0' < *_Grouping.c_str())
789  { // grouping specified, add thousands separators
790  const _Elem _Kseparator = _Ppunct_fac->thousands_sep();
791  const char *_Pg = _Grouping.c_str();
792  size_t _Off = _Val.size() - _Fracdigits; // start of fraction
793 
794  while (*_Pg != CHAR_MAX && '\0' < *_Pg
795  && (size_t)*_Pg < _Off)
796  { // add a thousands separator, right to left
797  _Val.insert(_Off -= *_Pg, (size_t)1, _Kseparator);
798  if ('\0' < _Pg[1])
799  ++_Pg; // not last group, advance
800  }
801  }
802 
803  money_base::pattern _Pattern;
804  string_type _Sign;
805  if (_Neg)
806  { // negative value, choose appropriate format and sign
807  _Pattern = _Ppunct_fac->neg_format();
808  _Sign = _Ppunct_fac->negative_sign();
809  }
810  else
811  { // positive value, choose appropriate format and sign
812  _Pattern = _Ppunct_fac->pos_format();
813  _Sign = _Ppunct_fac->positive_sign();
814  }
815 
816  string_type _Symbol;
817  if (_Iosbase.flags() & ios_base::showbase)
818  _Symbol = _Ppunct_fac->curr_symbol(); // showbase ==> show $
819 
820  bool _Intern = false;
821  size_t _Fillcount, _Off;
822  for (_Fillcount = 0, _Off = 0; _Off < 4; ++_Off)
823  switch (_Pattern.field[_Off])
824  { // accumulate total length in _Fillcount
825  case money_base::symbol: // count currency symbol size
826  _Fillcount += _Symbol.size();
827  break;
828 
829  case money_base::sign: // count sign size
830  _Fillcount += _Sign.size();
831  break;
832 
833  case money_base::value: // count value field size
834  _Fillcount += _Val.size() + (0 < _Fracdigits ? 1 : 0)
835  + (_Val.size() <= _Fracdigits
836  ? _Fracdigits - _Val.size() + 1 : 0);
837  break;
838 
839  case money_base::space: // count space size
840  ++_Fillcount; // at least one space
841  // fall through
842 
843  case money_base::none: // count space size
844  if (_Off != 3)
845  _Intern = true; // optional internal fill
846  break;
847  }
848 
849  _Fillcount = _Iosbase.width() <= 0
850  || (size_t)_Iosbase.width() <= _Fillcount
851  ? 0 : (size_t)_Iosbase.width() - _Fillcount;
852 
853  ios_base::fmtflags _Afl =
854  _Iosbase.flags() & ios_base::adjustfield;
855  if (_Afl != ios_base::left
856  && (_Afl != ios_base::internal || !_Intern))
857  { // put leading fill
858  _Dest = _Rep(_Dest, _Fill, _Fillcount);
859  _Fillcount = 0;
860  }
861 
862  for (_Off = 0; _Off < 4; ++_Off)
863  switch (_Pattern.field[_Off])
864  { // put components as specified by _Pattern
865  case money_base::symbol: // put currency symbol
866  _Dest = _Put(_Dest, _Symbol.begin(), _Symbol.size());
867  break;
868 
869  case money_base::sign: // put sign
870  if (0 < _Sign.size())
871  _Dest = _Put(_Dest, _Sign.begin(), 1);
872  break;
873 
874  case money_base::value: // put value field
875  if (_Fracdigits == 0)
876  _Dest = _Put(_Dest, _Val.begin(),
877  _Val.size()); // no fraction part
878  else if (_Val.size() <= _Fracdigits)
879  { // put leading zero, all fraction digits
880  *_Dest++ = _E0;
881  *_Dest++ = _Ppunct_fac->decimal_point();
882  _Dest = _Rep(_Dest, _E0,
883  _Fracdigits - _Val.size()); // insert zeros
884  _Dest = _Put(_Dest, _Val.begin(), _Val.size());
885  }
886  else
887  { // put both integer and fraction parts
888  _Dest = _Put(_Dest, _Val.begin(),
889  _Val.size() - _Fracdigits); // put integer part
890  *_Dest++ = _Ppunct_fac->decimal_point();
891  _Dest = _Put(_Dest, _Val.end() - _Fracdigits,
892  _Fracdigits); // put fraction part
893  }
894  break;
895 
896  case money_base::space: // put any internal fill
897  _Dest = _Rep(_Dest, _Fill, 1);
898  // fall through
899 
900  case money_base::none: // put any internal fill
901  if (_Afl == ios_base::internal)
902  { // put internal fill
903  _Dest = _Rep(_Dest, _Fill, _Fillcount);
904  _Fillcount = 0;
905  }
906  }
907 
908  if (1 < _Sign.size())
909  _Dest = _Put(_Dest, _Sign.begin() + 1,
910  _Sign.size() - 1); // put remainder of sign
911  _Iosbase.width(0);
912  return (_Rep(_Dest, _Fill, _Fillcount)); // put trailing fill
913  }
moneypunct< _Elem, true > _Mypunct1
Definition: xlocmon:653
Definition: xlocmon:22
#define _USE(loc, fac)
Definition: xlocale:547
Definition: xlocmon:22
_In_ int _Val
Definition: vcruntime_string.h:62
static _OutIt _Put(_OutIt _Dest, typename string_type::const_iterator _Source, size_t _Count)
Definition: xlocmon:915
Definition: xlocmon:22
locale __CLR_OR_THIS_CALL getloc() const
Definition: xiosbase:433
unsigned int size_t
Definition: sourceannotations.h:19
fmtflags __CLR_OR_THIS_CALL flags() const
Definition: xiosbase:376
static _OutIt _Rep(_OutIt _Dest, _Elem _Ch, size_t _Count)
Definition: xlocmon:923
streamsize __CLR_OR_THIS_CALL width() const
Definition: xiosbase:421
#define _DEBUG_POINTER(first)
Definition: xutility:819
static constexpr _Fmtflags showbase
Definition: xiosbase:59
static constexpr _Fmtflags internal
Definition: xiosbase:64
Definition: xlocmon:25
moneypunct< _Elem, false > _Mypunct0
Definition: xlocmon:652
char field[4]
Definition: xlocmon:27
Definition: xlocmon:22
#define CHAR_MAX
Definition: limits.h:24
basic_string< _Elem, char_traits< _Elem >, allocator< _Elem > > string_type
Definition: xlocmon:659
Definition: xlocmon:22
Definition: xlocmon:38
static constexpr _Fmtflags adjustfield
Definition: xiosbase:76
static constexpr _Fmtflags left
Definition: xiosbase:62
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
static _OutIt money_put< _Elem, _OutIt >::_Rep ( _OutIt  _Dest,
_Elem  _Ch,
size_t  _Count 
)
inlinestaticprivate
925  { // put _Count * _Ch to _Dest
926  for (; 0 < _Count; --_Count, (void)++_Dest)
927  *_Dest = _Ch;
928  return (_Dest);
929  }
unsigned int _Count
Definition: xcomplex:668
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *unexpected_handler)()
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
virtual _OutIt __CLR_OR_THIS_CALL money_put< _Elem, _OutIt >::do_put ( _OutIt  _Dest,
bool  _Intl,
ios_base _Iosbase,
_Elem  _Fill,
long double  _Val 
) const
inlineprotectedvirtual
712  { // put long double to _Dest
713  bool _Negative = false;
714  if (_Val < 0)
715  _Negative = true, _Val = -_Val;
716 
717  size_t _Exp;
718  for (_Exp = 0; 1e35 <= _Val && _Exp < 5000; _Exp += 10)
719  _Val /= 1e10; // drop 10 zeros before decimal point
720 
721  char _Buf[40];
722 
723  int _Count = _CSTD sprintf_s(_Buf, sizeof (_Buf), "%.0Lf",
724  _Val); // convert to chars
725 
726  if (_Count < 0)
727  return (_Dest); // bad conversion, give up
728 
729  const ctype<_Elem>& _Ctype_fac =
730  _USE(_Iosbase.getloc(), ctype<_Elem>);
731  const _Elem _E0 = _Ctype_fac.widen('0');
732 
733  string_type _Val2(_Count, (_Elem)0);
734  _Ctype_fac.widen(&_Buf[0], &_Buf[_Count], &_Val2[0]);
735  _Val2.append(_Exp, _E0); // scale by trailing zeros
736  return (_Putmfld(_Dest, _Intl, _Iosbase, _Fill,
737  _Negative, _Val2, _E0));
738  }
unsigned int _Count
Definition: xcomplex:668
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Exp(double *, double, short)
Definition: regex:1539
#define _USE(loc, fac)
Definition: xlocale:547
_In_ int _Val
Definition: vcruntime_string.h:62
locale __CLR_OR_THIS_CALL getloc() const
Definition: xiosbase:433
Definition: xlocale:2115
_OutIt _Putmfld(_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, bool _Neg, string_type _Val, _Elem _E0) const
Definition: xlocmon:768
_Elem __CLR_OR_THIS_CALL widen(char _Byte) const
Definition: xlocale:2164
#define _CSTD
Definition: yvals.h:570
basic_string< _Elem, char_traits< _Elem >, allocator< _Elem > > string_type
Definition: xlocmon:659
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
virtual _OutIt __CLR_OR_THIS_CALL money_put< _Elem, _OutIt >::do_put ( _OutIt  _Dest,
bool  _Intl,
ios_base _Iosbase,
_Elem  _Fill,
const string_type _Val 
) const
inlineprotectedvirtual
743  { // put string_type to _Dest
744  static const char _Src[] = {"0123456789-"}; // TRANSITION, VSO#202551
745  _Elem _Atoms[sizeof (_Src)];
746  const ctype<_Elem>& _Ctype_fac =
747  _USE(_Iosbase.getloc(), ctype<_Elem>);
748  _Ctype_fac.widen(&_Src[0], &_Src[sizeof (_Src)], _Atoms);
749 
750  bool _Negative = false;
751  size_t _Idx0 = 0;
752  if (!_Val.empty() && _Val[0] == _Atoms[10])
753  _Negative = true, ++_Idx0; // strip off '-'
754 
755  size_t _Size = _Val.size();
756  size_t _Idx = _Idx0;
757  for (; _Idx < _Size && _Find_elem(_Atoms, _Val[_Idx]) < 10; ++_Idx)
758  ; // count digits
759  string_type _Val2(&_Val[_Idx0], (size_t)(_Idx - _Idx0));
760  if (_Val2.empty()) // replace empty digit string with '0'
761  _Val2.append((size_t)1, _Atoms[0]);
762 
763  return (_Putmfld(_Dest, _Intl, _Iosbase, _Fill,
764  _Negative, _Val2, _Atoms[0]));
765  }
#define _USE(loc, fac)
Definition: xlocale:547
_In_ int _Val
Definition: vcruntime_string.h:62
locale __CLR_OR_THIS_CALL getloc() const
Definition: xiosbase:433
Definition: xlocale:2115
_OutIt _Putmfld(_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, bool _Neg, string_type _Val, _Elem _E0) const
Definition: xlocmon:768
size_t _Find_elem(_Elem *_Base, _Elem _Ch)
Definition: xlocnum:89
basic_string< _Elem, char_traits< _Elem >, allocator< _Elem > > string_type
Definition: xlocmon:659
_Size
Definition: vcruntime_string.h:36
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
_OutIt money_put< _Elem, _OutIt >::put ( _OutIt  _Dest,
bool  _Intl,
ios_base _Iosbase,
_Elem  _Fill,
long double  _Val 
) const
inline
664  { // put long double to _Dest
665  return (do_put(_Dest, _Intl, _Iosbase, _Fill, _Val));
666  }
_In_ int _Val
Definition: vcruntime_string.h:62
virtual _OutIt __CLR_OR_THIS_CALL do_put(_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, long double _Val) const
Definition: xlocmon:709
template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
_OutIt money_put< _Elem, _OutIt >::put ( _OutIt  _Dest,
bool  _Intl,
ios_base _Iosbase,
_Elem  _Fill,
const string_type _Val 
) const
inline
671  { // put string_type to _Dest
672  return (do_put(_Dest, _Intl, _Iosbase, _Fill, _Val));
673  }
_In_ int _Val
Definition: vcruntime_string.h:62
virtual _OutIt __CLR_OR_THIS_CALL do_put(_OutIt _Dest, bool _Intl, ios_base &_Iosbase, _Elem _Fill, long double _Val) const
Definition: xlocmon:709

Member Data Documentation

template<class _Elem , class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> >>
__PURE_APPDOMAIN_GLOBAL locale::id money_put< _Elem, _OutIt >::id
static

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