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_OSTREAMBUF_ITERATOR_H
27 # include <stl/_ostreambuf_iterator.h>
30 #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
31 # include <stl/_istreambuf_iterator.h>
34 #ifndef _STLP_FACETS_FWD_H
35 # include <stl/_facets_fwd.h>
42 enum part {none, space, symbol, sign, value};
48 // moneypunct facets: forward declaration
49 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
53 template <class _CharT, class _InputIter>
54 class money_get : public locale::facet {
56 typedef _CharT char_type;
57 typedef _InputIter iter_type;
58 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
60 explicit money_get(size_t __refs = 0) : locale::facet(__refs) {}
61 iter_type get(iter_type __s, iter_type __end, bool __intl,
62 ios_base& __str, ios_base::iostate& __err,
63 _STLP_LONGEST_FLOAT_TYPE& __units) const
64 { return do_get(__s, __end, __intl, __str, __err, __units); }
65 iter_type get(iter_type __s, iter_type __end, bool __intl,
66 ios_base& __str, ios_base::iostate& __err,
67 string_type& __digits) const
68 { return do_get(__s, __end, __intl, __str, __err, __digits); }
74 virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
75 ios_base& __str, ios_base::iostate& __err,
76 _STLP_LONGEST_FLOAT_TYPE& __units) const;
77 virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
78 ios_base& __str, ios_base::iostate& __err,
79 string_type& __digits) const;
83 // moneypunct facets: definition of specializations
86 class _STLP_CLASS_DECLSPEC moneypunct<char, true> : public locale::facet, public money_base {
88 typedef char char_type;
89 typedef string string_type;
90 explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
92 char decimal_point() const { return do_decimal_point(); }
93 char thousands_sep() const { return do_thousands_sep(); }
94 string grouping() const { return do_grouping(); }
95 string_type curr_symbol() const { return do_curr_symbol(); }
96 string_type positive_sign() const { return do_positive_sign(); }
97 string_type negative_sign() const { return do_negative_sign(); }
98 int frac_digits() const { return do_frac_digits(); }
99 pattern pos_format() const { return do_pos_format(); }
100 pattern neg_format() const { return do_neg_format(); }
102 static _STLP_STATIC_DECLSPEC locale::id id;
103 _STLP_STATIC_CONSTANT(bool, intl = true);
106 pattern _M_pos_format;
107 pattern _M_neg_format;
109 ~moneypunct _STLP_PSPEC2(char, true) ();
111 virtual char do_decimal_point() const;
112 virtual char do_thousands_sep() const;
113 virtual string do_grouping() const;
115 virtual string do_curr_symbol() const;
117 virtual string do_positive_sign() const;
118 virtual string do_negative_sign() const;
119 virtual int do_frac_digits() const;
120 virtual pattern do_pos_format() const;
121 virtual pattern do_neg_format() const;
125 class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base {
127 typedef char char_type;
128 typedef string string_type;
130 explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
132 char decimal_point() const { return do_decimal_point(); }
133 char thousands_sep() const { return do_thousands_sep(); }
134 string grouping() const { return do_grouping(); }
135 string_type curr_symbol() const { return do_curr_symbol(); }
136 string_type positive_sign() const { return do_positive_sign(); }
137 string_type negative_sign() const { return do_negative_sign(); }
138 int frac_digits() const { return do_frac_digits(); }
139 pattern pos_format() const { return do_pos_format(); }
140 pattern neg_format() const { return do_neg_format(); }
142 static _STLP_STATIC_DECLSPEC locale::id id;
143 _STLP_STATIC_CONSTANT(bool, intl = false);
146 pattern _M_pos_format;
147 pattern _M_neg_format;
149 ~moneypunct _STLP_PSPEC2(char, false) ();
151 virtual char do_decimal_point() const;
152 virtual char do_thousands_sep() const;
153 virtual string do_grouping() const;
155 virtual string do_curr_symbol() const;
157 virtual string do_positive_sign() const;
158 virtual string do_negative_sign() const;
159 virtual int do_frac_digits() const;
160 virtual pattern do_pos_format() const;
161 virtual pattern do_neg_format() const;
165 #ifndef _STLP_NO_WCHAR_T
168 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base {
170 typedef wchar_t char_type;
171 typedef wstring string_type;
172 explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0);
173 wchar_t decimal_point() const { return do_decimal_point(); }
174 wchar_t thousands_sep() const { return do_thousands_sep(); }
175 string grouping() const { return do_grouping(); }
176 string_type curr_symbol() const { return do_curr_symbol(); }
177 string_type positive_sign() const { return do_positive_sign(); }
178 string_type negative_sign() const { return do_negative_sign(); }
179 int frac_digits() const { return do_frac_digits(); }
180 pattern pos_format() const { return do_pos_format(); }
181 pattern neg_format() const { return do_neg_format(); }
183 static _STLP_STATIC_DECLSPEC locale::id id;
184 _STLP_STATIC_CONSTANT(bool, intl = true);
187 pattern _M_pos_format;
188 pattern _M_neg_format;
190 ~moneypunct _STLP_PSPEC2(wchar_t, true) ();
192 virtual wchar_t do_decimal_point() const;
193 virtual wchar_t do_thousands_sep() const;
194 virtual string do_grouping() const;
196 virtual string_type do_curr_symbol() const;
198 virtual string_type do_positive_sign() const;
199 virtual string_type do_negative_sign() const;
200 virtual int do_frac_digits() const;
201 virtual pattern do_pos_format() const;
202 virtual pattern do_neg_format() const;
207 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base {
209 typedef wchar_t char_type;
210 typedef wstring string_type;
211 explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0);
212 wchar_t decimal_point() const { return do_decimal_point(); }
213 wchar_t thousands_sep() const { return do_thousands_sep(); }
214 string grouping() const { return do_grouping(); }
215 string_type curr_symbol() const { return do_curr_symbol(); }
216 string_type positive_sign() const { return do_positive_sign(); }
217 string_type negative_sign() const { return do_negative_sign(); }
218 int frac_digits() const { return do_frac_digits(); }
219 pattern pos_format() const { return do_pos_format(); }
220 pattern neg_format() const { return do_neg_format(); }
222 static _STLP_STATIC_DECLSPEC locale::id id;
223 _STLP_STATIC_CONSTANT(bool, intl = false);
226 pattern _M_pos_format;
227 pattern _M_neg_format;
229 ~moneypunct _STLP_PSPEC2(wchar_t, false) ();
231 virtual wchar_t do_decimal_point() const;
232 virtual wchar_t do_thousands_sep() const;
233 virtual string do_grouping() const;
235 virtual string_type do_curr_symbol() const;
237 virtual string_type do_positive_sign() const;
238 virtual string_type do_negative_sign() const;
239 virtual int do_frac_digits() const;
240 virtual pattern do_pos_format() const;
241 virtual pattern do_neg_format() const;
246 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
249 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true> {
250 friend class _Locale_impl;
252 typedef money_base::pattern pattern;
253 typedef char char_type;
254 typedef string string_type;
256 explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0);
259 ~moneypunct_byname _STLP_PSPEC2(char, true) ();
260 virtual char do_decimal_point() const;
261 virtual char do_thousands_sep() const;
262 virtual string do_grouping() const;
264 virtual string_type do_curr_symbol() const;
266 virtual string_type do_positive_sign() const;
267 virtual string_type do_negative_sign() const;
268 virtual int do_frac_digits() const;
271 moneypunct_byname _STLP_PSPEC2(char, true) (_Locale_monetary *__monetary);
273 typedef moneypunct_byname<char, true> _Self;
274 //explicitely defined as private to avoid warnings:
275 moneypunct_byname(_Self const&);
276 _Self& operator = (_Self const&);
278 _Locale_monetary* _M_monetary;
282 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false> {
283 friend class _Locale_impl;
285 typedef money_base::pattern pattern;
286 typedef char char_type;
287 typedef string string_type;
289 explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0);
292 ~moneypunct_byname _STLP_PSPEC2(char, false) ();
293 virtual char do_decimal_point() const;
294 virtual char do_thousands_sep() const;
295 virtual string do_grouping() const;
297 virtual string_type do_curr_symbol() const;
299 virtual string_type do_positive_sign() const;
300 virtual string_type do_negative_sign() const;
301 virtual int do_frac_digits() const;
304 moneypunct_byname _STLP_PSPEC2(char, false) (_Locale_monetary *__monetary);
306 typedef moneypunct_byname<char, false> _Self;
307 //explicitely defined as private to avoid warnings:
308 moneypunct_byname(_Self const&);
309 _Self& operator = (_Self const&);
311 _Locale_monetary* _M_monetary;
314 #if !defined (_STLP_NO_WCHAR_T)
316 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true> {
317 friend class _Locale_impl;
319 typedef money_base::pattern pattern;
320 typedef wchar_t char_type;
321 typedef wstring string_type;
323 explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0);
326 ~moneypunct_byname _STLP_PSPEC2(wchar_t, true) ();
327 virtual wchar_t do_decimal_point() const;
328 virtual wchar_t do_thousands_sep() const;
329 virtual string do_grouping() const;
331 virtual string_type do_curr_symbol() const;
333 virtual string_type do_positive_sign() const;
334 virtual string_type do_negative_sign() const;
335 virtual int do_frac_digits() const;
338 moneypunct_byname _STLP_PSPEC2(wchar_t, true) (_Locale_monetary *__monetary);
340 typedef moneypunct_byname<wchar_t, true> _Self;
341 //explicitely defined as private to avoid warnings:
342 moneypunct_byname(_Self const&);
343 _Self& operator = (_Self const&);
345 _Locale_monetary* _M_monetary;
349 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false> {
350 friend class _Locale_impl;
352 typedef money_base::pattern pattern;
353 typedef wchar_t char_type;
354 typedef wstring string_type;
356 explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0);
359 ~moneypunct_byname _STLP_PSPEC2(wchar_t, false) ();
360 virtual wchar_t do_decimal_point() const;
361 virtual wchar_t do_thousands_sep() const;
362 virtual string do_grouping() const;
364 virtual string_type do_curr_symbol() const;
366 virtual string_type do_positive_sign() const;
367 virtual string_type do_negative_sign() const;
368 virtual int do_frac_digits() const;
371 moneypunct_byname _STLP_PSPEC2(wchar_t, false) (_Locale_monetary *__monetary);
373 typedef moneypunct_byname<wchar_t, false> _Self;
374 //explicitely defined as private to avoid warnings:
375 moneypunct_byname(_Self const&);
376 _Self& operator = (_Self const&);
378 _Locale_monetary* _M_monetary;
382 //===== methods ======
387 template <class _CharT, class _OutputIter>
388 class money_put : public locale::facet {
390 typedef _CharT char_type;
391 typedef _OutputIter iter_type;
392 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
394 explicit money_put(size_t __refs = 0) : locale::facet(__refs) {}
395 iter_type put(iter_type __s, bool __intl, ios_base& __str,
396 char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const
397 { return do_put(__s, __intl, __str, __fill, __units); }
398 iter_type put(iter_type __s, bool __intl, ios_base& __str,
400 const string_type& __digits) const
401 { return do_put(__s, __intl, __str, __fill, __digits); }
403 static locale::id id;
407 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
408 char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const;
409 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
411 const string_type& __digits) const;
414 #if defined (_STLP_USE_TEMPLATE_EXPORT)
415 _STLP_EXPORT_TEMPLATE_CLASS money_get<char, istreambuf_iterator<char, char_traits<char> > >;
416 _STLP_EXPORT_TEMPLATE_CLASS money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
417 # if ! defined (_STLP_NO_WCHAR_T)
418 _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
419 _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
425 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
426 # include <stl/_monetary.c>
429 #endif /* _STLP_INTERNAL_MONETARY_H */