|
|
|
| 1 |
|
// xlocmon internal header (from <locale>) |
| 2 |
|
#pragma once |
| 3 |
|
#ifndef _XLOCMON_ |
| 4 |
|
#define _XLOCMON_ |
| 5 |
|
#ifndef RC_INVOKED |
| 6 |
|
#include <xlocnum> |
| 7 |
|
|
| 8 |
|
#ifdef _MSC_VER |
| 9 |
|
#pragma pack(push,_CRT_PACKING) |
| 10 |
|
#pragma warning(push,3) |
| 11 |
|
#endif /* _MSC_VER */ |
| 12 |
|
|
| 13 |
|
_STD_BEGIN |
| 14 |
|
#pragma warning(push) |
| 15 |
|
#pragma warning(disable:4275) |
| 16 |
|
// STRUCT money_base |
| 17 |
|
|
| 18 |
|
const size_t _PATTERN_FIELD_SIZE = 4; |
| 19 |
|
|
| 20 |
|
struct _CRTIMP2_PURE money_base |
| 21 |
|
: public locale::facet |
| 22 |
|
{ // ultimate base class for moneypunct |
| 23 |
|
enum |
| 24 |
|
{ // constants for different format codes |
| 25 |
|
symbol = '$', sign = '+', space = ' ', value = 'v', none = 'x'}; |
| 26 |
|
typedef int part; |
| 27 |
|
|
| 28 |
|
struct pattern |
| 29 |
|
{ // four-part formats for monetary text |
| 30 |
|
char field[_PATTERN_FIELD_SIZE]; |
| 31 |
|
}; |
| 32 |
|
|
| 33 |
|
__CLR_OR_THIS_CALL money_base(size_t _Refs = 0) |
| 34 |
|
: locale::facet(_Refs) |
| 35 |
|
{ // default constructor |
| 36 |
|
} |
| 37 |
|
__CLR_OR_THIS_CALL ~money_base() |
| 38 |
|
{ |
| 39 |
|
} |
| 40 |
|
}; |
| 41 |
|
|
| 42 |
|
// TEMPLATE CLASS _Mpunct |
| 43 |
|
template<class _Elem> |
| 44 |
|
class _Mpunct |
| 45 |
|
: public money_base |
| 46 |
|
{ // common base class for moneypunct<_Elem, false/true> |
| 47 |
|
public: |
| 48 |
|
typedef _Elem char_type; |
| 49 |
|
typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> > |
| 50 |
|
string_type; |
| 51 |
|
|
| 52 |
|
_Elem __CLR_OR_THIS_CALL decimal_point() const |
| 53 |
|
{ // return decimal point |
| 54 |
|
return (do_decimal_point()); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
_Elem __CLR_OR_THIS_CALL thousands_sep() const |
| 58 |
|
{ // return thousands separator |
| 856 |
|
*_Dest++ = _Ppunct_fac->decimal_point(); |
| 857 |
|
_Dest = _Put(_Dest, _Val.end() - _Fracdigits, |
| 858 |
|
_Fracdigits); // put fraction part |
| 859 |
|
} |
| 860 |
|
break; |
| 861 |
|
|
| 862 |
|
case money_base::space: // put any internal fill |
| 863 |
|
_Dest = _Rep(_Dest, _Fill, 1); |
| 864 |
|
// fall through |
| 865 |
|
|
| 866 |
|
case money_base::none: // put any internal fill |
| 867 |
|
if (_Afl == ios_base::internal) |
| 868 |
|
{ // put internal fill |
| 869 |
|
_Dest = _Rep(_Dest, _Fill, _Fillcount); |
| 870 |
|
_Fillcount = 0; |
| 871 |
|
} |
| 872 |
|
} |
| 873 |
|
|
| 874 |
|
if (1 < _Sign.size()) |
| 875 |
|
_Dest = _Put(_Dest, _Sign.begin() + 1, |
| 876 |
|
_Sign.size() - 1); // put remainder of sign |
| 877 |
|
_Iosbase.width(0); |
| 878 |
|
return (_Rep(_Dest, _Fill, _Fillcount)); // put trailing fill |
| 879 |
|
} |
| 880 |
|
|
| 881 |
|
static _OutIt __CLRCALL_OR_CDECL _Put(_OutIt _Dest, |
| 882 |
|
typename string_type::const_iterator _Source, size_t _Count) |
| 883 |
|
{ // put [_Source, _Source + _Count) to _Dest |
| 884 |
|
for (; 0 < _Count; --_Count, ++_Dest, ++_Source) |
| 885 |
|
*_Dest = *_Source; |
| 886 |
|
return (_Dest); |
| 887 |
|
} |
| 888 |
|
|
| 889 |
|
static _OutIt __CLRCALL_OR_CDECL _Rep(_OutIt _Dest, |
| 890 |
|
_Elem _Ch, size_t _Count) |
| 891 |
|
{ // put _Count * _Ch to _Dest |
| 892 |
|
for (; 0 < _Count; --_Count, ++_Dest) |
| 893 |
|
*_Dest = _Ch; |
| 894 |
|
return (_Dest); |
| 895 |
|
} |
| 896 |
|
|
| 897 |
|
_Locinfo::_Cvtvec _Cvt; // conversion information |
| 898 |
|
}; |
| 899 |
|
|
| 900 |
|
// STATIC money_put::id OBJECT |
| 901 |
|
template<class _Elem, |
| 902 |
|
class _OutIt> |
| 903 |
|
__PURE_APPDOMAIN_GLOBAL locale::id money_put<_Elem, _OutIt>::id; |
| 904 |
|
|
| 905 |
|
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) |
| 906 |
|
|
| 907 |
|
template class _CRTIMP2_PURE _Mpunct<char>; |
| 908 |
|
template class _CRTIMP2_PURE moneypunct<char, true>; |
| 909 |
|
template class _CRTIMP2_PURE moneypunct<char, false>; |
| 910 |
|
template class _CRTIMP2_PURE money_get<char, |
| 911 |
|
istreambuf_iterator<char, char_traits<char> > >; |
| 912 |
|
template class _CRTIMP2_PURE money_put<char, |
| 913 |
|
ostreambuf_iterator<char, char_traits<char> > >; |
| 914 |
|
|
| 915 |
|
template class _CRTIMP2_PURE _Mpunct<wchar_t>; |
| 916 |
|
template class _CRTIMP2_PURE moneypunct<wchar_t, true>; |
| 917 |
|
template class _CRTIMP2_PURE moneypunct<wchar_t, false>; |
| 918 |
|
template class _CRTIMP2_PURE money_get<wchar_t, |
| 919 |
|
istreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
| 920 |
|
template class _CRTIMP2_PURE money_put<wchar_t, |
| 921 |
|
ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
| 922 |
|
|
| 923 |
|
|
| 924 |
|
|
| 925 |
|
#endif /* _DLL_CPPLIB */ |
| 926 |
|
#pragma warning(pop) |
| 927 |
|
_STD_END |
| 928 |
|
|
| 929 |
|
#ifdef _MSC_VER |
| 930 |
|
#pragma warning(pop) |
| 931 |
|
#pragma pack(pop) |
| 932 |
|
#endif /* _MSC_VER */ |
| 933 |
|
|
| 934 |
|
#endif /* RC_INVOKED */ |
| 935 |
|
#endif /* _XLOCMON_ */ |
| 936 |
|
|
| 937 |
|
/* |
| 938 |
|
* Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED. |
| 939 |
|
* Consult your license regarding permissions and restrictions. |
| 940 |
|
V5.03:0009 */ |
| 941 |
|
|
|
|
|