00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _STLP_INTERNAL_MONETARY_H
00024 #define _STLP_INTERNAL_MONETARY_H
00025
00026 #ifndef _STLP_INTERNAL_CTYPE_H
00027 # include <stl/_ctype.h>
00028 #endif
00029
00030 #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
00031 # include <stl/_ostreambuf_iterator.h>
00032 #endif
00033
00034 #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
00035 # include <stl/_istreambuf_iterator.h>
00036 #endif
00037
00038 _STLP_BEGIN_NAMESPACE
00039
00040 class money_base {
00041 public:
00042 enum part {none, space, symbol, sign, value};
00043 struct pattern {
00044 char field[4];
00045 };
00046 };
00047
00048
00049 template <class _charT, __DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
00050
00051
00052
00053 template <class _CharT, __DFL_TMPL_PARAM(_InputIter , istreambuf_iterator<_CharT>) >
00054 class money_get : public locale::facet
00055 {
00056 friend class _Locale;
00057 public:
00058 typedef _CharT char_type;
00059 typedef _InputIter iter_type;
00060 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
00061
00062 money_get(size_t __refs = 0) : _BaseFacet(__refs) {}
00063 # ifndef _STLP_NO_LONG_DOUBLE
00064 iter_type get(iter_type __s, iter_type __end, bool __intl,
00065 ios_base& __str, ios_base::iostate& __err,
00066 long double& __units) const
00067 { return do_get(__s, __end, __intl, __str, __err, __units); }
00068 # endif
00069 iter_type get(iter_type __s, iter_type __end, bool __intl,
00070 ios_base& __str, ios_base::iostate& __err,
00071 string_type& __digits) const
00072 { return do_get(__s, __end, __intl, __str, __err, __digits); }
00073
00074 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00075
00076 protected:
00077 ~money_get() {}
00078 # ifndef _STLP_NO_LONG_DOUBLE
00079 virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
00080 ios_base& __str, ios_base::iostate& __err,
00081 long double& __units) const;
00082 # endif
00083 virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
00084 ios_base& __str, ios_base::iostate& __err,
00085 string_type& __digits) const;
00086 };
00087
00088
00089
00090
00091 _STLP_TEMPLATE_NULL
00092 class _STLP_CLASS_DECLSPEC moneypunct<char, true> : public locale::facet, public money_base
00093 {
00094
00095 public:
00096 typedef char char_type;
00097 typedef string string_type;
00098 explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
00099
00100 char decimal_point() const { return do_decimal_point(); }
00101 char thousands_sep() const { return do_thousands_sep(); }
00102 string grouping() const { return do_grouping(); }
00103 string_type curr_symbol() const { return do_curr_symbol(); }
00104 string_type positive_sign() const { return do_positive_sign(); }
00105 string_type negative_sign() const { return do_negative_sign(); }
00106 int frac_digits() const { return do_frac_digits(); }
00107 pattern pos_format() const { return do_pos_format(); }
00108 pattern neg_format() const { return do_neg_format(); }
00109
00110 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00111 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00112 enum _IntlVal { intl = 1 } ;
00113 # else
00114 static const bool intl = true;
00115 # endif
00116
00117 protected:
00118 pattern _M_pos_format;
00119 pattern _M_neg_format;
00120
00121 ~moneypunct _STLP_PSPEC2(char, true) ();
00122
00123 virtual char do_decimal_point() const;
00124 virtual char do_thousands_sep() const;
00125 virtual string do_grouping() const;
00126
00127 virtual string do_curr_symbol() const;
00128
00129 virtual string do_positive_sign() const;
00130 virtual string do_negative_sign() const;
00131 virtual int do_frac_digits() const;
00132 virtual pattern do_pos_format() const;
00133 virtual pattern do_neg_format() const;
00134
00135 friend class _Locale;
00136
00137 };
00138
00139 _STLP_TEMPLATE_NULL
00140 class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base
00141 {
00142 public:
00143 typedef char char_type;
00144 typedef string string_type;
00145
00146 explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
00147
00148 char decimal_point() const { return do_decimal_point(); }
00149 char thousands_sep() const { return do_thousands_sep(); }
00150 string grouping() const { return do_grouping(); }
00151 string_type curr_symbol() const { return do_curr_symbol(); }
00152 string_type positive_sign() const { return do_positive_sign(); }
00153 string_type negative_sign() const { return do_negative_sign(); }
00154 int frac_digits() const { return do_frac_digits(); }
00155 pattern pos_format() const { return do_pos_format(); }
00156 pattern neg_format() const { return do_neg_format(); }
00157
00158 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00159 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00160 enum _IntlVal { intl = 0 } ;
00161 # else
00162 static const bool intl = false;
00163 # endif
00164
00165 protected:
00166 pattern _M_pos_format;
00167 pattern _M_neg_format;
00168
00169 ~moneypunct _STLP_PSPEC2(char, false) ();
00170
00171 virtual char do_decimal_point() const;
00172 virtual char do_thousands_sep() const;
00173 virtual string do_grouping() const;
00174
00175 virtual string do_curr_symbol() const;
00176
00177 virtual string do_positive_sign() const;
00178 virtual string do_negative_sign() const;
00179 virtual int do_frac_digits() const;
00180 virtual pattern do_pos_format() const;
00181 virtual pattern do_neg_format() const;
00182
00183 friend class _Locale;
00184 };
00185
00186
00187 # ifndef _STLP_NO_WCHAR_T
00188
00189 _STLP_TEMPLATE_NULL
00190 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base
00191 {
00192 friend class _Locale;
00193 public:
00194 typedef wchar_t char_type;
00195 typedef wstring string_type;
00196 explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0);
00197 wchar_t decimal_point() const { return do_decimal_point(); }
00198 wchar_t thousands_sep() const { return do_thousands_sep(); }
00199 string grouping() const { return do_grouping(); }
00200 string_type curr_symbol() const { return do_curr_symbol(); }
00201 string_type positive_sign() const { return do_positive_sign(); }
00202 string_type negative_sign() const { return do_negative_sign(); }
00203 int frac_digits() const { return do_frac_digits(); }
00204 pattern pos_format() const { return do_pos_format(); }
00205 pattern neg_format() const { return do_neg_format(); }
00206
00207 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00208 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00209 enum _IntlVal { intl = 1 } ;
00210 # else
00211 static const bool intl = true;
00212 # endif
00213
00214 protected:
00215 pattern _M_pos_format;
00216 pattern _M_neg_format;
00217
00218 ~moneypunct _STLP_PSPEC2(wchar_t, true) ();
00219
00220 virtual wchar_t do_decimal_point() const;
00221 virtual wchar_t do_thousands_sep() const;
00222 virtual string do_grouping() const;
00223
00224 virtual string_type do_curr_symbol() const;
00225
00226 virtual string_type do_positive_sign() const;
00227 virtual string_type do_negative_sign() const;
00228 virtual int do_frac_digits() const;
00229 virtual pattern do_pos_format() const;
00230 virtual pattern do_neg_format() const;
00231 };
00232
00233
00234 _STLP_TEMPLATE_NULL
00235 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base
00236 {
00237 friend class _Locale;
00238 public:
00239 typedef wchar_t char_type;
00240 typedef wstring string_type;
00241 explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0);
00242 wchar_t decimal_point() const { return do_decimal_point(); }
00243 wchar_t thousands_sep() const { return do_thousands_sep(); }
00244 string grouping() const { return do_grouping(); }
00245 string_type curr_symbol() const { return do_curr_symbol(); }
00246 string_type positive_sign() const { return do_positive_sign(); }
00247 string_type negative_sign() const { return do_negative_sign(); }
00248 int frac_digits() const { return do_frac_digits(); }
00249 pattern pos_format() const { return do_pos_format(); }
00250 pattern neg_format() const { return do_neg_format(); }
00251
00252 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00253 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00254 enum _IntlVal { intl = 0 } ;
00255 # else
00256 static const bool intl = false;
00257 # endif
00258
00259 protected:
00260 pattern _M_pos_format;
00261 pattern _M_neg_format;
00262
00263 ~moneypunct _STLP_PSPEC2(wchar_t, false) ();
00264
00265 virtual wchar_t do_decimal_point() const;
00266 virtual wchar_t do_thousands_sep() const;
00267 virtual string do_grouping() const;
00268
00269 virtual string_type do_curr_symbol() const;
00270
00271 virtual string_type do_positive_sign() const;
00272 virtual string_type do_negative_sign() const;
00273 virtual int do_frac_digits() const;
00274 virtual pattern do_pos_format() const;
00275 virtual pattern do_neg_format() const;
00276 };
00277
00278 # endif
00279
00280 template <class _charT, __DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
00281
00282 _STLP_TEMPLATE_NULL
00283 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true>
00284 {
00285 public:
00286 typedef money_base::pattern pattern;
00287 typedef char char_type;
00288 typedef string string_type;
00289
00290 explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0);
00291
00292 protected:
00293 _Locale_monetary* _M_monetary;
00294 ~moneypunct_byname _STLP_PSPEC2(char, true) ();
00295 virtual char do_decimal_point() const;
00296 virtual char do_thousands_sep() const;
00297 virtual string do_grouping() const;
00298
00299 virtual string_type do_curr_symbol() const;
00300
00301 virtual string_type do_positive_sign() const;
00302 virtual string_type do_negative_sign() const;
00303 virtual int do_frac_digits() const;
00304 };
00305
00306 _STLP_TEMPLATE_NULL
00307 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false>
00308 {
00309 public:
00310 typedef money_base::pattern pattern;
00311 typedef char char_type;
00312 typedef string string_type;
00313
00314 explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0);
00315
00316 protected:
00317 _Locale_monetary* _M_monetary;
00318 ~moneypunct_byname _STLP_PSPEC2(char, false) ();
00319 virtual char do_decimal_point() const;
00320 virtual char do_thousands_sep() const;
00321 virtual string do_grouping() const;
00322
00323 virtual string_type do_curr_symbol() const;
00324
00325 virtual string_type do_positive_sign() const;
00326 virtual string_type do_negative_sign() const;
00327 virtual int do_frac_digits() const;
00328 };
00329
00330 # ifndef _STLP_NO_WCHAR_T
00331 _STLP_TEMPLATE_NULL
00332 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true>
00333 {
00334 public:
00335 typedef money_base::pattern pattern;
00336 typedef wchar_t char_type;
00337 typedef wstring string_type;
00338
00339 explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0);
00340
00341 protected:
00342 _Locale_monetary* _M_monetary;
00343 ~moneypunct_byname _STLP_PSPEC2(wchar_t, true) ();
00344 virtual wchar_t do_decimal_point() const;
00345 virtual wchar_t do_thousands_sep() const;
00346 virtual string do_grouping() const;
00347
00348 virtual string_type do_curr_symbol() const;
00349
00350 virtual string_type do_positive_sign() const;
00351 virtual string_type do_negative_sign() const;
00352 virtual int do_frac_digits() const;
00353 };
00354
00355 _STLP_TEMPLATE_NULL
00356 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false>
00357 {
00358 public:
00359 typedef money_base::pattern pattern;
00360 typedef wchar_t char_type;
00361 typedef wstring string_type;
00362
00363 explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0);
00364
00365 protected:
00366 _Locale_monetary* _M_monetary;
00367 ~moneypunct_byname _STLP_PSPEC2(wchar_t, false) ();
00368 virtual wchar_t do_decimal_point() const;
00369 virtual wchar_t do_thousands_sep() const;
00370 virtual string do_grouping() const;
00371
00372 virtual string_type do_curr_symbol() const;
00373
00374 virtual string_type do_positive_sign() const;
00375 virtual string_type do_negative_sign() const;
00376 virtual int do_frac_digits() const;
00377 };
00378 # endif
00379
00380
00381
00382
00383
00384
00385 template <class _CharT, __DFL_TMPL_PARAM( _OutputIter , ostreambuf_iterator<_CharT>) >
00386 class money_put : public locale::facet {
00387 friend class _Locale;
00388
00389 public:
00390 typedef _CharT char_type;
00391 typedef _OutputIter iter_type;
00392 typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
00393
00394 money_put(size_t __refs = 0) : _BaseFacet(__refs) {}
00395 # ifndef _STLP_NO_LONG_DOUBLE
00396 iter_type put(iter_type __s, bool __intl, ios_base& __str,
00397 char_type __fill, long double __units) const
00398 { return do_put(__s, __intl, __str, __fill, __units); }
00399 # endif
00400 iter_type put(iter_type __s, bool __intl, ios_base& __str,
00401 char_type __fill,
00402 const string_type& __digits) const
00403 { return do_put(__s, __intl, __str, __fill, __digits); }
00404
00405 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00406
00407 protected:
00408 ~money_put() {}
00409 # ifndef _STLP_NO_LONG_DOUBLE
00410 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
00411 char_type __fill, long double ) const {
00412
00413 locale __loc = __str.getloc();
00414 _CharT __buf[64];
00415 return do_put(__s, __intl, __str, __fill, __buf + 0);
00416 }
00417 # endif
00418 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
00419 char_type __fill,
00420 const string_type& __digits) const;
00421 };
00422
00423 # if defined (_STLP_USE_TEMPLATE_EXPORT)
00424 _STLP_EXPORT_TEMPLATE_CLASS money_get<char, istreambuf_iterator<char, char_traits<char> > >;
00425 _STLP_EXPORT_TEMPLATE_CLASS money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
00426
00427
00428 # if ! defined (_STLP_NO_WCHAR_T)
00429 _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00430 _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00431
00432
00433 # endif
00434 # endif
00435
00436 # if defined (__BORLANDC__) && defined (_RTLDLL)
00437 inline void _Stl_loc_init_monetary() {
00438 money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 8;
00439 money_get<char, const char*>::id._M_index = 9;
00440 money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 10;
00441 money_put<char, char*>::id._M_index = 11;
00442 # ifndef _STLP_NO_WCHAR_T
00443 money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 27;
00444 money_get<wchar_t, const wchar_t*>::id._M_index = 28;
00445 money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 29;
00446 money_put<wchar_t, wchar_t*>::id._M_index = 30;
00447 # endif
00448 }
00449 #endif
00450
00451 _STLP_END_NAMESPACE
00452
00453 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
00454 # include <stl/_monetary.c>
00455 # endif
00456
00457 #endif
00458
00459
00460
00461
00462
00463