~ubuntu-branches/ubuntu/hardy/libterralib/hardy

« back to all changes in this revision

Viewing changes to src/STLport/stl/_monetary.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-25 22:32:59 UTC
  • Revision ID: james.westby@ubuntu.com-20051125223259-3zubal8ux4ki4fjg
Tags: upstream-3.0.3b2
ImportĀ upstreamĀ versionĀ 3.0.3b2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1999
 
3
 * Silicon Graphics Computer Systems, Inc.
 
4
 *
 
5
 * Copyright (c) 1999 
 
6
 * Boris Fomitchev
 
7
 *
 
8
 * This material is provided "as is", with absolutely no warranty expressed
 
9
 * or implied. Any use is at your own risk.
 
10
 *
 
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.
 
16
 *
 
17
 */ 
 
18
// WARNING: This is an internal header file, included by other C++
 
19
// standard library headers.  You should not attempt to use this header
 
20
// file directly.
 
21
 
 
22
 
 
23
#ifndef _STLP_INTERNAL_MONETARY_H
 
24
#define _STLP_INTERNAL_MONETARY_H
 
25
 
 
26
#ifndef _STLP_INTERNAL_CTYPE_H
 
27
# include <stl/_ctype.h>
 
28
#endif
 
29
 
 
30
#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
 
31
# include <stl/_ostreambuf_iterator.h>
 
32
#endif
 
33
 
 
34
#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
 
35
# include <stl/_istreambuf_iterator.h>
 
36
#endif
 
37
 
 
38
_STLP_BEGIN_NAMESPACE
 
39
 
 
40
class money_base {
 
41
public:
 
42
  enum part {none, space, symbol, sign, value};
 
43
  struct pattern {
 
44
    char field[4];
 
45
  };
 
46
};
 
47
 
 
48
// moneypunct facets: forward declaration
 
49
template <class _charT, __DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
 
50
 
 
51
// money_get facets
 
52
 
 
53
template <class _CharT, __DFL_TMPL_PARAM(_InputIter , istreambuf_iterator<_CharT>) >
 
54
class money_get : public locale::facet 
 
55
{
 
56
  friend class _Locale;
 
57
public:
 
58
  typedef _CharT               char_type;
 
59
  typedef _InputIter           iter_type;
 
60
  typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
 
61
 
 
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); }
 
68
# endif  
 
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); }
 
73
 
 
74
  _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
 
75
 
 
76
protected:
 
77
  ~money_get() {}
 
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;
 
82
# endif
 
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;
 
86
};
 
87
 
 
88
 
 
89
// moneypunct facets: definition of specializations
 
90
 
 
91
_STLP_TEMPLATE_NULL
 
92
class _STLP_CLASS_DECLSPEC moneypunct<char, true> : public locale::facet, public money_base 
 
93
{
 
94
 
 
95
public:
 
96
  typedef char                 char_type;
 
97
  typedef string               string_type;
 
98
  explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
 
99
 
 
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(); }
 
109
 
 
110
  _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
 
111
# if defined (_STLP_STATIC_CONST_INIT_BUG)
 
112
  enum _IntlVal { intl = 1 } ;
 
113
# else
 
114
  static const bool intl = true;
 
115
# endif
 
116
 
 
117
protected:
 
118
  pattern _M_pos_format;
 
119
  pattern _M_neg_format;
 
120
 
 
121
  ~moneypunct _STLP_PSPEC2(char, true) ();
 
122
 
 
123
  virtual char        do_decimal_point() const;
 
124
  virtual char        do_thousands_sep() const;
 
125
  virtual string      do_grouping()      const;
 
126
 
 
127
  virtual string      do_curr_symbol()   const;
 
128
 
 
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;
 
134
 
 
135
  friend class _Locale;
 
136
 
 
137
};
 
138
 
 
139
_STLP_TEMPLATE_NULL
 
140
class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base 
 
141
{
 
142
public:
 
143
  typedef char                 char_type;
 
144
  typedef string               string_type;
 
145
 
 
146
  explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
 
147
 
 
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(); }
 
157
 
 
158
  _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
 
159
# if defined (_STLP_STATIC_CONST_INIT_BUG)
 
160
  enum _IntlVal { intl = 0 } ;
 
161
# else
 
162
  static const bool intl = false;
 
163
# endif
 
164
 
 
165
protected:
 
166
  pattern _M_pos_format;
 
167
  pattern _M_neg_format;
 
168
 
 
169
  ~moneypunct _STLP_PSPEC2(char, false) ();
 
170
 
 
171
  virtual char        do_decimal_point() const;
 
172
  virtual char        do_thousands_sep() const;
 
173
  virtual string      do_grouping()      const;
 
174
 
 
175
  virtual string      do_curr_symbol()   const;
 
176
 
 
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;
 
182
 
 
183
  friend class _Locale;
 
184
};
 
185
 
 
186
 
 
187
# ifndef _STLP_NO_WCHAR_T
 
188
 
 
189
_STLP_TEMPLATE_NULL
 
190
class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base 
 
191
{
 
192
  friend class _Locale;
 
193
public:
 
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(); }
 
206
 
 
207
  _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
 
208
# if defined (_STLP_STATIC_CONST_INIT_BUG)
 
209
  enum _IntlVal { intl = 1 } ;
 
210
# else
 
211
  static const bool intl = true;
 
212
# endif
 
213
 
 
214
protected:
 
215
  pattern _M_pos_format;
 
216
  pattern _M_neg_format;
 
217
 
 
218
  ~moneypunct _STLP_PSPEC2(wchar_t, true) ();
 
219
 
 
220
  virtual wchar_t     do_decimal_point() const;
 
221
  virtual wchar_t     do_thousands_sep() const;
 
222
  virtual string      do_grouping()      const;
 
223
 
 
224
  virtual string_type do_curr_symbol()   const;
 
225
 
 
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;
 
231
};
 
232
 
 
233
 
 
234
_STLP_TEMPLATE_NULL
 
235
class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base 
 
236
{
 
237
  friend class _Locale;
 
238
public:
 
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(); }
 
251
 
 
252
  _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
 
253
# if defined (_STLP_STATIC_CONST_INIT_BUG)
 
254
  enum _IntlVal { intl = 0 } ;
 
255
# else
 
256
  static const bool intl = false;
 
257
# endif
 
258
 
 
259
protected:
 
260
  pattern _M_pos_format;
 
261
  pattern _M_neg_format;
 
262
 
 
263
  ~moneypunct _STLP_PSPEC2(wchar_t, false) ();
 
264
 
 
265
  virtual wchar_t     do_decimal_point() const;
 
266
  virtual wchar_t     do_thousands_sep() const;
 
267
  virtual string      do_grouping()      const;
 
268
 
 
269
  virtual string_type do_curr_symbol()   const;
 
270
 
 
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;
 
276
};
 
277
 
 
278
# endif
 
279
 
 
280
template <class _charT, __DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
 
281
 
 
282
_STLP_TEMPLATE_NULL
 
283
class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true> 
 
284
{
 
285
public:
 
286
  typedef money_base::pattern   pattern;
 
287
  typedef char                  char_type;
 
288
  typedef string                string_type;
 
289
 
 
290
  explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0);
 
291
 
 
292
protected:
 
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;
 
298
 
 
299
  virtual string_type do_curr_symbol()   const;
 
300
 
 
301
  virtual string_type do_positive_sign() const;
 
302
  virtual string_type do_negative_sign() const;
 
303
  virtual int         do_frac_digits()   const;
 
304
};
 
305
 
 
306
_STLP_TEMPLATE_NULL
 
307
class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false> 
 
308
{
 
309
public:
 
310
  typedef money_base::pattern   pattern;
 
311
  typedef char                  char_type;
 
312
  typedef string                string_type;
 
313
 
 
314
  explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0);
 
315
 
 
316
protected:
 
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;
 
322
 
 
323
  virtual string_type do_curr_symbol()   const;
 
324
 
 
325
  virtual string_type do_positive_sign() const;
 
326
  virtual string_type do_negative_sign() const;
 
327
  virtual int         do_frac_digits()   const;
 
328
};
 
329
 
 
330
# ifndef _STLP_NO_WCHAR_T
 
331
_STLP_TEMPLATE_NULL
 
332
class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true> 
 
333
{
 
334
public:
 
335
  typedef money_base::pattern   pattern;
 
336
  typedef wchar_t               char_type;
 
337
  typedef wstring               string_type;
 
338
 
 
339
  explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0);
 
340
 
 
341
protected:
 
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;
 
347
 
 
348
  virtual string_type do_curr_symbol()   const;
 
349
 
 
350
  virtual string_type do_positive_sign() const;
 
351
  virtual string_type do_negative_sign() const;
 
352
  virtual int         do_frac_digits()   const;
 
353
};
 
354
 
 
355
_STLP_TEMPLATE_NULL
 
356
class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false> 
 
357
{
 
358
public:
 
359
  typedef money_base::pattern   pattern;
 
360
  typedef wchar_t               char_type;
 
361
  typedef wstring               string_type;
 
362
 
 
363
  explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0);
 
364
 
 
365
protected:
 
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;
 
371
 
 
372
  virtual string_type do_curr_symbol()   const;
 
373
 
 
374
  virtual string_type do_positive_sign() const;
 
375
  virtual string_type do_negative_sign() const;
 
376
  virtual int         do_frac_digits()   const;
 
377
};
 
378
# endif
 
379
 
 
380
//===== methods ======
 
381
 
 
382
 
 
383
// money_put facets
 
384
 
 
385
template <class _CharT, __DFL_TMPL_PARAM( _OutputIter , ostreambuf_iterator<_CharT>) >
 
386
class money_put : public locale::facet {
 
387
  friend class _Locale;
 
388
 
 
389
public:
 
390
  typedef _CharT               char_type;
 
391
  typedef _OutputIter          iter_type;
 
392
  typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
 
393
 
 
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); }
 
399
# endif
 
400
  iter_type put(iter_type __s, bool __intl, ios_base& __str,
 
401
                char_type  __fill, 
 
402
                const string_type& __digits) const
 
403
    { return do_put(__s, __intl, __str, __fill, __digits); }
 
404
 
 
405
  _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
 
406
 
 
407
protected:
 
408
  ~money_put() {}
 
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 {
 
412
 
 
413
    locale __loc = __str.getloc();
 
414
    _CharT  __buf[64];
 
415
    return do_put(__s, __intl, __str, __fill, __buf + 0);
 
416
  }
 
417
# endif    
 
418
  virtual iter_type do_put(iter_type __s, bool  __intl, ios_base&  __str,
 
419
                           char_type __fill,
 
420
                           const string_type& __digits) const;
 
421
};
 
422
 
 
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* >;
 
433
#  endif
 
434
# endif /* _STLP_USE_TEMPLATE_EXPORT */
 
435
 
 
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;
 
447
# endif  
 
448
}
 
449
#endif
 
450
 
 
451
_STLP_END_NAMESPACE
 
452
 
 
453
# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
 
454
#  include <stl/_monetary.c>
 
455
# endif
 
456
 
 
457
#endif /* _STLP_INTERNAL_MONETARY_H */
 
458
 
 
459
// Local Variables:
 
460
// mode:C++
 
461
// End:
 
462
 
 
463