|
1 /* |
|
2 * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
3 * |
|
4 * Copyright (c) 1999 |
|
5 * Silicon Graphics Computer Systems, Inc. |
|
6 * |
|
7 * Copyright (c) 1999 |
|
8 * Boris Fomitchev |
|
9 * |
|
10 * This material is provided "as is", with absolutely no warranty expressed |
|
11 * or implied. Any use is at your own risk. |
|
12 * |
|
13 * Permission to use or copy this software for any purpose is hereby granted |
|
14 * without fee, provided the above notices are retained on all copies. |
|
15 * Permission to modify the code and to distribute modified code is granted, |
|
16 * provided the above notices are retained, and a notice that the code was |
|
17 * modified is included with the above copyright notice. |
|
18 * |
|
19 */ |
|
20 #include "stlport_prefix.h" |
|
21 |
|
22 #include <locale> |
|
23 #include <istream> |
|
24 #include <algorithm> |
|
25 |
|
26 #ifdef __SYMBIAN32__WSD__ |
|
27 #include <libstdcppwsd.h> |
|
28 #endif //__SYMBIAN32__WSD__ |
|
29 |
|
30 _STLP_BEGIN_NAMESPACE |
|
31 _STLP_MOVE_TO_PRIV_NAMESPACE |
|
32 |
|
33 // __valid_grouping compares two strings, one representing the |
|
34 // group sizes encountered when reading an integer, and the other |
|
35 // representing the valid group sizes as returned by the numpunct |
|
36 // grouping() member function. Both are interpreted right-to-left. |
|
37 // The grouping string is treated as if it were extended indefinitely |
|
38 // with its last value. For a grouping to be valid, each term in |
|
39 // the first string must be equal to the corresponding term in the |
|
40 // second, except for the last, which must be less than or equal. |
|
41 |
|
42 // boris : this takes reversed first string ! |
|
43 _STLP_DECLSPEC bool _STLP_CALL |
|
44 __valid_grouping(const char * first1, const char * last1, |
|
45 const char * first2, const char * last2) { |
|
46 if (first1 == last1 || first2 == last2) return true; |
|
47 |
|
48 --last1; --last2; |
|
49 |
|
50 while (first1 != last1) { |
|
51 if (*last1 != *first2) |
|
52 return false; |
|
53 --last1; |
|
54 if (first2 != last2) ++first2; |
|
55 } |
|
56 |
|
57 return *last1 <= *first2; |
|
58 } |
|
59 |
|
60 _STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index) { |
|
61 static const unsigned char __val_table[128] = { |
|
62 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
|
63 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
|
64 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
|
65 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
|
66 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
|
67 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
|
68 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
|
69 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF |
|
70 }; |
|
71 |
|
72 return __val_table[__index]; |
|
73 } |
|
74 |
|
75 _STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms() |
|
76 { return "+-0xX"; } |
|
77 |
|
78 // index is actually a char |
|
79 |
|
80 #if !defined (_STLP_NO_WCHAR_T) |
|
81 |
|
82 // Similar, except return the character itself instead of the numeric |
|
83 // value. Used for floating-point input. |
|
84 _STLP_DECLSPEC bool _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits) { |
|
85 const wchar_t* p = find(digits, digits + 10, c); |
|
86 if (p != digits + 10) { |
|
87 c = (char)('0' + (p - digits)); |
|
88 return true; |
|
89 } |
|
90 else |
|
91 return false; |
|
92 } |
|
93 |
|
94 _STLP_DECLSPEC bool _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep, |
|
95 const wchar_t * digits) { |
|
96 if (c == sep) { |
|
97 c = (char)','; |
|
98 return true; |
|
99 } |
|
100 else |
|
101 return __get_fdigit(c, digits); |
|
102 } |
|
103 |
|
104 #endif |
|
105 |
|
106 _STLP_MOVE_TO_STD_NAMESPACE |
|
107 |
|
108 #if defined (__SYMBIAN32__WSD__) |
|
109 template <> |
|
110 _STLP_DECLSPEC locale::id& num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId() |
|
111 { |
|
112 return get_libcpp_wsd().num_get_char_istreambuf_iterator_id; |
|
113 } |
|
114 # ifndef _STLP_NO_WCHAR_T |
|
115 template <> |
|
116 _STLP_DECLSPEC locale::id& num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId() |
|
117 { |
|
118 return get_libcpp_wsd().num_get_wchar_istreambuf_iterator_id; |
|
119 } |
|
120 # endif /* _STLP_NO_WCHAR_T */ |
|
121 #endif /* __SYMBIAN32__WSD__ */ |
|
122 |
|
123 #if !defined(_STLP_NO_FORCE_INSTANTIATE) |
|
124 //---------------------------------------------------------------------- |
|
125 // Force instantiation of of num_get<> |
|
126 template class _STLP_CLASS_DECLSPEC istreambuf_iterator<char, char_traits<char> >; |
|
127 // template class num_get<char, const char*>; |
|
128 template class num_get<char, istreambuf_iterator<char, char_traits<char> > >; |
|
129 |
|
130 # if !defined (_STLP_NO_WCHAR_T) |
|
131 template class _STLP_CLASS_DECLSPEC istreambuf_iterator<wchar_t, char_traits<wchar_t> >; |
|
132 template class num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
|
133 // template class num_get<wchar_t, const wchar_t*>; |
|
134 # endif |
|
135 #endif |
|
136 |
|
137 #if defined(__EPOC32__) |
|
138 template <> |
|
139 locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id={12}; |
|
140 |
|
141 # if !defined (STLP_NO_WCHAR_T) |
|
142 template <> |
|
143 locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id={31}; |
|
144 # endif |
|
145 #endif |
|
146 |
|
147 _STLP_END_NAMESPACE |
|
148 |
|
149 // Local Variables: |
|
150 // mode:C++ |
|
151 // End: |