/home/ntakagi/work/STLport-5.1.5/stlport/stl/_monetary.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 // WARNING: This is an internal header file, included by other C++
00019 // standard library headers.  You should not attempt to use this header
00020 // file directly.
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 // moneypunct facets: forward declaration
00049 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
00050 
00051 // money_get facets
00052 
00053 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
00054 template <class _CharT, class _InputIter>
00055 #else
00056 template <class _CharT, class _InputIter = istreambuf_iterator<_CharT, char_traits<_CharT> > >
00057 #endif
00058 class money_get : public locale::facet {
00059   friend class _Locale_impl;
00060 
00061 public:
00062   typedef _CharT               char_type;
00063   typedef _InputIter           iter_type;
00064   typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
00065 
00066   money_get(size_t __refs = 0) : locale::facet(__refs) {}
00067   iter_type get(iter_type __s, iter_type  __end, bool __intl,
00068                 ios_base&  __str, ios_base::iostate&  __err,
00069                 _STLP_LONGEST_FLOAT_TYPE& __units) const
00070     { return do_get(__s,  __end, __intl,  __str,  __err, __units); }
00071   iter_type get(iter_type __s, iter_type  __end, bool __intl,
00072                 ios_base&  __str, ios_base::iostate& __err,
00073                 string_type& __digits) const
00074     { return do_get(__s,  __end, __intl,  __str,  __err, __digits); }
00075 
00076   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
00077 
00078 protected:
00079   ~money_get() {}
00080   virtual iter_type do_get(iter_type __s, iter_type  __end, bool  __intl,
00081                            ios_base&  __str, ios_base::iostate& __err,
00082                            _STLP_LONGEST_FLOAT_TYPE& __units) const;
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 // moneypunct facets: definition of specializations
00090 
00091 _STLP_TEMPLATE_NULL
00092 class _STLP_CLASS_DECLSPEC moneypunct<char, true> : public locale::facet, public money_base {
00093 
00094 public:
00095   typedef char                 char_type;
00096   typedef string               string_type;
00097   explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
00098 
00099   char        decimal_point() const { return do_decimal_point(); }
00100   char        thousands_sep() const { return do_thousands_sep(); }
00101   string      grouping()      const { return do_grouping(); }
00102   string_type curr_symbol()   const { return do_curr_symbol(); }
00103   string_type positive_sign() const { return do_positive_sign(); }
00104   string_type negative_sign() const { return do_negative_sign(); }
00105   int         frac_digits()   const { return do_frac_digits(); }
00106   pattern     pos_format()    const { return do_pos_format(); }
00107   pattern     neg_format()    const { return do_neg_format(); }
00108 
00109   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
00110 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00111   enum _IntlVal { intl = 1 } ;
00112 # else
00113   static const bool intl = true;
00114 # endif
00115 
00116 protected:
00117   pattern _M_pos_format;
00118   pattern _M_neg_format;
00119 
00120   ~moneypunct _STLP_PSPEC2(char, true) ();
00121 
00122   virtual char        do_decimal_point() const;
00123   virtual char        do_thousands_sep() const;
00124   virtual string      do_grouping()      const;
00125 
00126   virtual string      do_curr_symbol()   const;
00127 
00128   virtual string      do_positive_sign() const;
00129   virtual string      do_negative_sign() const;
00130   virtual int         do_frac_digits()   const;
00131   virtual pattern     do_pos_format()    const;
00132   virtual pattern     do_neg_format()    const;
00133 
00134   friend class _Locale_impl;
00135 };
00136 
00137 _STLP_TEMPLATE_NULL
00138 class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base
00139 {
00140 public:
00141   typedef char                 char_type;
00142   typedef string               string_type;
00143 
00144   explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
00145 
00146   char        decimal_point() const { return do_decimal_point(); }
00147   char        thousands_sep() const { return do_thousands_sep(); }
00148   string      grouping()      const { return do_grouping(); }
00149   string_type curr_symbol()   const { return do_curr_symbol(); }
00150   string_type positive_sign() const { return do_positive_sign(); }
00151   string_type negative_sign() const { return do_negative_sign(); }
00152   int         frac_digits()   const { return do_frac_digits(); }
00153   pattern     pos_format()    const { return do_pos_format(); }
00154   pattern     neg_format()    const { return do_neg_format(); }
00155 
00156   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
00157 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00158   enum _IntlVal { intl = 0 } ;
00159 # else
00160   static const bool intl = false;
00161 # endif
00162 
00163 protected:
00164   pattern _M_pos_format;
00165   pattern _M_neg_format;
00166 
00167   ~moneypunct _STLP_PSPEC2(char, false) ();
00168 
00169   virtual char        do_decimal_point() const;
00170   virtual char        do_thousands_sep() const;
00171   virtual string      do_grouping()      const;
00172 
00173   virtual string      do_curr_symbol()   const;
00174 
00175   virtual string      do_positive_sign() const;
00176   virtual string      do_negative_sign() const;
00177   virtual int         do_frac_digits()   const;
00178   virtual pattern     do_pos_format()    const;
00179   virtual pattern     do_neg_format()    const;
00180 
00181   friend class _Locale_impl;
00182 };
00183 
00184 
00185 # ifndef _STLP_NO_WCHAR_T
00186 
00187 _STLP_TEMPLATE_NULL
00188 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base
00189 {
00190   friend class _Locale_impl;
00191 public:
00192   typedef wchar_t                 char_type;
00193   typedef wstring                 string_type;
00194   explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0);
00195   wchar_t     decimal_point() const { return do_decimal_point(); }
00196   wchar_t     thousands_sep() const { return do_thousands_sep(); }
00197   string      grouping()      const { return do_grouping(); }
00198   string_type curr_symbol()   const { return do_curr_symbol(); }
00199   string_type positive_sign() const { return do_positive_sign(); }
00200   string_type negative_sign() const { return do_negative_sign(); }
00201   int         frac_digits()   const { return do_frac_digits(); }
00202   pattern     pos_format()    const { return do_pos_format(); }
00203   pattern     neg_format()    const { return do_neg_format(); }
00204 
00205   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
00206 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00207   enum _IntlVal { intl = 1 } ;
00208 # else
00209   static const bool intl = true;
00210 # endif
00211 
00212 protected:
00213   pattern _M_pos_format;
00214   pattern _M_neg_format;
00215 
00216   ~moneypunct _STLP_PSPEC2(wchar_t, true) ();
00217 
00218   virtual wchar_t     do_decimal_point() const;
00219   virtual wchar_t     do_thousands_sep() const;
00220   virtual string      do_grouping()      const;
00221 
00222   virtual string_type do_curr_symbol()   const;
00223 
00224   virtual string_type do_positive_sign() const;
00225   virtual string_type do_negative_sign() const;
00226   virtual int         do_frac_digits()   const;
00227   virtual pattern     do_pos_format()    const;
00228   virtual pattern     do_neg_format()    const;
00229 };
00230 
00231 
00232 _STLP_TEMPLATE_NULL
00233 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base
00234 {
00235   friend class _Locale_impl;
00236 public:
00237   typedef wchar_t                 char_type;
00238   typedef wstring                 string_type;
00239   explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0);
00240   wchar_t     decimal_point() const { return do_decimal_point(); }
00241   wchar_t     thousands_sep() const { return do_thousands_sep(); }
00242   string      grouping()      const { return do_grouping(); }
00243   string_type curr_symbol()   const { return do_curr_symbol(); }
00244   string_type positive_sign() const { return do_positive_sign(); }
00245   string_type negative_sign() const { return do_negative_sign(); }
00246   int         frac_digits()   const { return do_frac_digits(); }
00247   pattern     pos_format()    const { return do_pos_format(); }
00248   pattern     neg_format()    const { return do_neg_format(); }
00249 
00250   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
00251 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00252   enum _IntlVal { intl = 0 } ;
00253 # else
00254   static const bool intl = false;
00255 # endif
00256 
00257 protected:
00258   pattern _M_pos_format;
00259   pattern _M_neg_format;
00260 
00261   ~moneypunct _STLP_PSPEC2(wchar_t, false) ();
00262 
00263   virtual wchar_t     do_decimal_point() const;
00264   virtual wchar_t     do_thousands_sep() const;
00265   virtual string      do_grouping()      const;
00266 
00267   virtual string_type do_curr_symbol()   const;
00268 
00269   virtual string_type do_positive_sign() const;
00270   virtual string_type do_negative_sign() const;
00271   virtual int         do_frac_digits()   const;
00272   virtual pattern     do_pos_format()    const;
00273   virtual pattern     do_neg_format()    const;
00274 };
00275 
00276 # endif
00277 
00278 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
00279 
00280 _STLP_TEMPLATE_NULL
00281 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true> {
00282 public:
00283   typedef money_base::pattern   pattern;
00284   typedef char                  char_type;
00285   typedef string                string_type;
00286 
00287   explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0,
00288                                                        _Locale_name_hint* __hint = 0);
00289 
00290 protected:
00291   _Locale_monetary* _M_monetary;
00292   ~moneypunct_byname _STLP_PSPEC2(char, true) ();
00293   virtual char        do_decimal_point() const;
00294   virtual char        do_thousands_sep() const;
00295   virtual string      do_grouping()      const;
00296 
00297   virtual string_type do_curr_symbol()   const;
00298 
00299   virtual string_type do_positive_sign() const;
00300   virtual string_type do_negative_sign() const;
00301   virtual int         do_frac_digits()   const;
00302 
00303 private:
00304   typedef moneypunct_byname<char, true> _Self;
00305   //explicitely defined as private to avoid warnings:
00306   moneypunct_byname(_Self const&);
00307   _Self& operator = (_Self const&);
00308 };
00309 
00310 _STLP_TEMPLATE_NULL
00311 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false>
00312 {
00313 public:
00314   typedef money_base::pattern   pattern;
00315   typedef char                  char_type;
00316   typedef string                string_type;
00317 
00318   explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0,
00319                                                         _Locale_name_hint* __hint = 0);
00320 
00321 protected:
00322   _Locale_monetary* _M_monetary;
00323   ~moneypunct_byname _STLP_PSPEC2(char, false) ();
00324   virtual char        do_decimal_point() const;
00325   virtual char        do_thousands_sep() const;
00326   virtual string      do_grouping()      const;
00327 
00328   virtual string_type do_curr_symbol()   const;
00329 
00330   virtual string_type do_positive_sign() const;
00331   virtual string_type do_negative_sign() const;
00332   virtual int         do_frac_digits()   const;
00333 
00334 private:
00335   typedef moneypunct_byname<char, false> _Self;
00336   //explicitely defined as private to avoid warnings:
00337   moneypunct_byname(_Self const&);
00338   _Self& operator = (_Self const&);
00339   friend _Locale_name_hint* _Locale_extract_hint(moneypunct_byname<char, false>*);
00340 };
00341 
00342 #if !defined (_STLP_NO_WCHAR_T)
00343 _STLP_TEMPLATE_NULL
00344 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true>
00345 {
00346 public:
00347   typedef money_base::pattern   pattern;
00348   typedef wchar_t               char_type;
00349   typedef wstring               string_type;
00350 
00351   explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0,
00352                                                           _Locale_name_hint* __hint = 0);
00353 
00354 protected:
00355   _Locale_monetary* _M_monetary;
00356   ~moneypunct_byname _STLP_PSPEC2(wchar_t, true) ();
00357   virtual wchar_t     do_decimal_point() const;
00358   virtual wchar_t     do_thousands_sep() const;
00359   virtual string      do_grouping()      const;
00360 
00361   virtual string_type do_curr_symbol()   const;
00362 
00363   virtual string_type do_positive_sign() const;
00364   virtual string_type do_negative_sign() const;
00365   virtual int         do_frac_digits()   const;
00366 
00367 private:
00368   typedef moneypunct_byname<wchar_t, true> _Self;
00369   //explicitely defined as private to avoid warnings:
00370   moneypunct_byname(_Self const&);
00371   _Self& operator = (_Self const&);
00372 };
00373 
00374 _STLP_TEMPLATE_NULL
00375 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false>
00376 {
00377 public:
00378   typedef money_base::pattern   pattern;
00379   typedef wchar_t               char_type;
00380   typedef wstring               string_type;
00381 
00382   explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0,
00383                                                            _Locale_name_hint* __hint = 0);
00384 
00385 protected:
00386   _Locale_monetary* _M_monetary;
00387   ~moneypunct_byname _STLP_PSPEC2(wchar_t, false) ();
00388   virtual wchar_t     do_decimal_point() const;
00389   virtual wchar_t     do_thousands_sep() const;
00390   virtual string      do_grouping()      const;
00391 
00392   virtual string_type do_curr_symbol()   const;
00393 
00394   virtual string_type do_positive_sign() const;
00395   virtual string_type do_negative_sign() const;
00396   virtual int         do_frac_digits()   const;
00397 
00398 private:
00399   typedef moneypunct_byname<wchar_t, false> _Self;
00400   //explicitely defined as private to avoid warnings:
00401   moneypunct_byname(_Self const&);
00402   _Self& operator = (_Self const&);
00403 };
00404 #endif
00405 
00406 //===== methods ======
00407 
00408 
00409 // money_put facets
00410 
00411 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
00412 template <class _CharT, class _OutputIter>
00413 #else
00414 template <class _CharT, class _OutputIter = ostreambuf_iterator<_CharT, char_traits<_CharT> > >
00415 #endif
00416 class money_put : public locale::facet {
00417   friend class _Locale_impl;
00418 
00419 public:
00420   typedef _CharT               char_type;
00421   typedef _OutputIter          iter_type;
00422   typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
00423 
00424   money_put(size_t __refs = 0) : locale::facet(__refs) {}
00425   iter_type put(iter_type __s, bool __intl, ios_base& __str,
00426                 char_type  __fill, _STLP_LONGEST_FLOAT_TYPE __units) const
00427     { return do_put(__s, __intl, __str, __fill, __units); }
00428   iter_type put(iter_type __s, bool __intl, ios_base& __str,
00429                 char_type  __fill,
00430                 const string_type& __digits) const
00431     { return do_put(__s, __intl, __str, __fill, __digits); }
00432 
00433   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
00434 
00435 protected:
00436   ~money_put() {}
00437   virtual iter_type do_put(iter_type __s, bool  __intl, ios_base&  __str,
00438                            char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const;
00439   virtual iter_type do_put(iter_type __s, bool  __intl, ios_base&  __str,
00440                            char_type __fill,
00441                            const string_type& __digits) const;
00442 };
00443 
00444 # if defined (_STLP_USE_TEMPLATE_EXPORT)
00445 _STLP_EXPORT_TEMPLATE_CLASS money_get<char, istreambuf_iterator<char, char_traits<char> > >;
00446 _STLP_EXPORT_TEMPLATE_CLASS money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
00447 //_STLP_EXPORT_TEMPLATE_CLASS money_get<char, const char* >;
00448 //_STLP_EXPORT_TEMPLATE_CLASS money_put<char, char* >;
00449 #  if ! defined (_STLP_NO_WCHAR_T)
00450 _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00451 _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00452 // _STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, const wchar_t* >;
00453 // _STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, wchar_t* >;
00454 #  endif
00455 # endif /* _STLP_USE_TEMPLATE_EXPORT */
00456 
00457 _STLP_END_NAMESPACE
00458 
00459 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
00460 #  include <stl/_monetary.c>
00461 #endif
00462 
00463 #endif /* _STLP_INTERNAL_MONETARY_H */
00464 
00465 // Local Variables:
00466 // mode:C++
00467 // End:
00468 
00469 



Generated on Mon Mar 10 15:32:31 2008 by  doxygen 1.5.1