williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
|
williamr@4
|
3 |
*
|
williamr@4
|
4 |
* Copyright (c) 1999
|
williamr@4
|
5 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@4
|
6 |
*
|
williamr@4
|
7 |
* Copyright (c) 1999
|
williamr@4
|
8 |
* Boris Fomitchev
|
williamr@4
|
9 |
*
|
williamr@4
|
10 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@4
|
11 |
* or implied. Any use is at your own risk.
|
williamr@4
|
12 |
*
|
williamr@4
|
13 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@4
|
14 |
* without fee, provided the above notices are retained on all copies.
|
williamr@4
|
15 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@4
|
16 |
* provided the above notices are retained, and a notice that the code was
|
williamr@4
|
17 |
* modified is included with the above copyright notice.
|
williamr@4
|
18 |
*
|
williamr@4
|
19 |
*/
|
williamr@4
|
20 |
#ifndef _STLP_TIME_FACETS_C
|
williamr@4
|
21 |
#define _STLP_TIME_FACETS_C
|
williamr@4
|
22 |
|
williamr@4
|
23 |
#ifndef _STLP_INTERNAL_TIME_FACETS_H
|
williamr@4
|
24 |
# include <stl/_time_facets.h>
|
williamr@4
|
25 |
#endif
|
williamr@4
|
26 |
|
williamr@4
|
27 |
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
|
williamr@4
|
28 |
|
williamr@4
|
29 |
#ifndef _STLP_INTERNAL_NUM_PUT_H
|
williamr@4
|
30 |
# include <stl/_num_put.h>
|
williamr@4
|
31 |
#endif
|
williamr@4
|
32 |
|
williamr@4
|
33 |
#ifndef _STLP_INTERNAL_NUM_GET_H
|
williamr@4
|
34 |
# include <stl/_num_get.h>
|
williamr@4
|
35 |
#endif
|
williamr@4
|
36 |
|
williamr@4
|
37 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
38 |
|
williamr@4
|
39 |
//----------------------------------------------------------------------
|
williamr@4
|
40 |
// Declarations of static template members.
|
williamr@4
|
41 |
# if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
|
williamr@4
|
42 |
# if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
|
williamr@4
|
43 |
template <class _CharT, class _InputIterator>
|
williamr@4
|
44 |
locale::id time_get<_CharT, _InputIterator>::id;
|
williamr@4
|
45 |
|
williamr@4
|
46 |
template <class _CharT, class _OutputIterator>
|
williamr@4
|
47 |
locale::id time_put<_CharT, _OutputIterator>::id;
|
williamr@4
|
48 |
#endif
|
williamr@4
|
49 |
|
williamr@4
|
50 |
# else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
|
williamr@4
|
51 |
|
williamr@4
|
52 |
typedef time_get<char, const char*> time_get_char;
|
williamr@4
|
53 |
typedef time_get<char, char*> time_get_char_2;
|
williamr@4
|
54 |
typedef time_get<char, istreambuf_iterator<char, char_traits<char> > > time_get_char_3;
|
williamr@4
|
55 |
typedef time_put<char, const char*> time_put_char;
|
williamr@4
|
56 |
typedef time_put<char, char*> time_put_char_2;
|
williamr@4
|
57 |
typedef time_put<char, ostreambuf_iterator<char, char_traits<char> > > time_put_char_3;
|
williamr@4
|
58 |
|
williamr@4
|
59 |
#ifndef __SYMBIAN32__
|
williamr@4
|
60 |
__DECLARE_INSTANCE(locale::id, time_get_char::id, );
|
williamr@4
|
61 |
__DECLARE_INSTANCE(locale::id, time_get_char_2::id, );
|
williamr@4
|
62 |
__DECLARE_INSTANCE(locale::id, time_get_char_3::id, );
|
williamr@4
|
63 |
__DECLARE_INSTANCE(locale::id, time_put_char::id, );
|
williamr@4
|
64 |
__DECLARE_INSTANCE(locale::id, time_put_char_2::id, );
|
williamr@4
|
65 |
__DECLARE_INSTANCE(locale::id, time_put_char_3::id, );
|
williamr@4
|
66 |
#endif
|
williamr@4
|
67 |
|
williamr@4
|
68 |
# ifndef _STLP_NO_WCHAR_T
|
williamr@4
|
69 |
|
williamr@4
|
70 |
typedef time_get<wchar_t, const wchar_t*> time_get_wchar_t;
|
williamr@4
|
71 |
typedef time_get<wchar_t, wchar_t*> time_get_wchar_t_2;
|
williamr@4
|
72 |
typedef time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > time_get_wchar_t_3;
|
williamr@4
|
73 |
typedef time_put<wchar_t, const wchar_t*> time_put_wchar_t;
|
williamr@4
|
74 |
typedef time_put<wchar_t, wchar_t*> time_put_wchar_t_2;
|
williamr@4
|
75 |
typedef time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > time_put_wchar_t_3;
|
williamr@4
|
76 |
|
williamr@4
|
77 |
#ifndef __SYMBIAN32__
|
williamr@4
|
78 |
__DECLARE_INSTANCE(locale::id, time_get_wchar_t::id, );
|
williamr@4
|
79 |
__DECLARE_INSTANCE(locale::id, time_get_wchar_t_2::id, );
|
williamr@4
|
80 |
__DECLARE_INSTANCE(locale::id, time_get_wchar_t_3::id, );
|
williamr@4
|
81 |
__DECLARE_INSTANCE(locale::id, time_put_wchar_t::id, );
|
williamr@4
|
82 |
__DECLARE_INSTANCE(locale::id, time_put_wchar_t_2::id, );
|
williamr@4
|
83 |
__DECLARE_INSTANCE(locale::id, time_put_wchar_t_3::id, );
|
williamr@4
|
84 |
#endif
|
williamr@4
|
85 |
|
williamr@4
|
86 |
# endif
|
williamr@4
|
87 |
|
williamr@4
|
88 |
# endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
|
williamr@4
|
89 |
|
williamr@4
|
90 |
template <class _InIt, class _RAIt, class _DiffType>
|
williamr@4
|
91 |
_RAIt _STLP_CALL
|
williamr@4
|
92 |
__match(_InIt& __first, _InIt& __last, _RAIt __name, _RAIt __name_end, _DiffType*) {
|
williamr@4
|
93 |
typedef _DiffType difference_type;
|
williamr@4
|
94 |
difference_type __n = __name_end - __name;
|
williamr@4
|
95 |
size_t __max_pos = 0;
|
williamr@4
|
96 |
difference_type __i;
|
williamr@4
|
97 |
difference_type __pos = 0;
|
williamr@4
|
98 |
difference_type __check_count = __n;
|
williamr@4
|
99 |
bool __do_check[_MAXNAMES];
|
williamr@4
|
100 |
_RAIt __matching_name[_MAX_NAME_LENGTH];
|
williamr@4
|
101 |
|
williamr@4
|
102 |
for (__i = 0; __i < __n; ++__i)
|
williamr@4
|
103 |
__max_pos = (max)(__max_pos, __name[__i].size());
|
williamr@4
|
104 |
|
williamr@4
|
105 |
for (__i = 0; __i < _MAXNAMES; ++__i)
|
williamr@4
|
106 |
__do_check[__i] = true;
|
williamr@4
|
107 |
|
williamr@4
|
108 |
|
williamr@4
|
109 |
|
williamr@4
|
110 |
for (__i = 0; __i < _MAX_NAME_LENGTH; ++__i)
|
williamr@4
|
111 |
__matching_name[__i] = __name_end;
|
williamr@4
|
112 |
|
williamr@4
|
113 |
while (__first != __last) {
|
williamr@4
|
114 |
for (__i = 0; __i < __n; ++__i)
|
williamr@4
|
115 |
if (__do_check[__i])
|
williamr@4
|
116 |
if (*__first == __name[__i][__pos]) {
|
williamr@4
|
117 |
if (__pos == _DiffType(__name[__i].size()) - 1) {
|
williamr@4
|
118 |
__do_check[__i] = 0;
|
williamr@4
|
119 |
__matching_name[__pos+1] = __name + __i;
|
williamr@4
|
120 |
--__check_count;
|
williamr@4
|
121 |
if (__check_count == 0) {
|
williamr@4
|
122 |
++__first;
|
williamr@4
|
123 |
return __name + __i;
|
williamr@4
|
124 |
}
|
williamr@4
|
125 |
}
|
williamr@4
|
126 |
}
|
williamr@4
|
127 |
else {
|
williamr@4
|
128 |
__do_check[__i] = 0;
|
williamr@4
|
129 |
--__check_count;
|
williamr@4
|
130 |
if (__check_count == 0)
|
williamr@4
|
131 |
return __matching_name[__pos];
|
williamr@4
|
132 |
}
|
williamr@4
|
133 |
|
williamr@4
|
134 |
++__first; ++__pos;
|
williamr@4
|
135 |
}
|
williamr@4
|
136 |
|
williamr@4
|
137 |
return __matching_name[__pos];
|
williamr@4
|
138 |
}
|
williamr@4
|
139 |
|
williamr@4
|
140 |
template <class _InIt, class _RAIt>
|
williamr@4
|
141 |
_RAIt _STLP_CALL
|
williamr@4
|
142 |
__match(_InIt& __first, _InIt& __last, _RAIt __name, _RAIt __name_end) {
|
williamr@4
|
143 |
return __match((_InIt&)__first, (_InIt&)__last, __name, __name_end, _STLP_DISTANCE_TYPE(__name, _InIt));
|
williamr@4
|
144 |
}
|
williamr@4
|
145 |
|
williamr@4
|
146 |
// __get_formatted_time reads input that is assumed to be formatted
|
williamr@4
|
147 |
// according to the rules for the C strftime function (C standard,
|
williamr@4
|
148 |
// 7.12.3.5). This function is used to implement the do_get_time
|
williamr@4
|
149 |
// and do_get_date virtual functions, which depend on the locale
|
williamr@4
|
150 |
// specifications for the time and day formats respectively.
|
williamr@4
|
151 |
// Note the catchall default case, intended mainly for the '%Z'
|
williamr@4
|
152 |
// format designator, which does not make sense here since the
|
williamr@4
|
153 |
// representation of timezones is not part of the locale.
|
williamr@4
|
154 |
//
|
williamr@4
|
155 |
// The case branches are implemented either by doing a match using
|
williamr@4
|
156 |
// the appopriate name table or by doing a __get_integer_nogroup.
|
williamr@4
|
157 |
//
|
williamr@4
|
158 |
// 'y' format is assumed to mean that the input represents years
|
williamr@4
|
159 |
// since 1900. That is, 2002 should be represented as 102. There
|
williamr@4
|
160 |
// is no century-guessing.
|
williamr@4
|
161 |
//
|
williamr@4
|
162 |
// The match is successful if and only if the second component of the
|
williamr@4
|
163 |
// return value is format_end.
|
williamr@4
|
164 |
|
williamr@4
|
165 |
// Note that the antepenultimate parameter is being used only to determine
|
williamr@4
|
166 |
// the correct overloading for the calls to __get_integer_nogroup.
|
williamr@4
|
167 |
|
williamr@4
|
168 |
template <class _InIt1, class _InIt2 /* , class _Ch */ >
|
williamr@4
|
169 |
_InIt2 _STLP_CALL
|
williamr@4
|
170 |
__get_formatted_time _STLP_WEAK (_InIt1 __first, _InIt1 __last,
|
williamr@4
|
171 |
_InIt2 __format, _InIt2 __format_end,
|
williamr@4
|
172 |
/* _Ch, */ const _Time_Info& __table,
|
williamr@4
|
173 |
ios_base::iostate& __err,
|
williamr@4
|
174 |
tm* __t) {
|
williamr@4
|
175 |
while(__first != __last && __format != __format_end) {
|
williamr@4
|
176 |
if (*__format == '%') {
|
williamr@4
|
177 |
++__format;
|
williamr@4
|
178 |
char __c = *__format;
|
williamr@4
|
179 |
switch (__c) {
|
williamr@4
|
180 |
case 'a': {
|
williamr@4
|
181 |
const string* __pr =
|
williamr@4
|
182 |
__match(__first, __last,
|
williamr@4
|
183 |
(string*)__table._M_dayname + 0 , (string*)__table._M_dayname + 7);
|
williamr@4
|
184 |
if (__pr == (string*)__table._M_dayname + 7)
|
williamr@4
|
185 |
return __format;
|
williamr@4
|
186 |
__t->tm_wday = (int)(__pr - (string*)__table._M_dayname);
|
williamr@4
|
187 |
break;
|
williamr@4
|
188 |
}
|
williamr@4
|
189 |
|
williamr@4
|
190 |
case 'A': {
|
williamr@4
|
191 |
const string* __pr =
|
williamr@4
|
192 |
__match(__first, __last,
|
williamr@4
|
193 |
(string*)__table._M_dayname + 7, (string*)__table._M_dayname + 14);
|
williamr@4
|
194 |
if (__pr == (string*)__table._M_dayname + 14)
|
williamr@4
|
195 |
return __format;
|
williamr@4
|
196 |
__t->tm_wday = (int)(__pr - (string*)__table._M_dayname - 7);
|
williamr@4
|
197 |
break;
|
williamr@4
|
198 |
}
|
williamr@4
|
199 |
|
williamr@4
|
200 |
case 'b': {
|
williamr@4
|
201 |
const string* __pr =
|
williamr@4
|
202 |
__match(__first, __last,
|
williamr@4
|
203 |
(string*)__table._M_monthname + 0, (string*)__table._M_monthname + 12);
|
williamr@4
|
204 |
if (__pr == (string*)__table._M_monthname + 12)
|
williamr@4
|
205 |
return __format;
|
williamr@4
|
206 |
__t->tm_mon = (int)(__pr - (string*)__table._M_monthname);
|
williamr@4
|
207 |
break;
|
williamr@4
|
208 |
}
|
williamr@4
|
209 |
|
williamr@4
|
210 |
case 'B': {
|
williamr@4
|
211 |
const string* __pr =
|
williamr@4
|
212 |
__match(__first, __last,
|
williamr@4
|
213 |
(string*)__table._M_monthname + 12, (string*)__table._M_monthname + 24);
|
williamr@4
|
214 |
if (__pr == (string*)__table._M_monthname + 24)
|
williamr@4
|
215 |
return __format;
|
williamr@4
|
216 |
__t->tm_mon = (int)(__pr - (string*)__table._M_monthname - 12);
|
williamr@4
|
217 |
break;
|
williamr@4
|
218 |
}
|
williamr@4
|
219 |
|
williamr@4
|
220 |
case 'd': {
|
williamr@4
|
221 |
bool __pr =
|
williamr@4
|
222 |
__get_decimal_integer(__first, __last, __t->tm_mday);
|
williamr@4
|
223 |
if (!__pr || __t->tm_mday < 1 || __t->tm_mday > 31) {
|
williamr@4
|
224 |
__err |= ios_base::failbit;
|
williamr@4
|
225 |
return __format;
|
williamr@4
|
226 |
}
|
williamr@4
|
227 |
break;
|
williamr@4
|
228 |
}
|
williamr@4
|
229 |
|
williamr@4
|
230 |
case 'H': case 'I': {
|
williamr@4
|
231 |
bool __pr =
|
williamr@4
|
232 |
__get_decimal_integer(__first, __last, __t->tm_hour);
|
williamr@4
|
233 |
if (!__pr)
|
williamr@4
|
234 |
return __format;
|
williamr@4
|
235 |
break;
|
williamr@4
|
236 |
}
|
williamr@4
|
237 |
|
williamr@4
|
238 |
case 'j': {
|
williamr@4
|
239 |
bool __pr =
|
williamr@4
|
240 |
__get_decimal_integer(__first, __last, __t->tm_yday);
|
williamr@4
|
241 |
if (!__pr)
|
williamr@4
|
242 |
return __format;
|
williamr@4
|
243 |
break;
|
williamr@4
|
244 |
}
|
williamr@4
|
245 |
|
williamr@4
|
246 |
case 'm': {
|
williamr@4
|
247 |
bool __pr =
|
williamr@4
|
248 |
__get_decimal_integer(__first, __last, __t->tm_mon);
|
williamr@4
|
249 |
--__t->tm_mon;
|
williamr@4
|
250 |
if (!__pr || __t->tm_mon < 0 || __t->tm_mon > 11) {
|
williamr@4
|
251 |
__err |= ios_base::failbit;
|
williamr@4
|
252 |
return __format;
|
williamr@4
|
253 |
}
|
williamr@4
|
254 |
break;
|
williamr@4
|
255 |
}
|
williamr@4
|
256 |
|
williamr@4
|
257 |
case 'M': {
|
williamr@4
|
258 |
bool __pr =
|
williamr@4
|
259 |
__get_decimal_integer(__first, __last, __t->tm_min);
|
williamr@4
|
260 |
if (!__pr)
|
williamr@4
|
261 |
return __format;
|
williamr@4
|
262 |
break;
|
williamr@4
|
263 |
}
|
williamr@4
|
264 |
|
williamr@4
|
265 |
case 'p': {
|
williamr@4
|
266 |
const string* __pr =
|
williamr@4
|
267 |
__match(__first, __last, (string*)__table._M_am_pm + 0, (string*)__table._M_am_pm + 2);
|
williamr@4
|
268 |
if (__pr == (string*)__table._M_am_pm + 2)
|
williamr@4
|
269 |
return __format;
|
williamr@4
|
270 |
if (__pr == (string*)__table._M_am_pm + 1)
|
williamr@4
|
271 |
__t->tm_hour += 12;
|
williamr@4
|
272 |
break;
|
williamr@4
|
273 |
}
|
williamr@4
|
274 |
|
williamr@4
|
275 |
case 'S': {
|
williamr@4
|
276 |
bool __pr =
|
williamr@4
|
277 |
__get_decimal_integer(__first, __last, __t->tm_sec);
|
williamr@4
|
278 |
if (!__pr)
|
williamr@4
|
279 |
return __format;
|
williamr@4
|
280 |
break;
|
williamr@4
|
281 |
}
|
williamr@4
|
282 |
|
williamr@4
|
283 |
case 'y': {
|
williamr@4
|
284 |
bool __pr =
|
williamr@4
|
285 |
__get_decimal_integer(__first, __last, __t->tm_year);
|
williamr@4
|
286 |
if (!__pr)
|
williamr@4
|
287 |
return __format;
|
williamr@4
|
288 |
break;
|
williamr@4
|
289 |
}
|
williamr@4
|
290 |
|
williamr@4
|
291 |
case 'Y': {
|
williamr@4
|
292 |
bool __pr =
|
williamr@4
|
293 |
__get_decimal_integer(__first, __last, __t->tm_year);
|
williamr@4
|
294 |
__t->tm_year -= 1900;
|
williamr@4
|
295 |
if (!__pr)
|
williamr@4
|
296 |
return __format;
|
williamr@4
|
297 |
break;
|
williamr@4
|
298 |
}
|
williamr@4
|
299 |
|
williamr@4
|
300 |
default:
|
williamr@4
|
301 |
break;
|
williamr@4
|
302 |
}
|
williamr@4
|
303 |
|
williamr@4
|
304 |
}
|
williamr@4
|
305 |
else {
|
williamr@4
|
306 |
if (*__first != *__format)
|
williamr@4
|
307 |
break;
|
williamr@4
|
308 |
__first++;
|
williamr@4
|
309 |
}
|
williamr@4
|
310 |
|
williamr@4
|
311 |
++__format;
|
williamr@4
|
312 |
}
|
williamr@4
|
313 |
|
williamr@4
|
314 |
return __format;
|
williamr@4
|
315 |
}
|
williamr@4
|
316 |
|
williamr@4
|
317 |
template <class _InIt>
|
williamr@4
|
318 |
bool _STLP_CALL
|
williamr@4
|
319 |
__get_short_or_long_dayname(_InIt& __first, _InIt& __last,
|
williamr@4
|
320 |
const _Time_Info& __table, tm* __t) {
|
williamr@4
|
321 |
const string* __pr =
|
williamr@4
|
322 |
__match(__first, __last, __table._M_dayname + 0, __table._M_dayname + 14);
|
williamr@4
|
323 |
__t->tm_wday = (int)(__pr - __table._M_dayname) % 7;
|
williamr@4
|
324 |
return __pr != __table._M_dayname + 14;
|
williamr@4
|
325 |
}
|
williamr@4
|
326 |
|
williamr@4
|
327 |
template <class _InIt>
|
williamr@4
|
328 |
bool _STLP_CALL
|
williamr@4
|
329 |
__get_short_or_long_monthname(_InIt& __first, _InIt& __last,
|
williamr@4
|
330 |
const _Time_Info& __table, tm* __t) {
|
williamr@4
|
331 |
const string* __pr =
|
williamr@4
|
332 |
__match(__first, __last, (string*)__table._M_monthname + 0, (string*)__table._M_monthname + 24);
|
williamr@4
|
333 |
__t->tm_mon = (int)(__pr - __table._M_monthname) % 12;
|
williamr@4
|
334 |
return __pr != __table._M_monthname + 24;
|
williamr@4
|
335 |
}
|
williamr@4
|
336 |
|
williamr@4
|
337 |
# ifndef _STLP_NO_WCHAR_T
|
williamr@4
|
338 |
template <class _OuIt>
|
williamr@4
|
339 |
_OuIt _STLP_CALL
|
williamr@4
|
340 |
__put_time(char * __first, char * __last, _OuIt __stl_out,
|
williamr@4
|
341 |
const ios_base& __s, wchar_t) {
|
williamr@4
|
342 |
//const ctype<wchar_t>& __ct = *(ctype<wchar_t>*)__s._M_ctype_facet();
|
williamr@4
|
343 |
const ctype<wchar_t>& __ct = use_facet< ctype<wchar_t> >(__s.getloc());
|
williamr@4
|
344 |
wchar_t __wbuf[64];
|
williamr@4
|
345 |
__ct.widen(__first, __last, __wbuf);
|
williamr@4
|
346 |
ptrdiff_t __len = __last - __first;
|
williamr@4
|
347 |
wchar_t * __eend = __wbuf + __len;
|
williamr@4
|
348 |
return copy((wchar_t*)__wbuf, __eend, __stl_out);
|
williamr@4
|
349 |
}
|
williamr@4
|
350 |
# endif
|
williamr@4
|
351 |
|
williamr@4
|
352 |
#ifdef __SYMBIAN32__
|
williamr@4
|
353 |
template <class _CharT, class _OuIt>
|
williamr@4
|
354 |
_OuIt _STLP_CALL
|
williamr@4
|
355 |
__put_time(char * __first, char * __last, _OuIt __stl_out,
|
williamr@4
|
356 |
const ios_base& __s, _CharT) {
|
williamr@4
|
357 |
//const ctype<wchar_t>& __ct = *(ctype<wchar_t>*)__s._M_ctype_facet();
|
williamr@4
|
358 |
const ctype<_CharT>& __ct = use_facet< ctype<_CharT> >(__s.getloc());
|
williamr@4
|
359 |
_CharT __wbuf[64];
|
williamr@4
|
360 |
__ct.widen(__first, __last, __wbuf);
|
williamr@4
|
361 |
ptrdiff_t __len = __last - __first;
|
williamr@4
|
362 |
_CharT * __eend = __wbuf + __len;
|
williamr@4
|
363 |
return copy((_CharT*)__wbuf, __eend, __stl_out);
|
williamr@4
|
364 |
}
|
williamr@4
|
365 |
|
williamr@4
|
366 |
#endif
|
williamr@4
|
367 |
template <class _Ch, class _InIt>
|
williamr@4
|
368 |
_InIt
|
williamr@4
|
369 |
time_get<_Ch, _InIt>::do_get_date(_InIt __s, _InIt __end,
|
williamr@4
|
370 |
ios_base& /* __str */, ios_base::iostate& __err,
|
williamr@4
|
371 |
tm* __t) const
|
williamr@4
|
372 |
{
|
williamr@4
|
373 |
typedef string::const_iterator string_iterator;
|
williamr@4
|
374 |
|
williamr@4
|
375 |
string_iterator __format
|
williamr@4
|
376 |
= _M_timeinfo._M_date_format.begin();
|
williamr@4
|
377 |
string_iterator __format_end
|
williamr@4
|
378 |
= _M_timeinfo._M_date_format.end();
|
williamr@4
|
379 |
|
williamr@4
|
380 |
string_iterator __result
|
williamr@4
|
381 |
= __get_formatted_time(__s, __end, __format, __format_end,
|
williamr@4
|
382 |
/* _Ch() ,*/ _M_timeinfo, __err, __t);
|
williamr@4
|
383 |
if (__result == __format_end)
|
williamr@4
|
384 |
__err = ios_base::goodbit;
|
williamr@4
|
385 |
else {
|
williamr@4
|
386 |
__err = ios_base::failbit;
|
williamr@4
|
387 |
if (__s == __end)
|
williamr@4
|
388 |
__err |= ios_base::eofbit;
|
williamr@4
|
389 |
}
|
williamr@4
|
390 |
return __s;
|
williamr@4
|
391 |
}
|
williamr@4
|
392 |
|
williamr@4
|
393 |
template <class _Ch, class _InIt>
|
williamr@4
|
394 |
_InIt
|
williamr@4
|
395 |
time_get<_Ch, _InIt>::do_get_time(_InIt __s, _InIt __end,
|
williamr@4
|
396 |
ios_base& /* __str */, ios_base::iostate& __err,
|
williamr@4
|
397 |
tm* __t) const
|
williamr@4
|
398 |
{
|
williamr@4
|
399 |
typedef string::const_iterator string_iterator;
|
williamr@4
|
400 |
string_iterator __format
|
williamr@4
|
401 |
= _M_timeinfo._M_time_format.begin();
|
williamr@4
|
402 |
string_iterator __format_end
|
williamr@4
|
403 |
= _M_timeinfo._M_time_format.end();
|
williamr@4
|
404 |
|
williamr@4
|
405 |
string_iterator __result
|
williamr@4
|
406 |
= __get_formatted_time(__s, __end, __format, __format_end,
|
williamr@4
|
407 |
/* _Ch() , */ _M_timeinfo, __err, __t);
|
williamr@4
|
408 |
__err = __result == __format_end ? ios_base::goodbit
|
williamr@4
|
409 |
: ios_base::failbit;
|
williamr@4
|
410 |
if (__s == __end)
|
williamr@4
|
411 |
__err |= ios_base::eofbit;
|
williamr@4
|
412 |
return __s;
|
williamr@4
|
413 |
}
|
williamr@4
|
414 |
|
williamr@4
|
415 |
template <class _Ch, class _InIt>
|
williamr@4
|
416 |
_InIt
|
williamr@4
|
417 |
time_get<_Ch, _InIt>::do_get_year(_InIt __s, _InIt __end,
|
williamr@4
|
418 |
ios_base&,
|
williamr@4
|
419 |
ios_base::iostate& __err,
|
williamr@4
|
420 |
tm* __t) const
|
williamr@4
|
421 |
{
|
williamr@4
|
422 |
|
williamr@4
|
423 |
if (__s == __end) {
|
williamr@4
|
424 |
__err = ios_base::failbit | ios_base::eofbit;
|
williamr@4
|
425 |
return __s;
|
williamr@4
|
426 |
}
|
williamr@4
|
427 |
|
williamr@4
|
428 |
bool __pr = __get_decimal_integer(__s, __end, __t->tm_year);
|
williamr@4
|
429 |
__t->tm_year -= 1900;
|
williamr@4
|
430 |
__err = __pr ? ios_base::goodbit : ios_base::failbit;
|
williamr@4
|
431 |
if (__s == __end)
|
williamr@4
|
432 |
__err |= ios_base::eofbit;
|
williamr@4
|
433 |
|
williamr@4
|
434 |
return __s;
|
williamr@4
|
435 |
}
|
williamr@4
|
436 |
|
williamr@4
|
437 |
template <class _Ch, class _InIt>
|
williamr@4
|
438 |
_InIt
|
williamr@4
|
439 |
time_get<_Ch, _InIt>::do_get_weekday(_InIt __s, _InIt __end,
|
williamr@4
|
440 |
ios_base& /* __str */,
|
williamr@4
|
441 |
ios_base::iostate& __err,
|
williamr@4
|
442 |
tm* __t) const
|
williamr@4
|
443 |
{
|
williamr@4
|
444 |
bool __result =
|
williamr@4
|
445 |
__get_short_or_long_dayname(__s, __end, _M_timeinfo, __t);
|
williamr@4
|
446 |
if (__result)
|
williamr@4
|
447 |
__err = ios_base::goodbit;
|
williamr@4
|
448 |
else {
|
williamr@4
|
449 |
__err = ios_base::failbit;
|
williamr@4
|
450 |
if (__s == __end)
|
williamr@4
|
451 |
__err |= ios_base::eofbit;
|
williamr@4
|
452 |
}
|
williamr@4
|
453 |
return __s;
|
williamr@4
|
454 |
}
|
williamr@4
|
455 |
|
williamr@4
|
456 |
template <class _Ch, class _InIt>
|
williamr@4
|
457 |
_InIt
|
williamr@4
|
458 |
time_get<_Ch, _InIt>::do_get_monthname(_InIt __s, _InIt __end,
|
williamr@4
|
459 |
ios_base& /* __str */,
|
williamr@4
|
460 |
ios_base::iostate& __err,
|
williamr@4
|
461 |
tm* __t) const
|
williamr@4
|
462 |
{
|
williamr@4
|
463 |
bool __result =
|
williamr@4
|
464 |
__get_short_or_long_monthname(__s, __end, _M_timeinfo, __t);
|
williamr@4
|
465 |
if (__result)
|
williamr@4
|
466 |
__err = ios_base::goodbit;
|
williamr@4
|
467 |
else {
|
williamr@4
|
468 |
__err = ios_base::failbit;
|
williamr@4
|
469 |
if (__s == __end)
|
williamr@4
|
470 |
__err |= ios_base::eofbit;
|
williamr@4
|
471 |
}
|
williamr@4
|
472 |
return __s;
|
williamr@4
|
473 |
}
|
williamr@4
|
474 |
|
williamr@4
|
475 |
template<class _Ch, class _OutputIter>
|
williamr@4
|
476 |
_OutputIter
|
williamr@4
|
477 |
time_put<_Ch,_OutputIter>::put(_OutputIter __s, ios_base& __f, _Ch __fill,
|
williamr@4
|
478 |
const tm* __tmb,
|
williamr@4
|
479 |
const _Ch* __pat, const _Ch* __pat_end) const
|
williamr@4
|
480 |
{
|
williamr@4
|
481 |
locale __loc = __f.getloc();
|
williamr@4
|
482 |
const ctype<_Ch>& _Ct = use_facet<ctype<_Ch> >(__loc);
|
williamr@4
|
483 |
// const ctype<_Ch>& _Ct = *(ctype<_Ch>*)__f._M_ctype_facet();
|
williamr@4
|
484 |
while (__pat != __pat_end) {
|
williamr@4
|
485 |
char __c = _Ct.narrow(*__pat, 0);
|
williamr@4
|
486 |
if (__c == '%') {
|
williamr@4
|
487 |
char __mod = 0;
|
williamr@4
|
488 |
++__pat;
|
williamr@4
|
489 |
__c = _Ct.narrow(*__pat++, 0);
|
williamr@4
|
490 |
if(__c == '#') { // MS extension
|
williamr@4
|
491 |
__mod = __c;
|
williamr@4
|
492 |
__c = _Ct.narrow(*__pat++, 0);
|
williamr@4
|
493 |
}
|
williamr@4
|
494 |
__s = do_put(__s, __f, __fill, __tmb, __c, __mod);
|
williamr@4
|
495 |
}
|
williamr@4
|
496 |
else
|
williamr@4
|
497 |
*__s++ = *__pat++;
|
williamr@4
|
498 |
}
|
williamr@4
|
499 |
return __s;
|
williamr@4
|
500 |
}
|
williamr@4
|
501 |
|
williamr@4
|
502 |
template<class _Ch, class _OutputIter>
|
williamr@4
|
503 |
_OutputIter
|
williamr@4
|
504 |
time_put<_Ch,_OutputIter>::do_put(_OutputIter __s, ios_base& __f, _Ch /* __fill */ ,
|
williamr@4
|
505 |
const tm* __tmb,
|
williamr@4
|
506 |
char __format, char __modifier ) const
|
williamr@4
|
507 |
{
|
williamr@4
|
508 |
char __buf[64];
|
williamr@4
|
509 |
char * __iend = __write_formatted_time(__buf, __format, __modifier,
|
williamr@4
|
510 |
_M_timeinfo, __tmb);
|
williamr@4
|
511 |
// locale __loc = __f.getloc();
|
williamr@4
|
512 |
return __put_time(__buf, __iend, __s, __f, _Ch());
|
williamr@4
|
513 |
}
|
williamr@4
|
514 |
|
williamr@4
|
515 |
_STLP_END_NAMESPACE
|
williamr@4
|
516 |
|
williamr@4
|
517 |
# endif /* defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) */
|
williamr@4
|
518 |
#endif /* _STLP_TIME_FACETS_C */
|
williamr@4
|
519 |
|
williamr@4
|
520 |
// Local Variables:
|
williamr@4
|
521 |
// mode:C++
|
williamr@4
|
522 |
// End:
|