1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/stlport/src/num_get.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,120 @@ 1.4 +/* 1.5 + * Copyright (c) 1999 1.6 + * Silicon Graphics Computer Systems, Inc. 1.7 + * 1.8 + * Copyright (c) 1999 1.9 + * Boris Fomitchev 1.10 + * 1.11 + * This material is provided "as is", with absolutely no warranty expressed 1.12 + * or implied. Any use is at your own risk. 1.13 + * 1.14 + * Permission to use or copy this software for any purpose is hereby granted 1.15 + * without fee, provided the above notices are retained on all copies. 1.16 + * Permission to modify the code and to distribute modified code is granted, 1.17 + * provided the above notices are retained, and a notice that the code was 1.18 + * modified is included with the above copyright notice. 1.19 + * 1.20 + */ 1.21 +#include "stlport_prefix.h" 1.22 + 1.23 +#include <locale> 1.24 +#include <istream> 1.25 +#include <algorithm> 1.26 + 1.27 +_STLP_BEGIN_NAMESPACE 1.28 +_STLP_MOVE_TO_PRIV_NAMESPACE 1.29 + 1.30 +// __valid_grouping compares two strings, one representing the 1.31 +// group sizes encountered when reading an integer, and the other 1.32 +// representing the valid group sizes as returned by the numpunct 1.33 +// grouping() member function. Both are interpreted right-to-left. 1.34 +// The grouping string is treated as if it were extended indefinitely 1.35 +// with its last value. For a grouping to be valid, each term in 1.36 +// the first string must be equal to the corresponding term in the 1.37 +// second, except for the last, which must be less than or equal. 1.38 + 1.39 +// boris : this takes reversed first string ! 1.40 +bool _STLP_CALL 1.41 +__valid_grouping(const char * first1, const char * last1, 1.42 + const char * first2, const char * last2) { 1.43 + if (first1 == last1 || first2 == last2) return true; 1.44 + 1.45 + --last1; --last2; 1.46 + 1.47 + while (first1 != last1) { 1.48 + if (*last1 != *first2) 1.49 + return false; 1.50 + --last1; 1.51 + if (first2 != last2) ++first2; 1.52 + } 1.53 + 1.54 + return *last1 <= *first2; 1.55 +} 1.56 + 1.57 +_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index) { 1.58 + static const unsigned char __val_table[128] = { 1.59 + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 1.60 + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 1.61 + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 1.62 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 1.63 + 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 1.64 + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 1.65 + 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 1.66 + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF 1.67 + }; 1.68 + 1.69 + return __val_table[__index]; 1.70 +} 1.71 + 1.72 +_STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms() 1.73 +{ return "+-0xX"; } 1.74 + 1.75 +// index is actually a char 1.76 + 1.77 +#if !defined (_STLP_NO_WCHAR_T) 1.78 + 1.79 +// Similar, except return the character itself instead of the numeric 1.80 +// value. Used for floating-point input. 1.81 +bool _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits) { 1.82 + const wchar_t* p = find(digits, digits + 10, c); 1.83 + if (p != digits + 10) { 1.84 + c = (char)('0' + (p - digits)); 1.85 + return true; 1.86 + } 1.87 + else 1.88 + return false; 1.89 +} 1.90 + 1.91 +bool _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep, 1.92 + const wchar_t * digits) { 1.93 + if (c == sep) { 1.94 + c = (char)','; 1.95 + return true; 1.96 + } 1.97 + else 1.98 + return __get_fdigit(c, digits); 1.99 +} 1.100 + 1.101 +#endif 1.102 + 1.103 +_STLP_MOVE_TO_STD_NAMESPACE 1.104 + 1.105 +#if !defined(_STLP_NO_FORCE_INSTANTIATE) 1.106 +//---------------------------------------------------------------------- 1.107 +// Force instantiation of num_get<> 1.108 +template class _STLP_CLASS_DECLSPEC istreambuf_iterator<char, char_traits<char> >; 1.109 +// template class num_get<char, const char*>; 1.110 +template class num_get<char, istreambuf_iterator<char, char_traits<char> > >; 1.111 + 1.112 +# if !defined (_STLP_NO_WCHAR_T) 1.113 +template class _STLP_CLASS_DECLSPEC istreambuf_iterator<wchar_t, char_traits<wchar_t> >; 1.114 +template class num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >; 1.115 +// template class num_get<wchar_t, const wchar_t*>; 1.116 +# endif 1.117 +#endif 1.118 + 1.119 +_STLP_END_NAMESPACE 1.120 + 1.121 +// Local Variables: 1.122 +// mode:C++ 1.123 +// End: