ossrv_pub/localization_function_api/inc/stdapis/stlport/stl/_num_get.h
changeset 31 ce057bb09d0b
child 45 4b03adbd26ca
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     1 /*
       
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
       
     3  * Copyright (c) 1999
       
     4  * Silicon Graphics Computer Systems, Inc.
       
     5  *
       
     6  * Copyright (c) 1999 
       
     7  * Boris Fomitchev
       
     8  *
       
     9  * This material is provided "as is", with absolutely no warranty expressed
       
    10  * or implied. Any use is at your own risk.
       
    11  *
       
    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.
       
    17  *
       
    18  */ 
       
    19 // WARNING: This is an internal header file, included by other C++
       
    20 // standard library headers.  You should not attempt to use this header
       
    21 // file directly.
       
    22 
       
    23 
       
    24 #ifndef _STLP_INTERNAL_NUM_GET_H
       
    25 #define _STLP_INTERNAL_NUM_GET_H
       
    26 
       
    27 #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
       
    28 # include <stl/_istreambuf_iterator.h>
       
    29 #endif
       
    30 
       
    31 # ifndef _STLP_C_LOCALE_H
       
    32 #  include <stl/c_locale.h>
       
    33 # endif
       
    34 
       
    35 #ifndef _STLP_INTERNAL_NUMPUNCT_H
       
    36 # include <stl/_numpunct.h>
       
    37 #endif
       
    38 #ifndef _STLP_INTERNAL_CTYPE_H
       
    39 # include <stl/_ctype.h>
       
    40 #endif
       
    41 
       
    42 _STLP_BEGIN_NAMESPACE
       
    43 
       
    44 //----------------------------------------------------------------------
       
    45 // num_get facets
       
    46 
       
    47 # ifdef _STLP_LIMITED_DEFAULT_TEMPLATES
       
    48 template <class _CharT, class _InputIter>  
       
    49 # else
       
    50 template <class _CharT, class _InputIter = istreambuf_iterator<_CharT> >  
       
    51 # endif
       
    52 #ifdef __SYMBIAN32__
       
    53 class num_get : public locale::facet
       
    54 #else
       
    55 class num_get: public locale::facet
       
    56 #endif
       
    57 {
       
    58   friend class _Locale;
       
    59 public:
       
    60   typedef _CharT     char_type;
       
    61   typedef _InputIter iter_type;
       
    62 
       
    63   explicit   num_get(size_t __refs = 0): locale::facet(__refs) {}
       
    64     
       
    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);
       
    69   }
       
    70 # endif
       
    71 
       
    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);
       
    76   }
       
    77 
       
    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);
       
    81   }
       
    82 //# endif
       
    83 
       
    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);
       
    87   }
       
    88 
       
    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);
       
    92   }
       
    93 
       
    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);
       
    97   }
       
    98 
       
    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);
       
   102   }
       
   103 
       
   104 #ifdef _STLP_LONG_LONG
       
   105 
       
   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);
       
   109   }
       
   110 
       
   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);
       
   114   }
       
   115 
       
   116 #endif /* _STLP_LONG_LONG */
       
   117 
       
   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);
       
   121   }
       
   122 
       
   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);
       
   126   }
       
   127 
       
   128 # ifndef _STLP_NO_LONG_DOUBLE
       
   129 
       
   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);
       
   133   }
       
   134 # endif
       
   135 
       
   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);
       
   139   }
       
   140 
       
   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**);
       
   147     
       
   148 #else
       
   149     _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
       
   150 #endif
       
   151 
       
   152 protected:
       
   153   ~num_get() {}
       
   154 
       
   155   typedef string               string_type; 
       
   156   typedef ctype<_CharT>        _Ctype;
       
   157   typedef numpunct<_CharT>     _Numpunct;
       
   158 
       
   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;
       
   162 # endif
       
   163 
       
   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;
       
   178 //# endif
       
   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,
       
   185                            void*& __p) const;
       
   186 
       
   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 */
       
   191 
       
   192 #ifdef _STLP_LONG_LONG
       
   193 
       
   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 */
       
   199 
       
   200 };
       
   201 
       
   202 
       
   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 */
       
   210 # endif
       
   211 
       
   212 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
       
   213 
       
   214 _STLP_DECLSPEC extern bool  _STLP_CALL __valid_grouping(const char*, const char*, const char*, const char*);
       
   215 
       
   216 template <class _InputIter, class _Integer>
       
   217 bool _STLP_CALL
       
   218 __get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val);
       
   219 
       
   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*);
       
   225 # endif
       
   226 
       
   227 inline void  _STLP_CALL
       
   228 _Initialize_get_float(const ctype<char>&,
       
   229                        char& Plus, char& Minus,
       
   230                        char& pow_e, char& pow_E,
       
   231                        char*)
       
   232 {
       
   233   Plus = '+';
       
   234   Minus = '-';
       
   235   pow_e = 'e';
       
   236   pow_E = 'E';
       
   237 }
       
   238 // Helper functions for _M_do_get_float.
       
   239 
       
   240 # ifndef _STLP_NO_WCHAR_T
       
   241 
       
   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,
       
   246                        wchar_t* digits)
       
   247 {
       
   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);
       
   254 }
       
   255 
       
   256 # endif /* WCHAR_T */
       
   257 
       
   258 #ifdef __SYMBIAN32__
       
   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,
       
   264                        _CharT* digits)
       
   265 {
       
   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);
       
   272 }
       
   273 #endif
       
   274 
       
   275 _STLP_DECLSPEC int  _STLP_CALL __string_to_float(const string&, float&);
       
   276 _STLP_DECLSPEC 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&);
       
   279 # endif
       
   280 # endif
       
   281 
       
   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;
       
   287 #else
       
   288   num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 12;
       
   289   num_get<char, const char*>::id._M_index = 13;
       
   290 #endif
       
   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;
       
   295 #else
       
   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;
       
   298 #endif
       
   299 # endif
       
   300 } 
       
   301 # endif
       
   302 
       
   303 _STLP_DECLSPEC unsigned char* _STLP_CALL __get_digit_val_table(void);
       
   304 _STLP_DECLSPEC char* _STLP_CALL __get_narrow_atoms(void);
       
   305 _STLP_END_NAMESPACE
       
   306 
       
   307 #  if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && ! defined (_STLP_LINK_TIME_INSTANTIATION)
       
   308 #   include <stl/_num_get.c>
       
   309 #  endif
       
   310 
       
   311 #endif /* _STLP_INTERNAL_NUM_GET_H */
       
   312 
       
   313 // Local Variables:
       
   314 // mode:C++
       
   315 // End:
       
   316