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