Home | History | Annotate | Download | only in stl
      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_NUM_PUT_H
     24 #define _STLP_INTERNAL_NUM_PUT_H
     25 
     26 #ifndef _STLP_INTERNAL_NUMPUNCT_H
     27 #  include <stl/_numpunct.h>
     28 #endif
     29 
     30 #ifndef _STLP_INTERNAL_CTYPE_H
     31 #  include <stl/_ctype.h>
     32 #endif
     33 
     34 #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
     35 #  include <stl/_ostreambuf_iterator.h>
     36 #endif
     37 
     38 #ifndef _STLP_INTERNAL_IOSTREAM_STRING_H
     39 #  include <stl/_iostream_string.h>
     40 #endif
     41 
     42 #ifndef _STLP_FACETS_FWD_H
     43 #  include <stl/_facets_fwd.h>
     44 #endif
     45 
     46 _STLP_BEGIN_NAMESPACE
     47 
     48 //----------------------------------------------------------------------
     49 // num_put facet
     50 
     51 template <class _CharT, class _OutputIter>
     52 class num_put: public locale::facet {
     53 public:
     54   typedef _CharT      char_type;
     55   typedef _OutputIter iter_type;
     56 
     57   explicit num_put(size_t __refs = 0) : locale::facet(__refs) {}
     58 
     59 #if !defined (_STLP_NO_BOOL)
     60   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
     61                 bool __val) const {
     62     return do_put(__s, __f, __fill, __val);
     63   }
     64 #endif
     65   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
     66                long __val) const {
     67     return do_put(__s, __f, __fill, __val);
     68   }
     69 
     70   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
     71                 unsigned long __val) const {
     72     return do_put(__s, __f, __fill, __val);
     73   }
     74 
     75 #if defined (_STLP_LONG_LONG)
     76   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
     77                 _STLP_LONG_LONG __val) const {
     78     return do_put(__s, __f, __fill, __val);
     79   }
     80 
     81   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
     82                 unsigned _STLP_LONG_LONG __val) const {
     83     return do_put(__s, __f, __fill, __val);
     84   }
     85 #endif
     86 
     87   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
     88                 double __val) const {
     89     return do_put(__s, __f, __fill, (double)__val);
     90   }
     91 
     92 #if !defined (_STLP_NO_LONG_DOUBLE)
     93   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
     94                 long double __val) const {
     95     return do_put(__s, __f, __fill, __val);
     96   }
     97 #endif
     98 
     99   iter_type put(iter_type __s, ios_base& __f, char_type __fill,
    100                 const void * __val) const {
    101     return do_put(__s, __f, __fill, __val);
    102   }
    103 
    104   static locale::id id;
    105 
    106 protected:
    107   ~num_put() {}
    108 #if !defined (_STLP_NO_BOOL)
    109   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, bool __val) const;
    110 #endif
    111   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long __val) const;
    112   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, unsigned long __val) const;
    113   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, double __val) const;
    114 #if !defined (_STLP_NO_LONG_DOUBLE)
    115   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long double __val) const;
    116 #endif
    117 
    118 #if defined (_STLP_LONG_LONG)
    119   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, _STLP_LONG_LONG __val) const;
    120   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
    121                            unsigned _STLP_LONG_LONG __val) const ;
    122 #endif
    123   virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, const void* __val) const;
    124 };
    125 
    126 #if defined (_STLP_USE_TEMPLATE_EXPORT)
    127 _STLP_EXPORT_TEMPLATE_CLASS num_put<char, ostreambuf_iterator<char, char_traits<char> > >;
    128 #  if !defined (_STLP_NO_WCHAR_T)
    129 _STLP_EXPORT_TEMPLATE_CLASS num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
    130 #  endif
    131 #endif
    132 
    133 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
    134 
    135 _STLP_MOVE_TO_PRIV_NAMESPACE
    136 
    137 template <class _Integer>
    138 char* _STLP_CALL
    139 __write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x);
    140 
    141 /*
    142  * Returns the position on the right of the digits that has to be considered
    143  * for the application of the grouping policy.
    144  */
    145 extern size_t _STLP_CALL __write_float(__iostring&, ios_base::fmtflags, int, double);
    146 #  if !defined (_STLP_NO_LONG_DOUBLE)
    147 extern size_t _STLP_CALL __write_float(__iostring&, ios_base::fmtflags, int, long double);
    148 #  endif
    149 
    150 /*
    151  * Gets the digits of the integer part.
    152  */
    153 void _STLP_CALL __get_floor_digits(__iostring&, _STLP_LONGEST_FLOAT_TYPE);
    154 
    155 template <class _CharT>
    156 void _STLP_CALL __get_money_digits(_STLP_BASIC_IOSTRING(_CharT)&, ios_base&, _STLP_LONGEST_FLOAT_TYPE);
    157 
    158 #  if !defined (_STLP_NO_WCHAR_T)
    159 extern void _STLP_CALL __convert_float_buffer(__iostring const&, __iowstring&, const ctype<wchar_t>&, wchar_t, bool = true);
    160 #  endif
    161 extern void _STLP_CALL __adjust_float_buffer(__iostring&, char);
    162 
    163 extern char* _STLP_CALL
    164 __write_integer(char* buf, ios_base::fmtflags flags, long x);
    165 
    166 extern ptrdiff_t _STLP_CALL __insert_grouping(char* first, char* last, const string&, char, char, char, int);
    167 extern void _STLP_CALL __insert_grouping(__iostring&, size_t, const string&, char, char, char, int);
    168 #  if !defined (_STLP_NO_WCHAR_T)
    169 extern ptrdiff_t _STLP_CALL __insert_grouping(wchar_t*, wchar_t*, const string&, wchar_t, wchar_t, wchar_t, int);
    170 extern void _STLP_CALL __insert_grouping(__iowstring&, size_t, const string&, wchar_t, wchar_t, wchar_t, int);
    171 #  endif
    172 
    173 _STLP_MOVE_TO_STD_NAMESPACE
    174 
    175 #endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
    176 
    177 _STLP_END_NAMESPACE
    178 
    179 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
    180 #  include <stl/_num_put.c>
    181 #endif
    182 
    183 #endif /* _STLP_INTERNAL_NUMERIC_FACETS_H */
    184 
    185 // Local Variables:
    186 // mode:C++
    187 // End:
    188