2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
4 * Silicon Graphics Computer Systems, Inc.
9 * This material is provided "as is", with absolutely no warranty expressed
10 * or implied. Any use is at your own risk.
12 * Permission to use or copy this software for any purpose is hereby granted
13 * without fee, provided the above notices are retained on all copies.
14 * Permission to modify the code and to distribute modified code is granted,
15 * provided the above notices are retained, and a notice that the code was
16 * modified is included with the above copyright notice.
19 // WARNING: This is an internal header file, included by other C++
20 // standard library headers. You should not attempt to use this header
24 #ifndef _STLP_INTERNAL_NUM_GET_H
25 #define _STLP_INTERNAL_NUM_GET_H
27 #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
28 # include <stl/_istreambuf_iterator.h>
31 # ifndef _STLP_C_LOCALE_H
32 # include <stl/c_locale.h>
35 #ifndef _STLP_INTERNAL_NUMPUNCT_H
36 # include <stl/_numpunct.h>
38 #ifndef _STLP_INTERNAL_CTYPE_H
39 # include <stl/_ctype.h>
44 //----------------------------------------------------------------------
47 # ifdef _STLP_LIMITED_DEFAULT_TEMPLATES
48 template <class _CharT, class _InputIter>
50 template <class _CharT, class _InputIter = istreambuf_iterator<_CharT> >
53 class num_get : public locale::facet
55 class num_get: public locale::facet
60 typedef _CharT char_type;
61 typedef _InputIter iter_type;
63 explicit num_get(size_t __refs = 0): locale::facet(__refs) {}
65 # ifndef _STLP_NO_BOOL
66 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
67 ios_base::iostate& __err, bool& __val) const {
68 return do_get(__stl_in, __end, __str, __err, __val);
72 //# ifdef _STLP_FIX_LIBRARY_ISSUES
73 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
74 ios_base::iostate& __err, short& __val) const {
75 return do_get(__stl_in, __end, __str, __err, __val);
78 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
79 ios_base::iostate& __err, int& __val) const {
80 return do_get(__stl_in, __end, __str, __err, __val);
84 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
85 ios_base::iostate& __err, long& __val) const {
86 return do_get(__stl_in, __end, __str, __err, __val);
89 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
90 ios_base::iostate& __err, unsigned short& __val) const {
91 return do_get(__stl_in, __end, __str, __err, __val);
94 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
95 ios_base::iostate& __err, unsigned int& __val) const {
96 return do_get(__stl_in, __end, __str, __err, __val);
99 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
100 ios_base::iostate& __err, unsigned long& __val) const {
101 return do_get(__stl_in, __end, __str, __err, __val);
104 #ifdef _STLP_LONG_LONG
106 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
107 ios_base::iostate& __err, _STLP_LONG_LONG& __val) const {
108 return do_get(__stl_in, __end, __str, __err, __val);
111 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
112 ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const {
113 return do_get(__stl_in, __end, __str, __err, __val);
116 #endif /* _STLP_LONG_LONG */
118 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
119 ios_base::iostate& __err, float& __val) const {
120 return do_get(__stl_in, __end, __str, __err, __val);
123 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
124 ios_base::iostate& __err, double& __val) const {
125 return do_get(__stl_in, __end, __str, __err, __val);
128 # ifndef _STLP_NO_LONG_DOUBLE
130 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
131 ios_base::iostate& __err, long double& __val) const {
132 return do_get(__stl_in, __end, __str, __err, __val);
136 _InputIter get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
137 ios_base::iostate& __err, void*& __val) const {
138 return do_get(__stl_in, __end, __str, __err, __val);
141 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
142 _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
143 _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId(istreambuf_iterator<wchar_t, char_traits<wchar_t> >* );
144 _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId(const wchar_t**);
145 _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId(istreambuf_iterator<char, char_traits<char> >* );
146 _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId(const char**);
149 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
155 typedef string string_type;
156 typedef ctype<_CharT> _Ctype;
157 typedef numpunct<_CharT> _Numpunct;
159 # ifndef _STLP_NO_BOOL
160 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end,
161 ios_base& __str, ios_base::iostate& __err, bool& __val) const;
164 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
165 ios_base::iostate& __err, long& __val) const;
166 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
167 ios_base::iostate& __err, unsigned short& __val) const;
168 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
169 ios_base::iostate& __err, unsigned int& __val) const;
170 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
171 ios_base::iostate& __err, unsigned long& __val) const;
172 //# ifdef _STLP_FIX_LIBRARY_ISSUES
173 // issue 118 : those are actually not supposed to be here
174 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
175 ios_base::iostate& __err, short& __val) const;
176 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
177 ios_base::iostate& __err, int& __val) const;
179 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
180 ios_base::iostate& __err, float& __val) const;
181 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
182 ios_base::iostate& __err, double& __val) const;
183 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
184 ios_base::iostate& __err,
187 #ifndef _STLP_NO_LONG_DOUBLE
188 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
189 ios_base::iostate& __err, long double& __val) const;
190 #endif /* _STLP_NO_LONG_DOUBLE */
192 #ifdef _STLP_LONG_LONG
194 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
195 ios_base::iostate& __err, _STLP_LONG_LONG& __val) const;
196 virtual _InputIter do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
197 ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const;
198 #endif /* _STLP_LONG_LONG */
203 # ifdef _STLP_USE_TEMPLATE_EXPORT
204 _STLP_EXPORT_TEMPLATE_CLASS num_get<char, istreambuf_iterator<char, char_traits<char> > >;
205 // _STLP_EXPORT_TEMPLATE_CLASS num_get<char, const char*>;
206 # ifndef _STLP_NO_WCHAR_T
207 _STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
208 // _STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, const wchar_t*>;
209 # endif /* _STLP_NO_WCHAR_T */
212 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
214 _STLP_DECLSPEC extern bool _STLP_CALL __valid_grouping(const char*, const char*, const char*, const char*);
216 template <class _InputIter, class _Integer>
218 __get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val);
220 inline bool _STLP_CALL __get_fdigit(char& __c, const char*);
221 inline bool _STLP_CALL __get_fdigit_or_sep(char& __c, char __sep, const char *);
222 # ifndef _STLP_NO_WCHAR_T
223 inline bool _STLP_CALL __get_fdigit(wchar_t&, const wchar_t*);
224 inline bool _STLP_CALL __get_fdigit_or_sep(wchar_t&, wchar_t, const wchar_t*);
227 inline void _STLP_CALL
228 _Initialize_get_float(const ctype<char>&,
229 char& Plus, char& Minus,
230 char& pow_e, char& pow_E,
238 // Helper functions for _M_do_get_float.
240 # ifndef _STLP_NO_WCHAR_T
242 inline void _STLP_CALL
243 _Initialize_get_float( const ctype<wchar_t>& ct,
244 wchar_t& Plus, wchar_t& Minus,
245 wchar_t& pow_e, wchar_t& pow_E,
248 char ndigits[11] = "0123456789";
249 Plus = ct.widen('+');
250 Minus = ct.widen('-');
251 pow_e = ct.widen('e');
252 pow_E = ct.widen('E');
253 ct.widen(ndigits + 0, ndigits + 10, digits);
256 # endif /* WCHAR_T */
259 template<class _CharT>
260 inline void _STLP_CALL
261 _Initialize_get_float( const ctype<_CharT>& ct,
262 _CharT& Plus, _CharT& Minus,
263 _CharT& pow_e, _CharT& pow_E,
266 char ndigits[11] = "0123456789";
267 Plus = ct.widen('+');
268 Minus = ct.widen('-');
269 pow_e = ct.widen('e');
270 pow_E = ct.widen('E');
271 ct.widen(ndigits + 0, ndigits + 10, digits);
275 int _STLP_CALL __string_to_float(const string&, float&);
276 int _STLP_CALL __string_to_float(const string&, double&);
277 # ifndef _STLP_NO_LONG_DOUBLE
278 int _STLP_CALL __string_to_float(const string&, long double&);
282 # if defined (__BORLANDC__) && defined (_RTLDLL)
283 inline void _Stl_loc_init_num_get() {
284 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
285 num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()._M_index = 12;
286 num_get<char, const char*>::GetFacetLocaleId()._M_index = 13;
288 num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 12;
289 num_get<char, const char*>::id._M_index = 13;
291 # ifndef _STLP_NO_WCHAR_T
292 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
293 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()._M_index = 31;
294 num_get<wchar_t, const wchar_t*>::GetFacetLocaleId()._M_index = 32;
296 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 31;
297 num_get<wchar_t, const wchar_t*>::id._M_index = 32;
303 _STLP_DECLSPEC unsigned char* _STLP_CALL __get_digit_val_table(void);
304 _STLP_DECLSPEC char* _STLP_CALL __get_narrow_atoms(void);
307 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && ! defined (_STLP_LINK_TIME_INSTANTIATION)
308 # include <stl/_num_get.c>
311 #endif /* _STLP_INTERNAL_NUM_GET_H */