epoc32/include/tools/stlport/stl/_monetary.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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, _STLP_DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
    50 
    51 // money_get facets
    52 
    53 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
    54 template <class _CharT, class _InputIter>
    55 #else
    56 template <class _CharT, class _InputIter = istreambuf_iterator<_CharT, char_traits<_CharT> > >
    57 #endif
    58 class money_get : public locale::facet {
    59   friend class _Locale_impl;
    60 
    61 public:
    62   typedef _CharT               char_type;
    63   typedef _InputIter           iter_type;
    64   typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
    65 
    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); }
    75 
    76   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
    77 
    78 protected:
    79   ~money_get() {}
    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;
    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 public:
    95   typedef char                 char_type;
    96   typedef string               string_type;
    97   explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
    98 
    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(); }
   108 
   109   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   110 # if defined (_STLP_STATIC_CONST_INIT_BUG)
   111   enum _IntlVal { intl = 1 } ;
   112 # else
   113   static const bool intl = true;
   114 # endif
   115 
   116 protected:
   117   pattern _M_pos_format;
   118   pattern _M_neg_format;
   119 
   120   ~moneypunct _STLP_PSPEC2(char, true) ();
   121 
   122   virtual char        do_decimal_point() const;
   123   virtual char        do_thousands_sep() const;
   124   virtual string      do_grouping()      const;
   125 
   126   virtual string      do_curr_symbol()   const;
   127 
   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;
   133 
   134   friend class _Locale_impl;
   135 };
   136 
   137 _STLP_TEMPLATE_NULL
   138 class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base
   139 {
   140 public:
   141   typedef char                 char_type;
   142   typedef string               string_type;
   143 
   144   explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
   145 
   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(); }
   155 
   156   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   157 # if defined (_STLP_STATIC_CONST_INIT_BUG)
   158   enum _IntlVal { intl = 0 } ;
   159 # else
   160   static const bool intl = false;
   161 # endif
   162 
   163 protected:
   164   pattern _M_pos_format;
   165   pattern _M_neg_format;
   166 
   167   ~moneypunct _STLP_PSPEC2(char, false) ();
   168 
   169   virtual char        do_decimal_point() const;
   170   virtual char        do_thousands_sep() const;
   171   virtual string      do_grouping()      const;
   172 
   173   virtual string      do_curr_symbol()   const;
   174 
   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;
   180 
   181   friend class _Locale_impl;
   182 };
   183 
   184 
   185 # ifndef _STLP_NO_WCHAR_T
   186 
   187 _STLP_TEMPLATE_NULL
   188 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base
   189 {
   190   friend class _Locale_impl;
   191 public:
   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(); }
   204 
   205   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   206 # if defined (_STLP_STATIC_CONST_INIT_BUG)
   207   enum _IntlVal { intl = 1 } ;
   208 # else
   209   static const bool intl = true;
   210 # endif
   211 
   212 protected:
   213   pattern _M_pos_format;
   214   pattern _M_neg_format;
   215 
   216   ~moneypunct _STLP_PSPEC2(wchar_t, true) ();
   217 
   218   virtual wchar_t     do_decimal_point() const;
   219   virtual wchar_t     do_thousands_sep() const;
   220   virtual string      do_grouping()      const;
   221 
   222   virtual string_type do_curr_symbol()   const;
   223 
   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;
   229 };
   230 
   231 
   232 _STLP_TEMPLATE_NULL
   233 class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base
   234 {
   235   friend class _Locale_impl;
   236 public:
   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(); }
   249 
   250   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   251 # if defined (_STLP_STATIC_CONST_INIT_BUG)
   252   enum _IntlVal { intl = 0 } ;
   253 # else
   254   static const bool intl = false;
   255 # endif
   256 
   257 protected:
   258   pattern _M_pos_format;
   259   pattern _M_neg_format;
   260 
   261   ~moneypunct _STLP_PSPEC2(wchar_t, false) ();
   262 
   263   virtual wchar_t     do_decimal_point() const;
   264   virtual wchar_t     do_thousands_sep() const;
   265   virtual string      do_grouping()      const;
   266 
   267   virtual string_type do_curr_symbol()   const;
   268 
   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;
   274 };
   275 
   276 # endif
   277 
   278 template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
   279 
   280 _STLP_TEMPLATE_NULL
   281 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true> {
   282 public:
   283   typedef money_base::pattern   pattern;
   284   typedef char                  char_type;
   285   typedef string                string_type;
   286 
   287   explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0,
   288                                                        _Locale_name_hint* __hint = 0);
   289 
   290 protected:
   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;
   296 
   297   virtual string_type do_curr_symbol()   const;
   298 
   299   virtual string_type do_positive_sign() const;
   300   virtual string_type do_negative_sign() const;
   301   virtual int         do_frac_digits()   const;
   302 
   303 private:
   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&);
   308 };
   309 
   310 _STLP_TEMPLATE_NULL
   311 class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false>
   312 {
   313 public:
   314   typedef money_base::pattern   pattern;
   315   typedef char                  char_type;
   316   typedef string                string_type;
   317 
   318   explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0,
   319                                                         _Locale_name_hint* __hint = 0);
   320 
   321 protected:
   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;
   327 
   328   virtual string_type do_curr_symbol()   const;
   329 
   330   virtual string_type do_positive_sign() const;
   331   virtual string_type do_negative_sign() const;
   332   virtual int         do_frac_digits()   const;
   333 
   334 private:
   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>*);
   340 };
   341 
   342 #if !defined (_STLP_NO_WCHAR_T)
   343 _STLP_TEMPLATE_NULL
   344 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true>
   345 {
   346 public:
   347   typedef money_base::pattern   pattern;
   348   typedef wchar_t               char_type;
   349   typedef wstring               string_type;
   350 
   351   explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0,
   352                                                           _Locale_name_hint* __hint = 0);
   353 
   354 protected:
   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;
   360 
   361   virtual string_type do_curr_symbol()   const;
   362 
   363   virtual string_type do_positive_sign() const;
   364   virtual string_type do_negative_sign() const;
   365   virtual int         do_frac_digits()   const;
   366 
   367 private:
   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&);
   372 };
   373 
   374 _STLP_TEMPLATE_NULL
   375 class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false>
   376 {
   377 public:
   378   typedef money_base::pattern   pattern;
   379   typedef wchar_t               char_type;
   380   typedef wstring               string_type;
   381 
   382   explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0,
   383                                                            _Locale_name_hint* __hint = 0);
   384 
   385 protected:
   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;
   391 
   392   virtual string_type do_curr_symbol()   const;
   393 
   394   virtual string_type do_positive_sign() const;
   395   virtual string_type do_negative_sign() const;
   396   virtual int         do_frac_digits()   const;
   397 
   398 private:
   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&);
   403 };
   404 #endif
   405 
   406 //===== methods ======
   407 
   408 
   409 // money_put facets
   410 
   411 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
   412 template <class _CharT, class _OutputIter>
   413 #else
   414 template <class _CharT, class _OutputIter = ostreambuf_iterator<_CharT, char_traits<_CharT> > >
   415 #endif
   416 class money_put : public locale::facet {
   417   friend class _Locale_impl;
   418 
   419 public:
   420   typedef _CharT               char_type;
   421   typedef _OutputIter          iter_type;
   422   typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
   423 
   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,
   429                 char_type  __fill,
   430                 const string_type& __digits) const
   431     { return do_put(__s, __intl, __str, __fill, __digits); }
   432 
   433   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   434 
   435 protected:
   436   ~money_put() {}
   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,
   440                            char_type __fill,
   441                            const string_type& __digits) const;
   442 };
   443 
   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* >;
   454 #  endif
   455 # endif /* _STLP_USE_TEMPLATE_EXPORT */
   456 
   457 _STLP_END_NAMESPACE
   458 
   459 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
   460 #  include <stl/_monetary.c>
   461 #endif
   462 
   463 #endif /* _STLP_INTERNAL_MONETARY_H */
   464 
   465 // Local Variables:
   466 // mode:C++
   467 // End:
   468 
   469