3
* Silicon Graphics Computer Systems, Inc.
8
* This material is provided "as is", with absolutely no warranty expressed
9
* or implied. Any use is at your own risk.
11
* Permission to use or copy this software for any purpose is hereby granted
12
* without fee, provided the above notices are retained on all copies.
13
* Permission to modify the code and to distribute modified code is granted,
14
* provided the above notices are retained, and a notice that the code was
15
* modified is included with the above copyright notice.
18
// WARNING: This is an internal header file, included by other C++
19
// standard library headers. You should not attempt to use this header
23
#ifndef _STLP_INTERNAL_MONETARY_H
24
#define _STLP_INTERNAL_MONETARY_H
26
#ifndef _STLP_INTERNAL_CTYPE_H
27
# include <stl/_ctype.h>
30
#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
31
# include <stl/_ostreambuf_iterator.h>
34
#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
35
# include <stl/_istreambuf_iterator.h>
42
enum part {none, space, symbol, sign, value};
48
// moneypunct facets: forward declaration
49
template <class _charT, __DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
53
template <class _CharT, __DFL_TMPL_PARAM(_InputIter , istreambuf_iterator<_CharT>) >
54
class money_get : public locale::facet
58
typedef _CharT char_type;
59
typedef _InputIter iter_type;
60
typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
62
money_get(size_t __refs = 0) : _BaseFacet(__refs) {}
63
# ifndef _STLP_NO_LONG_DOUBLE
64
iter_type get(iter_type __s, iter_type __end, bool __intl,
65
ios_base& __str, ios_base::iostate& __err,
66
long double& __units) const
67
{ return do_get(__s, __end, __intl, __str, __err, __units); }
69
iter_type get(iter_type __s, iter_type __end, bool __intl,
70
ios_base& __str, ios_base::iostate& __err,
71
string_type& __digits) const
72
{ return do_get(__s, __end, __intl, __str, __err, __digits); }
74
_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
78
# ifndef _STLP_NO_LONG_DOUBLE
79
virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
80
ios_base& __str, ios_base::iostate& __err,
81
long double& __units) const;
83
virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
84
ios_base& __str, ios_base::iostate& __err,
85
string_type& __digits) const;
89
// moneypunct facets: definition of specializations
92
class _STLP_CLASS_DECLSPEC moneypunct<char, true> : public locale::facet, public money_base
96
typedef char char_type;
97
typedef string string_type;
98
explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
100
char decimal_point() const { return do_decimal_point(); }
101
char thousands_sep() const { return do_thousands_sep(); }
102
string grouping() const { return do_grouping(); }
103
string_type curr_symbol() const { return do_curr_symbol(); }
104
string_type positive_sign() const { return do_positive_sign(); }
105
string_type negative_sign() const { return do_negative_sign(); }
106
int frac_digits() const { return do_frac_digits(); }
107
pattern pos_format() const { return do_pos_format(); }
108
pattern neg_format() const { return do_neg_format(); }
110
_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
111
# if defined (_STLP_STATIC_CONST_INIT_BUG)
112
enum _IntlVal { intl = 1 } ;
114
static const bool intl = true;
118
pattern _M_pos_format;
119
pattern _M_neg_format;
121
~moneypunct _STLP_PSPEC2(char, true) ();
123
virtual char do_decimal_point() const;
124
virtual char do_thousands_sep() const;
125
virtual string do_grouping() const;
127
virtual string do_curr_symbol() const;
129
virtual string do_positive_sign() const;
130
virtual string do_negative_sign() const;
131
virtual int do_frac_digits() const;
132
virtual pattern do_pos_format() const;
133
virtual pattern do_neg_format() const;
135
friend class _Locale;
140
class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base
143
typedef char char_type;
144
typedef string string_type;
146
explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
148
char decimal_point() const { return do_decimal_point(); }
149
char thousands_sep() const { return do_thousands_sep(); }
150
string grouping() const { return do_grouping(); }
151
string_type curr_symbol() const { return do_curr_symbol(); }
152
string_type positive_sign() const { return do_positive_sign(); }
153
string_type negative_sign() const { return do_negative_sign(); }
154
int frac_digits() const { return do_frac_digits(); }
155
pattern pos_format() const { return do_pos_format(); }
156
pattern neg_format() const { return do_neg_format(); }
158
_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
159
# if defined (_STLP_STATIC_CONST_INIT_BUG)
160
enum _IntlVal { intl = 0 } ;
162
static const bool intl = false;
166
pattern _M_pos_format;
167
pattern _M_neg_format;
169
~moneypunct _STLP_PSPEC2(char, false) ();
171
virtual char do_decimal_point() const;
172
virtual char do_thousands_sep() const;
173
virtual string do_grouping() const;
175
virtual string do_curr_symbol() const;
177
virtual string do_positive_sign() const;
178
virtual string do_negative_sign() const;
179
virtual int do_frac_digits() const;
180
virtual pattern do_pos_format() const;
181
virtual pattern do_neg_format() const;
183
friend class _Locale;
187
# ifndef _STLP_NO_WCHAR_T
190
class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base
192
friend class _Locale;
194
typedef wchar_t char_type;
195
typedef wstring string_type;
196
explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0);
197
wchar_t decimal_point() const { return do_decimal_point(); }
198
wchar_t thousands_sep() const { return do_thousands_sep(); }
199
string grouping() const { return do_grouping(); }
200
string_type curr_symbol() const { return do_curr_symbol(); }
201
string_type positive_sign() const { return do_positive_sign(); }
202
string_type negative_sign() const { return do_negative_sign(); }
203
int frac_digits() const { return do_frac_digits(); }
204
pattern pos_format() const { return do_pos_format(); }
205
pattern neg_format() const { return do_neg_format(); }
207
_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
208
# if defined (_STLP_STATIC_CONST_INIT_BUG)
209
enum _IntlVal { intl = 1 } ;
211
static const bool intl = true;
215
pattern _M_pos_format;
216
pattern _M_neg_format;
218
~moneypunct _STLP_PSPEC2(wchar_t, true) ();
220
virtual wchar_t do_decimal_point() const;
221
virtual wchar_t do_thousands_sep() const;
222
virtual string do_grouping() const;
224
virtual string_type do_curr_symbol() const;
226
virtual string_type do_positive_sign() const;
227
virtual string_type do_negative_sign() const;
228
virtual int do_frac_digits() const;
229
virtual pattern do_pos_format() const;
230
virtual pattern do_neg_format() const;
235
class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base
237
friend class _Locale;
239
typedef wchar_t char_type;
240
typedef wstring string_type;
241
explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0);
242
wchar_t decimal_point() const { return do_decimal_point(); }
243
wchar_t thousands_sep() const { return do_thousands_sep(); }
244
string grouping() const { return do_grouping(); }
245
string_type curr_symbol() const { return do_curr_symbol(); }
246
string_type positive_sign() const { return do_positive_sign(); }
247
string_type negative_sign() const { return do_negative_sign(); }
248
int frac_digits() const { return do_frac_digits(); }
249
pattern pos_format() const { return do_pos_format(); }
250
pattern neg_format() const { return do_neg_format(); }
252
_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
253
# if defined (_STLP_STATIC_CONST_INIT_BUG)
254
enum _IntlVal { intl = 0 } ;
256
static const bool intl = false;
260
pattern _M_pos_format;
261
pattern _M_neg_format;
263
~moneypunct _STLP_PSPEC2(wchar_t, false) ();
265
virtual wchar_t do_decimal_point() const;
266
virtual wchar_t do_thousands_sep() const;
267
virtual string do_grouping() const;
269
virtual string_type do_curr_symbol() const;
271
virtual string_type do_positive_sign() const;
272
virtual string_type do_negative_sign() const;
273
virtual int do_frac_digits() const;
274
virtual pattern do_pos_format() const;
275
virtual pattern do_neg_format() const;
280
template <class _charT, __DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
283
class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true>
286
typedef money_base::pattern pattern;
287
typedef char char_type;
288
typedef string string_type;
290
explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0);
293
_Locale_monetary* _M_monetary;
294
~moneypunct_byname _STLP_PSPEC2(char, true) ();
295
virtual char do_decimal_point() const;
296
virtual char do_thousands_sep() const;
297
virtual string do_grouping() const;
299
virtual string_type do_curr_symbol() const;
301
virtual string_type do_positive_sign() const;
302
virtual string_type do_negative_sign() const;
303
virtual int do_frac_digits() const;
307
class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false>
310
typedef money_base::pattern pattern;
311
typedef char char_type;
312
typedef string string_type;
314
explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0);
317
_Locale_monetary* _M_monetary;
318
~moneypunct_byname _STLP_PSPEC2(char, false) ();
319
virtual char do_decimal_point() const;
320
virtual char do_thousands_sep() const;
321
virtual string do_grouping() const;
323
virtual string_type do_curr_symbol() const;
325
virtual string_type do_positive_sign() const;
326
virtual string_type do_negative_sign() const;
327
virtual int do_frac_digits() const;
330
# ifndef _STLP_NO_WCHAR_T
332
class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true>
335
typedef money_base::pattern pattern;
336
typedef wchar_t char_type;
337
typedef wstring string_type;
339
explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0);
342
_Locale_monetary* _M_monetary;
343
~moneypunct_byname _STLP_PSPEC2(wchar_t, true) ();
344
virtual wchar_t do_decimal_point() const;
345
virtual wchar_t do_thousands_sep() const;
346
virtual string do_grouping() const;
348
virtual string_type do_curr_symbol() const;
350
virtual string_type do_positive_sign() const;
351
virtual string_type do_negative_sign() const;
352
virtual int do_frac_digits() const;
356
class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false>
359
typedef money_base::pattern pattern;
360
typedef wchar_t char_type;
361
typedef wstring string_type;
363
explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0);
366
_Locale_monetary* _M_monetary;
367
~moneypunct_byname _STLP_PSPEC2(wchar_t, false) ();
368
virtual wchar_t do_decimal_point() const;
369
virtual wchar_t do_thousands_sep() const;
370
virtual string do_grouping() const;
372
virtual string_type do_curr_symbol() const;
374
virtual string_type do_positive_sign() const;
375
virtual string_type do_negative_sign() const;
376
virtual int do_frac_digits() const;
380
//===== methods ======
385
template <class _CharT, __DFL_TMPL_PARAM( _OutputIter , ostreambuf_iterator<_CharT>) >
386
class money_put : public locale::facet {
387
friend class _Locale;
390
typedef _CharT char_type;
391
typedef _OutputIter iter_type;
392
typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
394
money_put(size_t __refs = 0) : _BaseFacet(__refs) {}
395
# ifndef _STLP_NO_LONG_DOUBLE
396
iter_type put(iter_type __s, bool __intl, ios_base& __str,
397
char_type __fill, long double __units) const
398
{ return do_put(__s, __intl, __str, __fill, __units); }
400
iter_type put(iter_type __s, bool __intl, ios_base& __str,
402
const string_type& __digits) const
403
{ return do_put(__s, __intl, __str, __fill, __digits); }
405
_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
409
# ifndef _STLP_NO_LONG_DOUBLE
410
virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
411
char_type __fill, long double /* __units */ ) const {
413
locale __loc = __str.getloc();
415
return do_put(__s, __intl, __str, __fill, __buf + 0);
418
virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
420
const string_type& __digits) const;
423
# if defined (_STLP_USE_TEMPLATE_EXPORT)
424
_STLP_EXPORT_TEMPLATE_CLASS money_get<char, istreambuf_iterator<char, char_traits<char> > >;
425
_STLP_EXPORT_TEMPLATE_CLASS money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
426
// _STLP_EXPORT_TEMPLATE_CLASS money_get<char, const char* >;
427
// _STLP_EXPORT_TEMPLATE_CLASS money_put<char, char* >;
428
# if ! defined (_STLP_NO_WCHAR_T)
429
_STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
430
_STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
431
// _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, const wchar_t* >;
432
// _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, wchar_t* >;
434
# endif /* _STLP_USE_TEMPLATE_EXPORT */
436
# if defined (__BORLANDC__) && defined (_RTLDLL)
437
inline void _Stl_loc_init_monetary() {
438
money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 8;
439
money_get<char, const char*>::id._M_index = 9;
440
money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 10;
441
money_put<char, char*>::id._M_index = 11;
442
# ifndef _STLP_NO_WCHAR_T
443
money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 27;
444
money_get<wchar_t, const wchar_t*>::id._M_index = 28;
445
money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 29;
446
money_put<wchar_t, wchar_t*>::id._M_index = 30;
453
# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
454
# include <stl/_monetary.c>
457
#endif /* _STLP_INTERNAL_MONETARY_H */