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