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, _STLP_DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
53 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
54 template <class _CharT, class _InputIter>
56 template <class _CharT, class _InputIter = istreambuf_iterator<_CharT, char_traits<_CharT> > >
58 class money_get : public locale::facet {
59 friend class _Locale_impl;
62 typedef _CharT char_type;
63 typedef _InputIter iter_type;
64 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
66 money_get(size_t __refs = 0) : locale::facet(__refs) {}
67 iter_type get(iter_type __s, iter_type __end, bool __intl,
68 ios_base& __str, ios_base::iostate& __err,
69 _STLP_LONGEST_FLOAT_TYPE& __units) const
70 { return do_get(__s, __end, __intl, __str, __err, __units); }
71 iter_type get(iter_type __s, iter_type __end, bool __intl,
72 ios_base& __str, ios_base::iostate& __err,
73 string_type& __digits) const
74 { return do_get(__s, __end, __intl, __str, __err, __digits); }
76 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
80 virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
81 ios_base& __str, ios_base::iostate& __err,
82 _STLP_LONGEST_FLOAT_TYPE& __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 {
95 typedef char char_type;
96 typedef string string_type;
97 explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
99 char decimal_point() const { return do_decimal_point(); }
100 char thousands_sep() const { return do_thousands_sep(); }
101 string grouping() const { return do_grouping(); }
102 string_type curr_symbol() const { return do_curr_symbol(); }
103 string_type positive_sign() const { return do_positive_sign(); }
104 string_type negative_sign() const { return do_negative_sign(); }
105 int frac_digits() const { return do_frac_digits(); }
106 pattern pos_format() const { return do_pos_format(); }
107 pattern neg_format() const { return do_neg_format(); }
109 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
110 # if defined (_STLP_STATIC_CONST_INIT_BUG)
111 enum _IntlVal { intl = 1 } ;
113 static const bool intl = true;
117 pattern _M_pos_format;
118 pattern _M_neg_format;
120 ~moneypunct _STLP_PSPEC2(char, true) ();
122 virtual char do_decimal_point() const;
123 virtual char do_thousands_sep() const;
124 virtual string do_grouping() const;
126 virtual string do_curr_symbol() const;
128 virtual string do_positive_sign() const;
129 virtual string do_negative_sign() const;
130 virtual int do_frac_digits() const;
131 virtual pattern do_pos_format() const;
132 virtual pattern do_neg_format() const;
134 friend class _Locale_impl;
138 class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base
141 typedef char char_type;
142 typedef string string_type;
144 explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
146 char decimal_point() const { return do_decimal_point(); }
147 char thousands_sep() const { return do_thousands_sep(); }
148 string grouping() const { return do_grouping(); }
149 string_type curr_symbol() const { return do_curr_symbol(); }
150 string_type positive_sign() const { return do_positive_sign(); }
151 string_type negative_sign() const { return do_negative_sign(); }
152 int frac_digits() const { return do_frac_digits(); }
153 pattern pos_format() const { return do_pos_format(); }
154 pattern neg_format() const { return do_neg_format(); }
156 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
157 # if defined (_STLP_STATIC_CONST_INIT_BUG)
158 enum _IntlVal { intl = 0 } ;
160 static const bool intl = false;
164 pattern _M_pos_format;
165 pattern _M_neg_format;
167 ~moneypunct _STLP_PSPEC2(char, false) ();
169 virtual char do_decimal_point() const;
170 virtual char do_thousands_sep() const;
171 virtual string do_grouping() const;
173 virtual string do_curr_symbol() const;
175 virtual string do_positive_sign() const;
176 virtual string do_negative_sign() const;
177 virtual int do_frac_digits() const;
178 virtual pattern do_pos_format() const;
179 virtual pattern do_neg_format() const;
181 friend class _Locale_impl;
185 # ifndef _STLP_NO_WCHAR_T
188 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base
190 friend class _Locale_impl;
192 typedef wchar_t char_type;
193 typedef wstring string_type;
194 explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0);
195 wchar_t decimal_point() const { return do_decimal_point(); }
196 wchar_t thousands_sep() const { return do_thousands_sep(); }
197 string grouping() const { return do_grouping(); }
198 string_type curr_symbol() const { return do_curr_symbol(); }
199 string_type positive_sign() const { return do_positive_sign(); }
200 string_type negative_sign() const { return do_negative_sign(); }
201 int frac_digits() const { return do_frac_digits(); }
202 pattern pos_format() const { return do_pos_format(); }
203 pattern neg_format() const { return do_neg_format(); }
205 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
206 # if defined (_STLP_STATIC_CONST_INIT_BUG)
207 enum _IntlVal { intl = 1 } ;
209 static const bool intl = true;
213 pattern _M_pos_format;
214 pattern _M_neg_format;
216 ~moneypunct _STLP_PSPEC2(wchar_t, true) ();
218 virtual wchar_t do_decimal_point() const;
219 virtual wchar_t do_thousands_sep() const;
220 virtual string do_grouping() const;
222 virtual string_type do_curr_symbol() const;
224 virtual string_type do_positive_sign() const;
225 virtual string_type do_negative_sign() const;
226 virtual int do_frac_digits() const;
227 virtual pattern do_pos_format() const;
228 virtual pattern do_neg_format() const;
233 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base
235 friend class _Locale_impl;
237 typedef wchar_t char_type;
238 typedef wstring string_type;
239 explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0);
240 wchar_t decimal_point() const { return do_decimal_point(); }
241 wchar_t thousands_sep() const { return do_thousands_sep(); }
242 string grouping() const { return do_grouping(); }
243 string_type curr_symbol() const { return do_curr_symbol(); }
244 string_type positive_sign() const { return do_positive_sign(); }
245 string_type negative_sign() const { return do_negative_sign(); }
246 int frac_digits() const { return do_frac_digits(); }
247 pattern pos_format() const { return do_pos_format(); }
248 pattern neg_format() const { return do_neg_format(); }
250 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
251 # if defined (_STLP_STATIC_CONST_INIT_BUG)
252 enum _IntlVal { intl = 0 } ;
254 static const bool intl = false;
258 pattern _M_pos_format;
259 pattern _M_neg_format;
261 ~moneypunct _STLP_PSPEC2(wchar_t, false) ();
263 virtual wchar_t do_decimal_point() const;
264 virtual wchar_t do_thousands_sep() const;
265 virtual string do_grouping() const;
267 virtual string_type do_curr_symbol() const;
269 virtual string_type do_positive_sign() const;
270 virtual string_type do_negative_sign() const;
271 virtual int do_frac_digits() const;
272 virtual pattern do_pos_format() const;
273 virtual pattern do_neg_format() const;
278 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
281 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true> {
283 typedef money_base::pattern pattern;
284 typedef char char_type;
285 typedef string string_type;
287 explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0,
288 _Locale_name_hint* __hint = 0);
291 _Locale_monetary* _M_monetary;
292 ~moneypunct_byname _STLP_PSPEC2(char, true) ();
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 typedef moneypunct_byname<char, true> _Self;
305 //explicitely defined as private to avoid warnings:
306 moneypunct_byname(_Self const&);
307 _Self& operator = (_Self const&);
311 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false>
314 typedef money_base::pattern pattern;
315 typedef char char_type;
316 typedef string string_type;
318 explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0,
319 _Locale_name_hint* __hint = 0);
322 _Locale_monetary* _M_monetary;
323 ~moneypunct_byname _STLP_PSPEC2(char, false) ();
324 virtual char do_decimal_point() const;
325 virtual char do_thousands_sep() const;
326 virtual string do_grouping() const;
328 virtual string_type do_curr_symbol() const;
330 virtual string_type do_positive_sign() const;
331 virtual string_type do_negative_sign() const;
332 virtual int do_frac_digits() const;
335 typedef moneypunct_byname<char, false> _Self;
336 //explicitely defined as private to avoid warnings:
337 moneypunct_byname(_Self const&);
338 _Self& operator = (_Self const&);
339 friend _Locale_name_hint* _Locale_extract_hint(moneypunct_byname<char, false>*);
342 #if !defined (_STLP_NO_WCHAR_T)
344 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true>
347 typedef money_base::pattern pattern;
348 typedef wchar_t char_type;
349 typedef wstring string_type;
351 explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0,
352 _Locale_name_hint* __hint = 0);
355 _Locale_monetary* _M_monetary;
356 ~moneypunct_byname _STLP_PSPEC2(wchar_t, true) ();
357 virtual wchar_t do_decimal_point() const;
358 virtual wchar_t do_thousands_sep() const;
359 virtual string do_grouping() const;
361 virtual string_type do_curr_symbol() const;
363 virtual string_type do_positive_sign() const;
364 virtual string_type do_negative_sign() const;
365 virtual int do_frac_digits() const;
368 typedef moneypunct_byname<wchar_t, true> _Self;
369 //explicitely defined as private to avoid warnings:
370 moneypunct_byname(_Self const&);
371 _Self& operator = (_Self const&);
375 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false>
378 typedef money_base::pattern pattern;
379 typedef wchar_t char_type;
380 typedef wstring string_type;
382 explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0,
383 _Locale_name_hint* __hint = 0);
386 _Locale_monetary* _M_monetary;
387 ~moneypunct_byname _STLP_PSPEC2(wchar_t, false) ();
388 virtual wchar_t do_decimal_point() const;
389 virtual wchar_t do_thousands_sep() const;
390 virtual string do_grouping() const;
392 virtual string_type do_curr_symbol() const;
394 virtual string_type do_positive_sign() const;
395 virtual string_type do_negative_sign() const;
396 virtual int do_frac_digits() const;
399 typedef moneypunct_byname<wchar_t, false> _Self;
400 //explicitely defined as private to avoid warnings:
401 moneypunct_byname(_Self const&);
402 _Self& operator = (_Self const&);
406 //===== methods ======
411 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
412 template <class _CharT, class _OutputIter>
414 template <class _CharT, class _OutputIter = ostreambuf_iterator<_CharT, char_traits<_CharT> > >
416 class money_put : public locale::facet {
417 friend class _Locale_impl;
420 typedef _CharT char_type;
421 typedef _OutputIter iter_type;
422 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
424 money_put(size_t __refs = 0) : locale::facet(__refs) {}
425 iter_type put(iter_type __s, bool __intl, ios_base& __str,
426 char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const
427 { return do_put(__s, __intl, __str, __fill, __units); }
428 iter_type put(iter_type __s, bool __intl, ios_base& __str,
430 const string_type& __digits) const
431 { return do_put(__s, __intl, __str, __fill, __digits); }
433 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
437 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
438 char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const;
439 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
441 const string_type& __digits) const;
444 # if defined (_STLP_USE_TEMPLATE_EXPORT)
445 _STLP_EXPORT_TEMPLATE_CLASS money_get<char, istreambuf_iterator<char, char_traits<char> > >;
446 _STLP_EXPORT_TEMPLATE_CLASS money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
447 //_STLP_EXPORT_TEMPLATE_CLASS money_get<char, const char* >;
448 //_STLP_EXPORT_TEMPLATE_CLASS money_put<char, char* >;
449 # if ! defined (_STLP_NO_WCHAR_T)
450 _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
451 _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
452 // _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, const wchar_t* >;
453 // _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, wchar_t* >;
455 # endif /* _STLP_USE_TEMPLATE_EXPORT */
459 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
460 # include <stl/_monetary.c>
463 #endif /* _STLP_INTERNAL_MONETARY_H */