2 * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
5 * Silicon Graphics Computer Systems, Inc.
10 * This material is provided "as is", with absolutely no warranty expressed
11 * or implied. Any use is at your own risk.
13 * Permission to use or copy this software for any purpose is hereby granted
14 * without fee, provided the above notices are retained on all copies.
15 * Permission to modify the code and to distribute modified code is granted,
16 * provided the above notices are retained, and a notice that the code was
17 * modified is included with the above copyright notice.
20 // WARNING: This is an internal header file, included by other C++
21 // standard library headers. You should not attempt to use this header
25 #ifndef _STLP_INTERNAL_MONETARY_H
26 #define _STLP_INTERNAL_MONETARY_H
28 #ifndef _STLP_INTERNAL_CTYPE_H
29 # include <stl/_ctype.h>
32 #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
33 # include <stl/_ostreambuf_iterator.h>
36 #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
37 # include <stl/_istreambuf_iterator.h>
44 enum part {none, space, symbol, sign, value};
50 // moneypunct facets: forward declaration
51 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
55 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
56 template <class _CharT, class _InputIter>
58 template <class _CharT, class _InputIter = istreambuf_iterator<_CharT, char_traits<_CharT> > >
60 class money_get : public locale::facet {
61 friend class _Locale_impl;
64 typedef _CharT char_type;
65 typedef _InputIter iter_type;
66 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
68 money_get(size_t __refs = 0) : locale::facet(__refs) {}
69 iter_type get(iter_type __s, iter_type __end, bool __intl,
70 ios_base& __str, ios_base::iostate& __err,
71 _STLP_LONGEST_FLOAT_TYPE& __units) const
72 { return do_get(__s, __end, __intl, __str, __err, __units); }
73 iter_type get(iter_type __s, iter_type __end, bool __intl,
74 ios_base& __str, ios_base::iostate& __err,
75 string_type& __digits) const
76 { return do_get(__s, __end, __intl, __str, __err, __digits); }
78 #if defined(__SYMBIAN32__WSD__)
79 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
80 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
81 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
84 // NOTE: Symbian doesn't support exporting static data.
85 // Users of this class should use GetFacetLocaleId() to access the data member id
86 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
91 virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
92 ios_base& __str, ios_base::iostate& __err,
93 _STLP_LONGEST_FLOAT_TYPE& __units) const;
94 virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
95 ios_base& __str, ios_base::iostate& __err,
96 string_type& __digits) const;
100 // moneypunct facets: definition of specializations
103 class _STLP_CLASS_DECLSPEC moneypunct<char, true> : public locale::facet, public money_base {
106 typedef char char_type;
107 typedef string string_type;
108 _STLP_DECLSPEC explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
110 char decimal_point() const { return do_decimal_point(); }
111 char thousands_sep() const { return do_thousands_sep(); }
112 string grouping() const { return do_grouping(); }
113 string_type curr_symbol() const { return do_curr_symbol(); }
114 string_type positive_sign() const { return do_positive_sign(); }
115 string_type negative_sign() const { return do_negative_sign(); }
116 int frac_digits() const { return do_frac_digits(); }
117 pattern pos_format() const { return do_pos_format(); }
118 pattern neg_format() const { return do_neg_format(); }
120 #if defined(__SYMBIAN32__WSD__)
121 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
122 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
123 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
124 static locale::id id;
126 // NOTE: Symbian doesn't support exporting static data.
127 // Users of this class should use GetFacetLocaleId() to access the data member id
128 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
130 # if defined (_STLP_STATIC_CONST_INIT_BUG)
131 enum _IntlVal { intl = 1 } ;
133 static const bool intl = true;
137 pattern _M_pos_format;
138 pattern _M_neg_format;
140 _STLP_DECLSPEC ~moneypunct _STLP_PSPEC2(char, true) ();
142 _STLP_DECLSPEC virtual char do_decimal_point() const;
143 _STLP_DECLSPEC virtual char do_thousands_sep() const;
144 _STLP_DECLSPEC virtual string do_grouping() const;
146 _STLP_DECLSPEC virtual string do_curr_symbol() const;
148 _STLP_DECLSPEC virtual string do_positive_sign() const;
149 _STLP_DECLSPEC virtual string do_negative_sign() const;
150 _STLP_DECLSPEC virtual int do_frac_digits() const;
151 _STLP_DECLSPEC virtual pattern do_pos_format() const;
152 _STLP_DECLSPEC virtual pattern do_neg_format() const;
154 friend class _Locale_impl;
158 class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base
161 typedef char char_type;
162 typedef string string_type;
164 _STLP_DECLSPEC explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
166 char decimal_point() const { return do_decimal_point(); }
167 char thousands_sep() const { return do_thousands_sep(); }
168 string grouping() const { return do_grouping(); }
169 string_type curr_symbol() const { return do_curr_symbol(); }
170 string_type positive_sign() const { return do_positive_sign(); }
171 string_type negative_sign() const { return do_negative_sign(); }
172 int frac_digits() const { return do_frac_digits(); }
173 pattern pos_format() const { return do_pos_format(); }
174 pattern neg_format() const { return do_neg_format(); }
176 #if defined(__SYMBIAN32__WSD__)
177 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
178 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
179 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
180 static locale::id id;
182 // NOTE: Symbian doesn't support exporting static data.
183 // Users of this class should use GetFacetLocaleId() to access the data member id
184 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
187 # if defined (_STLP_STATIC_CONST_INIT_BUG)
188 enum _IntlVal { intl = 0 } ;
190 static const bool intl = false;
194 pattern _M_pos_format;
195 pattern _M_neg_format;
197 _STLP_DECLSPEC ~moneypunct _STLP_PSPEC2(char, false) ();
199 _STLP_DECLSPEC virtual char do_decimal_point() const;
200 _STLP_DECLSPEC virtual char do_thousands_sep() const;
201 _STLP_DECLSPEC virtual string do_grouping() const;
203 _STLP_DECLSPEC virtual string do_curr_symbol() const;
205 _STLP_DECLSPEC virtual string do_positive_sign() const;
206 _STLP_DECLSPEC virtual string do_negative_sign() const;
207 _STLP_DECLSPEC virtual int do_frac_digits() const;
208 _STLP_DECLSPEC virtual pattern do_pos_format() const;
209 _STLP_DECLSPEC virtual pattern do_neg_format() const;
211 friend class _Locale_impl;
215 # ifndef _STLP_NO_WCHAR_T
218 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base
220 friend class _Locale_impl;
222 typedef wchar_t char_type;
223 typedef wstring string_type;
224 _STLP_DECLSPEC explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0);
225 wchar_t decimal_point() const { return do_decimal_point(); }
226 wchar_t thousands_sep() const { return do_thousands_sep(); }
227 string grouping() const { return do_grouping(); }
228 string_type curr_symbol() const { return do_curr_symbol(); }
229 string_type positive_sign() const { return do_positive_sign(); }
230 string_type negative_sign() const { return do_negative_sign(); }
231 int frac_digits() const { return do_frac_digits(); }
232 pattern pos_format() const { return do_pos_format(); }
233 pattern neg_format() const { return do_neg_format(); }
235 #if defined(__SYMBIAN32__WSD__)
236 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
237 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
238 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
239 static locale::id id;
241 // NOTE: Symbian doesn't support exporting static data.
242 // Users of this class should use GetFacetLocaleId() to access the data member id
243 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
246 # if defined (_STLP_STATIC_CONST_INIT_BUG)
247 enum _IntlVal { intl = 1 } ;
249 static const bool intl = true;
253 pattern _M_pos_format;
254 pattern _M_neg_format;
256 _STLP_DECLSPEC ~moneypunct _STLP_PSPEC2(wchar_t, true) ();
258 _STLP_DECLSPEC virtual wchar_t do_decimal_point() const;
259 _STLP_DECLSPEC virtual wchar_t do_thousands_sep() const;
260 _STLP_DECLSPEC virtual string do_grouping() const;
262 _STLP_DECLSPEC virtual string_type do_curr_symbol() const;
264 _STLP_DECLSPEC virtual string_type do_positive_sign() const;
265 _STLP_DECLSPEC virtual string_type do_negative_sign() const;
266 _STLP_DECLSPEC virtual int do_frac_digits() const;
267 _STLP_DECLSPEC virtual pattern do_pos_format() const;
268 _STLP_DECLSPEC virtual pattern do_neg_format() const;
273 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base
275 friend class _Locale_impl;
277 typedef wchar_t char_type;
278 typedef wstring string_type;
279 _STLP_DECLSPEC explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0);
280 wchar_t decimal_point() const { return do_decimal_point(); }
281 wchar_t thousands_sep() const { return do_thousands_sep(); }
282 string grouping() const { return do_grouping(); }
283 string_type curr_symbol() const { return do_curr_symbol(); }
284 string_type positive_sign() const { return do_positive_sign(); }
285 string_type negative_sign() const { return do_negative_sign(); }
286 int frac_digits() const { return do_frac_digits(); }
287 pattern pos_format() const { return do_pos_format(); }
288 pattern neg_format() const { return do_neg_format(); }
290 #if defined(__SYMBIAN32__WSD__)
291 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
292 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
293 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
294 static locale::id id;
296 // NOTE: Symbian doesn't support exporting static data.
297 // Users of this class should use GetFacetLocaleId() to access the data member id
298 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
301 # if defined (_STLP_STATIC_CONST_INIT_BUG)
302 enum _IntlVal { intl = 0 } ;
304 static const bool intl = false;
308 pattern _M_pos_format;
309 pattern _M_neg_format;
311 _STLP_DECLSPEC ~moneypunct _STLP_PSPEC2(wchar_t, false) ();
313 _STLP_DECLSPEC virtual wchar_t do_decimal_point() const;
314 _STLP_DECLSPEC virtual wchar_t do_thousands_sep() const;
315 _STLP_DECLSPEC virtual string do_grouping() const;
317 _STLP_DECLSPEC virtual string_type do_curr_symbol() const;
319 _STLP_DECLSPEC virtual string_type do_positive_sign() const;
320 _STLP_DECLSPEC virtual string_type do_negative_sign() const;
321 _STLP_DECLSPEC virtual int do_frac_digits() const;
322 _STLP_DECLSPEC virtual pattern do_pos_format() const;
323 _STLP_DECLSPEC virtual pattern do_neg_format() const;
328 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
331 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true> {
333 typedef money_base::pattern pattern;
334 typedef char char_type;
335 typedef string string_type;
337 _STLP_DECLSPEC explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0,
338 _Locale_name_hint* __hint = 0);
341 _Locale_monetary* _M_monetary;
342 _STLP_DECLSPEC ~moneypunct_byname _STLP_PSPEC2(char, true) ();
343 _STLP_DECLSPEC virtual char do_decimal_point() const;
344 _STLP_DECLSPEC virtual char do_thousands_sep() const;
345 _STLP_DECLSPEC virtual string do_grouping() const;
347 _STLP_DECLSPEC virtual string_type do_curr_symbol() const;
349 _STLP_DECLSPEC virtual string_type do_positive_sign() const;
350 _STLP_DECLSPEC virtual string_type do_negative_sign() const;
351 _STLP_DECLSPEC virtual int do_frac_digits() const;
354 typedef moneypunct_byname<char, true> _Self;
355 //explicitely defined as private to avoid warnings:
356 moneypunct_byname(_Self const&);
357 _Self& operator = (_Self const&);
361 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false>
364 typedef money_base::pattern pattern;
365 typedef char char_type;
366 typedef string string_type;
368 _STLP_DECLSPEC explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0,
369 _Locale_name_hint* __hint = 0);
372 _Locale_monetary* _M_monetary;
373 _STLP_DECLSPEC ~moneypunct_byname _STLP_PSPEC2(char, false) ();
374 _STLP_DECLSPEC virtual char do_decimal_point() const;
375 _STLP_DECLSPEC virtual char do_thousands_sep() const;
376 _STLP_DECLSPEC virtual string do_grouping() const;
378 _STLP_DECLSPEC virtual string_type do_curr_symbol() const;
380 _STLP_DECLSPEC virtual string_type do_positive_sign() const;
381 _STLP_DECLSPEC virtual string_type do_negative_sign() const;
382 _STLP_DECLSPEC virtual int do_frac_digits() const;
385 typedef moneypunct_byname<char, false> _Self;
386 //explicitely defined as private to avoid warnings:
387 moneypunct_byname(_Self const&);
388 _Self& operator = (_Self const&);
389 friend _Locale_name_hint* _Locale_extract_hint(moneypunct_byname<char, false>*);
392 #if !defined (_STLP_NO_WCHAR_T)
394 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true>
397 typedef money_base::pattern pattern;
398 typedef wchar_t char_type;
399 typedef wstring string_type;
401 _STLP_DECLSPEC explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0,
402 _Locale_name_hint* __hint = 0);
405 _Locale_monetary* _M_monetary;
406 _STLP_DECLSPEC ~moneypunct_byname _STLP_PSPEC2(wchar_t, true) ();
407 _STLP_DECLSPEC virtual wchar_t do_decimal_point() const;
408 _STLP_DECLSPEC virtual wchar_t do_thousands_sep() const;
409 _STLP_DECLSPEC virtual string do_grouping() const;
411 _STLP_DECLSPEC virtual string_type do_curr_symbol() const;
413 _STLP_DECLSPEC virtual string_type do_positive_sign() const;
414 _STLP_DECLSPEC virtual string_type do_negative_sign() const;
415 _STLP_DECLSPEC virtual int do_frac_digits() const;
418 typedef moneypunct_byname<wchar_t, true> _Self;
419 //explicitely defined as private to avoid warnings:
420 moneypunct_byname(_Self const&);
421 _Self& operator = (_Self const&);
425 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false>
428 typedef money_base::pattern pattern;
429 typedef wchar_t char_type;
430 typedef wstring string_type;
432 _STLP_DECLSPEC explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0,
433 _Locale_name_hint* __hint = 0);
436 _Locale_monetary* _M_monetary;
437 _STLP_DECLSPEC ~moneypunct_byname _STLP_PSPEC2(wchar_t, false) ();
438 _STLP_DECLSPEC virtual wchar_t do_decimal_point() const;
439 _STLP_DECLSPEC virtual wchar_t do_thousands_sep() const;
440 _STLP_DECLSPEC virtual string do_grouping() const;
442 _STLP_DECLSPEC virtual string_type do_curr_symbol() const;
444 _STLP_DECLSPEC virtual string_type do_positive_sign() const;
445 _STLP_DECLSPEC virtual string_type do_negative_sign() const;
446 _STLP_DECLSPEC virtual int do_frac_digits() const;
449 typedef moneypunct_byname<wchar_t, false> _Self;
450 //explicitely defined as private to avoid warnings:
451 moneypunct_byname(_Self const&);
452 _Self& operator = (_Self const&);
456 //===== methods ======
461 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
462 template <class _CharT, class _OutputIter>
464 template <class _CharT, class _OutputIter = ostreambuf_iterator<_CharT, char_traits<_CharT> > >
466 class money_put : public locale::facet {
467 friend class _Locale_impl;
470 typedef _CharT char_type;
471 typedef _OutputIter iter_type;
472 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
474 money_put(size_t __refs = 0) : locale::facet(__refs) {}
475 iter_type put(iter_type __s, bool __intl, ios_base& __str,
476 char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const
477 { return do_put(__s, __intl, __str, __fill, __units); }
478 iter_type put(iter_type __s, bool __intl, ios_base& __str,
480 const string_type& __digits) const
481 { return do_put(__s, __intl, __str, __fill, __digits); }
483 #if defined(__SYMBIAN32__WSD__)
484 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
485 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
486 static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
487 static locale::id id;
489 // NOTE: Symbian doesn't support exporting static data.
490 // Users of this class should use GetFacetLocaleId() to access the data member id
491 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
496 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
497 char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const;
498 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
500 const string_type& __digits) const;
503 # if defined (_STLP_USE_TEMPLATE_EXPORT)
504 _STLP_EXPORT_TEMPLATE_CLASS money_get<char, istreambuf_iterator<char, char_traits<char> > >;
505 _STLP_EXPORT_TEMPLATE_CLASS money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
506 //_STLP_EXPORT_TEMPLATE_CLASS money_get<char, const char* >;
507 //_STLP_EXPORT_TEMPLATE_CLASS money_put<char, char* >;
508 # if ! defined (_STLP_NO_WCHAR_T)
509 _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
510 _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
511 // _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, const wchar_t* >;
512 // _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, wchar_t* >;
514 # endif /* _STLP_USE_TEMPLATE_EXPORT */
518 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
519 # include <stl/_monetary.c>
522 #endif /* _STLP_INTERNAL_MONETARY_H */