_num_get.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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_GET_H
  22. #define _STLP_INTERNAL_NUM_GET_H
  23. #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
  24. # include <stl/_istreambuf_iterator.h>
  25. #endif
  26. #ifndef _STLP_C_LOCALE_H
  27. # include <stl/c_locale.h>
  28. #endif
  29. #ifndef _STLP_INTERNAL_NUMPUNCT_H
  30. # include <stl/_numpunct.h>
  31. #endif
  32. #ifndef _STLP_INTERNAL_CTYPE_H
  33. # include <stl/_ctype.h>
  34. #endif
  35. #ifndef _STLP_INTERNAL_IOSTREAM_STRING_H
  36. # include <stl/_iostream_string.h>
  37. #endif
  38. #ifndef _STLP_FACETS_FWD_H
  39. # include <stl/_facets_fwd.h>
  40. #endif
  41. _STLP_BEGIN_NAMESPACE
  42. //----------------------------------------------------------------------
  43. // num_get facets
  44. template <class _CharT, class _InputIter>
  45. class num_get: public locale::facet {
  46. public:
  47. typedef _CharT char_type;
  48. typedef _InputIter iter_type;
  49. explicit num_get(size_t __refs = 0): locale::facet(__refs) {}
  50. #if !defined (_STLP_NO_BOOL)
  51. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  52. ios_base::iostate& __err, bool& __val) const
  53. { return do_get(__ii, __end, __str, __err, __val); }
  54. #endif
  55. #if defined (_STLP_FIX_LIBRARY_ISSUES)
  56. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  57. ios_base::iostate& __err, short& __val) const
  58. { return do_get(__ii, __end, __str, __err, __val); }
  59. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  60. ios_base::iostate& __err, int& __val) const
  61. { return do_get(__ii, __end, __str, __err, __val); }
  62. #endif
  63. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  64. ios_base::iostate& __err, long& __val) const
  65. { return do_get(__ii, __end, __str, __err, __val); }
  66. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  67. ios_base::iostate& __err, unsigned short& __val) const
  68. { return do_get(__ii, __end, __str, __err, __val); }
  69. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  70. ios_base::iostate& __err, unsigned int& __val) const
  71. { return do_get(__ii, __end, __str, __err, __val); }
  72. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  73. ios_base::iostate& __err, unsigned long& __val) const
  74. { return do_get(__ii, __end, __str, __err, __val); }
  75. #if defined (_STLP_LONG_LONG)
  76. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  77. ios_base::iostate& __err, _STLP_LONG_LONG& __val) const
  78. { return do_get(__ii, __end, __str, __err, __val); }
  79. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  80. ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const
  81. { return do_get(__ii, __end, __str, __err, __val); }
  82. #endif /* _STLP_LONG_LONG */
  83. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  84. ios_base::iostate& __err, float& __val) const
  85. { return do_get(__ii, __end, __str, __err, __val); }
  86. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  87. ios_base::iostate& __err, double& __val) const
  88. { return do_get(__ii, __end, __str, __err, __val); }
  89. #if !defined (_STLP_NO_LONG_DOUBLE)
  90. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  91. ios_base::iostate& __err, long double& __val) const
  92. { return do_get(__ii, __end, __str, __err, __val); }
  93. # endif
  94. _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
  95. ios_base::iostate& __err, void*& __val) const
  96. { return do_get(__ii, __end, __str, __err, __val); }
  97. static locale::id id;
  98. protected:
  99. ~num_get() {}
  100. typedef string string_type;
  101. typedef ctype<_CharT> _Ctype;
  102. typedef numpunct<_CharT> _Numpunct;
  103. #if !defined (_STLP_NO_BOOL)
  104. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  105. ios_base::iostate& __err, bool& __val) const;
  106. #endif
  107. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  108. ios_base::iostate& __err, long& __val) const;
  109. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  110. ios_base::iostate& __err, unsigned short& __val) const;
  111. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  112. ios_base::iostate& __err, unsigned int& __val) const;
  113. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  114. ios_base::iostate& __err, unsigned long& __val) const;
  115. #if defined (_STLP_FIX_LIBRARY_ISSUES)
  116. // issue 118 : those are actually not supposed to be here
  117. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  118. ios_base::iostate& __err, short& __val) const;
  119. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  120. ios_base::iostate& __err, int& __val) const;
  121. #endif
  122. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  123. ios_base::iostate& __err, float& __val) const;
  124. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  125. ios_base::iostate& __err, double& __val) const;
  126. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  127. ios_base::iostate& __err, void*& __p) const;
  128. #if !defined (_STLP_NO_LONG_DOUBLE)
  129. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  130. ios_base::iostate& __err, long double& __val) const;
  131. #endif
  132. #if defined (_STLP_LONG_LONG)
  133. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  134. ios_base::iostate& __err, _STLP_LONG_LONG& __val) const;
  135. virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
  136. ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const;
  137. #endif
  138. };
  139. #if defined (_STLP_USE_TEMPLATE_EXPORT)
  140. _STLP_EXPORT_TEMPLATE_CLASS num_get<char, istreambuf_iterator<char, char_traits<char> > >;
  141. // _STLP_EXPORT_TEMPLATE_CLASS num_get<char, const char*>;
  142. # if !defined (_STLP_NO_WCHAR_T)
  143. _STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
  144. // _STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, const wchar_t*>;
  145. # endif
  146. #endif
  147. #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
  148. _STLP_MOVE_TO_PRIV_NAMESPACE
  149. _STLP_DECLSPEC bool _STLP_CALL __valid_grouping(const char*, const char*, const char*, const char*);
  150. template <class _InputIter, class _Integer, class _CharT>
  151. bool _STLP_CALL
  152. __get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val, _CharT*);
  153. # if !defined (_STLP_NO_WCHAR_T)
  154. bool _STLP_DECLSPEC _STLP_CALL __get_fdigit(wchar_t&, const wchar_t*);
  155. bool _STLP_DECLSPEC _STLP_CALL __get_fdigit_or_sep(wchar_t&, wchar_t, const wchar_t*);
  156. # endif
  157. inline void _STLP_CALL
  158. _Initialize_get_float(const ctype<char>&,
  159. char& Plus, char& Minus,
  160. char& pow_e, char& pow_E,
  161. char*) {
  162. Plus = '+';
  163. Minus = '-';
  164. pow_e = 'e';
  165. pow_E = 'E';
  166. }
  167. # if !defined (_STLP_NO_WCHAR_T)
  168. void _STLP_DECLSPEC _STLP_CALL _Initialize_get_float(const ctype<wchar_t>&,
  169. wchar_t&, wchar_t&, wchar_t&, wchar_t&, wchar_t*);
  170. # endif
  171. void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, float&);
  172. void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, double&);
  173. # if !defined (_STLP_NO_LONG_DOUBLE)
  174. void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, long double&);
  175. # endif
  176. _STLP_MOVE_TO_STD_NAMESPACE
  177. #endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
  178. _STLP_END_NAMESPACE
  179. #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
  180. # include <stl/_num_get.c>
  181. #endif
  182. #endif /* _STLP_INTERNAL_NUM_GET_H */
  183. // Local Variables:
  184. // mode:C++
  185. // End: