home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _num_get.h < prev    next >
C/C++ Source or Header  |  2001-11-26  |  9KB  |  260 lines

  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_GET_H
  24. #define _STLP_INTERNAL_NUM_GET_H
  25.  
  26. #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
  27. # include <stl/_istreambuf_iterator.h>
  28. #endif
  29.  
  30. # ifndef _STLP_C_LOCALE_H
  31. #  include <stl/c_locale.h>
  32. # endif
  33.  
  34. #ifndef _STLP_INTERNAL_NUMPUNCT_H
  35. # include <stl/_numpunct.h>
  36. #endif
  37. #ifndef _STLP_INTERNAL_CTYPE_H
  38. # include <stl/_ctype.h>
  39. #endif
  40.  
  41. _STLP_BEGIN_NAMESPACE
  42.  
  43. //----------------------------------------------------------------------
  44. // num_get facets
  45.  
  46. # ifdef _STLP_LIMITED_DEFAULT_TEMPLATES
  47. template <class _CharT, class _InputIter>  
  48. # else
  49. template <class _CharT, class _InputIter = istreambuf_iterator<_CharT> >  
  50. # endif
  51. class num_get: public locale::facet
  52. {
  53.   friend class _Locale;
  54. public:
  55.   typedef _CharT     char_type;
  56.   typedef _InputIter iter_type;
  57.  
  58.   explicit num_get(size_t __refs = 0): locale::facet(__refs) {}
  59.     
  60. # ifndef _STLP_NO_BOOL
  61.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  62.                 ios_base::iostate& __err, bool& __val) const {
  63.     return do_get(__in, __end, __str, __err, __val);
  64.   }
  65. # endif
  66.  
  67. # ifdef _STLP_FIX_LIBRARY_ISSUES
  68.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  69.                 ios_base::iostate& __err, short& __val) const {
  70.     return do_get(__in, __end, __str, __err, __val);
  71.   }
  72.  
  73.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  74.                 ios_base::iostate& __err, int& __val) const {
  75.     return do_get(__in, __end, __str, __err, __val);
  76.   }
  77. # endif
  78.  
  79.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  80.                 ios_base::iostate& __err, long& __val) const {
  81.     return do_get(__in, __end, __str, __err, __val);
  82.   }
  83.  
  84.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  85.                 ios_base::iostate& __err, unsigned short& __val) const {
  86.     return do_get(__in, __end, __str, __err, __val);
  87.   }
  88.  
  89.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  90.                 ios_base::iostate& __err, unsigned int& __val) const {
  91.     return do_get(__in, __end, __str, __err, __val);
  92.   }
  93.  
  94.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  95.                 ios_base::iostate& __err, unsigned long& __val) const {
  96.     return do_get(__in, __end, __str, __err, __val);
  97.   }
  98.  
  99. #ifdef _STLP_LONG_LONG
  100.  
  101.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  102.                 ios_base::iostate& __err, _STLP_LONG_LONG& __val) const {
  103.     return do_get(__in, __end, __str, __err, __val);
  104.   }
  105.  
  106.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  107.                 ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const {
  108.     return do_get(__in, __end, __str, __err, __val);
  109.   }
  110.  
  111. #endif /* _STLP_LONG_LONG */
  112.  
  113.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  114.                  ios_base::iostate& __err, float& __val) const {
  115.     return do_get(__in, __end, __str, __err, __val);
  116.   }
  117.  
  118.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  119.                 ios_base::iostate& __err, double& __val) const {
  120.     return do_get(__in, __end, __str, __err, __val);
  121.   }
  122.  
  123. # ifndef _STLP_NO_LONG_DOUBLE
  124.  
  125.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  126.                 ios_base::iostate& __err, long double& __val) const {
  127.     return do_get(__in, __end, __str, __err, __val);
  128.   }
  129. # endif
  130.  
  131.   _InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
  132.                 ios_base::iostate& __err, void*& __val) const {
  133.     return do_get(__in, __end, __str, __err, __val);
  134.   }
  135.  
  136.   _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
  137.  
  138. protected:
  139.   ~num_get() {}
  140.  
  141.   typedef string               string_type; 
  142.   typedef ctype<_CharT>        _Ctype;
  143.   typedef numpunct<_CharT>     _Numpunct;
  144.  
  145. # ifndef _STLP_NO_BOOL
  146.   virtual _InputIter do_get(_InputIter __in, _InputIter __end,
  147.                            ios_base& __str, ios_base::iostate& __err, bool& __val) const;
  148. # endif
  149.  
  150.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  151.                            ios_base::iostate& __err, long& __val) const;
  152.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  153.                            ios_base::iostate& __err, unsigned short& __val) const;
  154.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  155.                            ios_base::iostate& __err, unsigned int& __val) const;
  156.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  157.                            ios_base::iostate& __err, unsigned long& __val) const;
  158. # ifdef _STLP_FIX_LIBRARY_ISSUES
  159.   // issue 118 : those are actually not supposed to be here
  160.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  161.                            ios_base::iostate& __err, short& __val) const;
  162.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  163.                            ios_base::iostate& __err, int& __val) const;
  164. # endif
  165.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  166.                           ios_base::iostate& __err, float& __val) const;
  167.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  168.                            ios_base::iostate& __err, double& __val) const;
  169.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  170.                            ios_base::iostate& __err,
  171.                            void*& __p) const;
  172.  
  173. #ifndef _STLP_NO_LONG_DOUBLE
  174.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  175.                            ios_base::iostate& __err, long double& __val) const;
  176. #endif /* _STLP_LONG_DOUBLE */
  177.  
  178. #ifdef _STLP_LONG_LONG
  179.  
  180.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  181.                             ios_base::iostate& __err, _STLP_LONG_LONG& __val) const;
  182.   virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  183.                            ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const;
  184. #endif /* _STLP_LONG_LONG */
  185.  
  186. };
  187.  
  188.  
  189. # ifdef _STLP_USE_TEMPLATE_EXPORT
  190. _STLP_EXPORT_TEMPLATE_CLASS num_get<char, istreambuf_iterator<char, char_traits<char> > >;
  191. // _STLP_EXPORT_TEMPLATE_CLASS num_get<char, const char*>;
  192. #  ifndef _STLP_NO_WCHAR_T
  193. _STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
  194. // _STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, const wchar_t*>;
  195. #  endif /* _STLP_NO_WCHAR_T */
  196. # endif
  197.  
  198. # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
  199.  
  200. extern bool  _STLP_CALL __valid_grouping(const char*, const char*, const char*, const char*);
  201.  
  202. template <class _InputIter, class _Integer>
  203. bool _STLP_CALL
  204. __get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val);
  205.  
  206. inline bool _STLP_CALL __get_fdigit(char& __c, const char*);
  207. inline bool _STLP_CALL __get_fdigit_or_sep(char& __c, char __sep, const char *);
  208. # ifndef _STLP_NO_WCHAR_T
  209. bool _STLP_CALL __get_fdigit(wchar_t&, const wchar_t*);
  210. bool _STLP_CALL __get_fdigit_or_sep(wchar_t&, wchar_t, const wchar_t*);
  211. # endif
  212.  
  213. inline void  _STLP_CALL
  214. _Initialize_get_float(const ctype<char>&,
  215.                        char& Plus, char& Minus,
  216.                        char& pow_e, char& pow_E,
  217.                        char*)
  218. {
  219.   Plus = '+';
  220.   Minus = '-';
  221.   pow_e = 'e';
  222.   pow_E = 'E';
  223. }
  224.  
  225. # ifndef _STLP_NO_WCHAR_T
  226. void  _STLP_CALL _Initialize_get_float(const ctype<wchar_t>&,
  227.                                         wchar_t&, wchar_t&, wchar_t&, wchar_t&, wchar_t*);
  228. # endif
  229. void  _STLP_CALL __string_to_float(const string&, float&);
  230. void  _STLP_CALL __string_to_float(const string&, double&);
  231. # ifndef _STLP_NO_LONG_DOUBLE
  232. void  _STLP_CALL __string_to_float(const string&, long double&);
  233. # endif
  234. # endif
  235.  
  236. # if defined (__BORLANDC__) && defined (_RTLDLL)
  237. inline void _Stl_loc_init_num_get() {  
  238.   num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 12;
  239.   num_get<char, const char*>::id._M_index = 13;
  240.   
  241. # ifndef _STLP_NO_WCHAR_T
  242.   num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 31;
  243.   num_get<wchar_t, const wchar_t*>::id._M_index = 32;
  244. # endif
  245. # endif
  246.  
  247. _STLP_END_NAMESPACE
  248.  
  249. #  if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && ! defined (_STLP_LINK_TIME_INSTANTIATION)
  250. #   include <stl/_num_get.c>
  251. #  endif
  252.  
  253. #endif /* _STLP_INTERNAL_NUM_GET_H */
  254.  
  255. // Local Variables:
  256. // mode:C++
  257. // End:
  258.  
  259.