ReactOS  0.4.14-dev-114-gc8cbd56
_time_facets.c File Reference
#include <stl/_time_facets.h>
#include <stl/_num_put.h>
#include <stl/_num_get.h>
Include dependency graph for _time_facets.c:

Go to the source code of this file.

Macros

#define _STLP_TIME_FACETS_C
 
#define _MAXNAMES   24
 

Functions

template<class _InIt , class _NameIt >
size_t _STLP_CALL __match (_InIt &__first, _InIt &__last, _NameIt __name, _NameIt __name_end)
 
template<class _InIt1 , class _Ch , class _TimeInfo >
string::const_iterator _STLP_CALL __get_formatted_time _STLP_WEAK (_InIt1 __first, _InIt1 __last, string::const_iterator __format, string::const_iterator __format_end, _Ch *, const _TimeInfo &__table, const ios_base &__s, ios_base::iostate &__err, tm *__t)
 
template<class _InIt , class _TimeInfo >
bool _STLP_CALL __get_short_or_long_dayname (_InIt &__first, _InIt &__last, const _TimeInfo &__table, tm *__t)
 
template<class _InIt , class _TimeInfo >
bool _STLP_CALL __get_short_or_long_monthname (_InIt &__first, _InIt &__last, const _TimeInfo &__table, tm *__t)
 

Macro Definition Documentation

◆ _MAXNAMES

#define _MAXNAMES   24

Definition at line 74 of file _time_facets.c.

◆ _STLP_TIME_FACETS_C

#define _STLP_TIME_FACETS_C

Definition at line 19 of file _time_facets.c.

Function Documentation

◆ __get_short_or_long_dayname()

template<class _InIt , class _TimeInfo >
bool _STLP_CALL __get_short_or_long_dayname ( _InIt &  __first,
_InIt &  __last,
const _TimeInfo &  __table,
tm __t 
)

Definition at line 281 of file _time_facets.c.

281  {
282  size_t __index = __match(__first, __last, __table._M_dayname + 0, __table._M_dayname + 14);
283  if (__index != 14) {
284  __t->tm_wday = __STATIC_CAST(int, __index % 7);
285  return true;
286  }
287  return false;
288 }
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
size_t _STLP_CALL __match(_InIt &__first, _InIt &__last, _NameIt __name, _NameIt __name_end)
Definition: _time_facets.c:78
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
int tm_wday
Definition: time.h:83

Referenced by time_get< _Ch, _InIt >::do_get_weekday().

◆ __get_short_or_long_monthname()

template<class _InIt , class _TimeInfo >
bool _STLP_CALL __get_short_or_long_monthname ( _InIt &  __first,
_InIt &  __last,
const _TimeInfo &  __table,
tm __t 
)

Definition at line 292 of file _time_facets.c.

292  {
293  size_t __index = __match(__first, __last, __table._M_monthname + 0, __table._M_monthname + 24);
294  if (__index != 24) {
295  __t->tm_mon = __STATIC_CAST(int, __index % 12);
296  return true;
297  }
298  return false;
299 }
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
size_t _STLP_CALL __match(_InIt &__first, _InIt &__last, _NameIt __name, _NameIt __name_end)
Definition: _time_facets.c:78
int tm_mon
Definition: time.h:81
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68

Referenced by time_get< _Ch, _InIt >::do_get_monthname().

◆ __match()

template<class _InIt , class _NameIt >
size_t _STLP_CALL __match ( _InIt &  __first,
_InIt &  __last,
_NameIt  __name,
_NameIt  __name_end 
)

Definition at line 78 of file _time_facets.c.

78  {
79  typedef ptrdiff_t difference_type;
80  difference_type __n = __name_end - __name;
81  difference_type __i, __start = 0;
82  size_t __pos = 0;
83  difference_type __check_count = __n;
84  bool __do_not_check[_MAXNAMES];
85  size_t __matching_name_index = __n;
86 
87  memset(__do_not_check, 0, sizeof(__do_not_check));
88 
89  while (__first != __last) {
90  difference_type __new_n = __n;
91  for (__i = __start; __i < __n; ++__i) {
92  if (!__do_not_check[__i]) {
93  if (*__first == __name[__i][__pos]) {
94  if (__pos == (__name[__i].size() - 1)) {
95  __matching_name_index = __i;
96  __do_not_check[__i] = true;
97  if (__i == __start) ++__start;
98  --__check_count;
99  if (__check_count == 0) {
100  ++__first;
101  return __matching_name_index;
102  }
103  }
104  __new_n = __i + 1;
105  }
106  else {
107  __do_not_check[__i] = true;
108  if (__i == __start) ++__start;
109  --__check_count;
110  if (__check_count == 0)
111  return __matching_name_index;
112  }
113  }
114  else {
115  if (__i == __start) ++ __start;
116  }
117  }
118 
119  __n = __new_n;
120  ++__first; ++__pos;
121  }
122 
123  return __matching_name_index;
124 }
return __n
Definition: _algo.h:75
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
GLsizeiptr size
Definition: glext.h:5919
#define _MAXNAMES
Definition: _time_facets.c:74
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define memset(x, y, z)
Definition: compat.h:39

Referenced by __get_short_or_long_dayname(), __get_short_or_long_monthname(), and _STLP_WEAK().

◆ _STLP_WEAK()

template<class _InIt1 , class _Ch , class _TimeInfo >
string::const_iterator _STLP_CALL __get_formatted_time _STLP_WEAK ( _InIt1  __first,
_InIt1  __last,
string::const_iterator  __format,
string::const_iterator  __format_end,
_Ch ,
const _TimeInfo &  __table,
const ios_base __s,
ios_base::iostate __err,
tm __t 
)

Definition at line 149 of file _time_facets.c.

152  {
153  const ctype<_Ch>& __ct = use_facet<ctype<_Ch> >(__s.getloc());
154  typedef basic_string<_Ch, char_traits<_Ch>, allocator<_Ch> > string_type;
155  size_t offset;
156 
157  while (__first != __last && __format != __format_end) {
158  offset = 0;
159  if (*__format == '%') {
160  ++__format;
161  char __c = *__format;
162  if (__c == '#') { //MS extension
163  ++__format;
164  __c = *__format;
165  }
166 
167  switch (__c) {
168  case 'A':
169  offset = 7;
170  case 'a': {
171  size_t __index = __match(__first, __last,
172  __table._M_dayname + offset, __table._M_dayname + offset + 7);
173  if (__index == 7)
174  return __format;
175  __t->tm_wday = __STATIC_CAST(int, __index);
176  break;
177  }
178 
179  case 'B':
180  offset = 12;
181  case 'b': {
182  size_t __index = __match(__first, __last,
183  __table._M_monthname + offset, __table._M_monthname + offset + 12);
184  if (__index == 12)
185  return __format;
186  __t->tm_mon = __STATIC_CAST(int, __index);
187  break;
188  }
189 
190  case 'd': {
191  bool __pr = __get_decimal_integer(__first, __last, __t->tm_mday, __STATIC_CAST(_Ch*, 0));
192  if (!__pr || __t->tm_mday < 1 || __t->tm_mday > 31) {
193  __err |= ios_base::failbit;
194  return __format;
195  }
196  break;
197  }
198 
199  case 'H': case 'I': {
200  bool __pr = __get_decimal_integer(__first, __last, __t->tm_hour, __STATIC_CAST(_Ch*, 0));
201  if (!__pr)
202  return __format;
203  break;
204  }
205 
206  case 'j': {
207  bool __pr = __get_decimal_integer(__first, __last, __t->tm_yday, __STATIC_CAST(_Ch*, 0));
208  if (!__pr)
209  return __format;
210  break;
211  }
212 
213  case 'm': {
214  bool __pr = __get_decimal_integer(__first, __last, __t->tm_mon, __STATIC_CAST(_Ch*, 0));
215  --__t->tm_mon;
216  if (!__pr || __t->tm_mon < 0 || __t->tm_mon > 11) {
217  __err |= ios_base::failbit;
218  return __format;
219  }
220  break;
221  }
222 
223  case 'M': {
224  bool __pr = __get_decimal_integer(__first, __last, __t->tm_min, __STATIC_CAST(_Ch*, 0));
225  if (!__pr)
226  return __format;
227  break;
228  }
229 
230  case 'p': {
231  size_t __index = __match(__first, __last,
232  __table._M_am_pm + 0, __table._M_am_pm + 2);
233  if (__index == 2)
234  return __format;
235  // 12:00 PM <=> 12:00, 12:00 AM <=> 00:00
236  if (__index == 1 && __t->tm_hour != 12 )
237  __t->tm_hour += 12;
238  if (__index == 0 && __t->tm_hour == 12 )
239  __t->tm_hour = 0;
240  break;
241  }
242 
243  case 'S': {
244  bool __pr = __get_decimal_integer(__first, __last, __t->tm_sec, __STATIC_CAST(_Ch*, 0));
245  if (!__pr)
246  return __format;
247  break;
248  }
249 
250  case 'y': {
251  bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0));
252  if (!__pr)
253  return __format;
254  break;
255  }
256 
257  case 'Y': {
258  bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0));
259  __t->tm_year -= 1900;
260  if (!__pr)
261  return __format;
262  break;
263  }
264 
265  default:
266  break;
267  }
268  }
269  else {
270  if (*__first++ != __ct.widen(*__format)) break;
271  }
272 
273  ++__format;
274  }
275 
276  return __format;
277 }
int tm_min
Definition: time.h:78
_Check_return_ wchar_t _Ch
Definition: string.h:647
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
int tm_mday
Definition: time.h:80
GLintptr offset
Definition: glext.h:5920
locale getloc() const
Definition: _ios_base.h:143
size_t _STLP_CALL __match(_InIt &__first, _InIt &__last, _NameIt __name, _NameIt __name_end)
Definition: _time_facets.c:78
int tm_year
Definition: time.h:82
#define __c
Definition: schilyio.h:209
int tm_mon
Definition: time.h:81
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
Definition: _ctype.h:58
bool _STLP_CALL __get_decimal_integer(_InputIter &__first, _InputIter &__last, _Integer &__val, _CharT *)
Definition: _num_get.c:239
int tm_wday
Definition: time.h:83
int tm_yday
Definition: time.h:84
int tm_sec
Definition: time.h:77
int tm_hour
Definition: time.h:79