_num_put.h 6.0 KB

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