ReactOS  0.4.13-dev-544-gede3fdd
_time_facets.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999
3  * Silicon Graphics Computer Systems, Inc.
4  *
5  * Copyright (c) 1999
6  * Boris Fomitchev
7  *
8  * This material is provided "as is", with absolutely no warranty expressed
9  * or implied. Any use is at your own risk.
10  *
11  * Permission to use or copy this software for any purpose is hereby granted
12  * without fee, provided the above notices are retained on all copies.
13  * Permission to modify the code and to distribute modified code is granted,
14  * provided the above notices are retained, and a notice that the code was
15  * modified is included with the above copyright notice.
16  *
17  */
18 // WARNING: This is an internal header file, included by other C++
19 // standard library headers. You should not attempt to use this header
20 // file directly.
21 
22 
23 #ifndef _STLP_INTERNAL_TIME_FACETS_H
24 #define _STLP_INTERNAL_TIME_FACETS_H
25 
26 #ifndef _STLP_INTERNAL_CTIME
27 # include <stl/_ctime.h> // Needed (for struct tm) by time facets
28 #endif
29 
30 #ifndef _STLP_C_LOCALE_H
31 # include <stl/c_locale.h>
32 #endif
33 
34 #ifndef _STLP_IOS_BASE_H
35 # include <stl/_ios_base.h>
36 #endif
37 
38 #ifndef _STLP_INTERNAL_IOSTREAM_STRING_H
39 # include <stl/_iostream_string.h>
40 #endif
41 
42 #ifndef _STLP_FACETS_FWD_H
43 # include <stl/_facets_fwd.h>
44 #endif
45 
47 
49 
50 // Template functions used by time_get
51 
52 /* Both time_get and time_put need a structure of type _Time_Info
53  * to provide names and abbreviated names for months and days,
54  * as well as the am/pm designator. The month and weekday tables
55  * have the all the abbreviated names before all the full names.
56  * The _Time_Info tables are initialized using the non-template
57  * time_base class, which has a default constructor and two protected.
58  * The default one initialize _Time_Info with "C" time info. The
59  * protected initialize _time_Info using a _Locale_time instance
60  * or using a name( in fact the name is used to build a _Locale_time
61  * instance that is then used for initialization). */
62 
64 public:
70 };
71 
73 public:
74  string _M_dayname[14];
75  string _M_monthname[24];
76  string _M_am_pm[2];
77 };
78 
79 #ifndef _STLP_NO_WCHAR_T
81 public:
82  wstring _M_dayname[14];
83  wstring _M_monthname[24];
84  wstring _M_am_pm[2];
85 };
86 #endif
87 
89 
91 public:
92  enum dateorder {no_order, dmy, mdy, ymd, ydm};
93 };
94 
96 
97 template <class _Ch>
98 class time_init;
99 
102 protected:
103  time_init();
104  time_init(const char *name);
106 #if defined (__BORLANDC__)
107  static
108 #endif
111 };
112 
113 #ifndef _STLP_NO_WCHAR_T
116 protected:
117  time_init();
118  time_init(const char *name);
120 #if defined (__BORLANDC__)
121  static
122 #endif
125 };
126 #endif
127 
129 
130 template <class _Ch, class _InIt>
131 class time_get : public locale::facet, public time_base, public _STLP_PRIV time_init<_Ch> {
132 public:
133  typedef _Ch char_type;
134  typedef _InIt iter_type;
135 
136  explicit time_get(size_t __refs = 0) : locale::facet(__refs)
137  {}
138 
139  dateorder date_order() const { return do_date_order(); }
141  ios_base::iostate& __err, tm* __t) const
142  { return do_get_time(__s, __end, __str, __err, __t); }
144  ios_base::iostate& __err, tm* __t) const
145  { return do_get_date(__s, __end, __str, __err, __t); }
147  ios_base::iostate& __err, tm* __t) const
148  { return do_get_weekday(__s, __end, __str, __err, __t); }
150  ios_base::iostate& __err, tm* __t) const
151  { return do_get_monthname(__s, __end, __str, __err, __t); }
153  ios_base::iostate& __err, tm* __t) const
154  { return do_get_year(__s, __end, __str, __err, __t); }
155 
156  static locale::id id;
157 
158 protected:
159  time_get(const char* __name, size_t __refs)
160  : locale::facet(__refs), _STLP_PRIV time_init<_Ch>(__name)
161  {}
163  : _STLP_PRIV time_init<_Ch>(__time)
164  {}
165 
167 
168  virtual dateorder do_date_order() const { return this->_M_dateorder; }
169 
170  virtual iter_type do_get_time(iter_type __s, iter_type __end,
171  ios_base&, ios_base::iostate& __err,
172  tm* __t) const;
173 
174  virtual iter_type do_get_date(iter_type __s, iter_type __end,
175  ios_base&, ios_base::iostate& __err,
176  tm* __t) const;
177 
178  virtual iter_type do_get_weekday(iter_type __s, iter_type __end,
179  ios_base&,
180  ios_base::iostate& __err,
181  tm* __t) const;
182  virtual iter_type do_get_monthname(iter_type __s, iter_type __end,
183  ios_base&,
184  ios_base::iostate& __err,
185  tm* __t) const;
186 
187  virtual iter_type do_get_year(iter_type __s, iter_type __end,
188  ios_base&, ios_base::iostate& __err,
189  tm* __t) const;
190 };
191 
192 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
193 template <class _Ch, class _InIt>
194 #else
195 template <class _Ch, class _InIt = istreambuf_iterator<_Ch, char_traits<_Ch> > >
196 #endif
197 class time_get_byname : public time_get<_Ch, _InIt> {
198  friend class _Locale_impl;
199 public:
201  typedef _InIt iter_type;
202 
203  explicit time_get_byname(const char* __name, size_t __refs = 0)
204  : time_get<_Ch, _InIt>(__name, __refs) {}
205 
206 protected:
208  dateorder do_date_order() const { return this->_M_dateorder; }
209 
210 private:
212  : time_get<_Ch, _InIt>(__time)
213  {}
214 
216  //explicitely defined as private to avoid warnings:
217  time_get_byname(_Self const&);
218  _Self& operator = (_Self const&);
219 };
220 
221 // time_put facet
222 
223 // For the formats 'x, 'X', and 'c', do_put calls the first form of
224 // put with the pattern obtained from _M_timeinfo._M_date_format or
225 // _M_timeinfo._M_time_format.
226 
227 // Helper function: __ takes a single-character
228 // format. As indicated by the foregoing remark, this will never be
229 // 'x', 'X', or 'c'.
230 
232 
235  char __format, char __modifier,
236  const _Time_Info& __table, const tm* __t);
237 
238 #ifndef _STLP_NO_WCHAR_T
241  char __format, char __modifier,
242  const _WTime_Info& __table, const tm* __t);
243 #endif
244 
246 
247 template <class _Ch, class _OutIt>
248 class time_put : public locale::facet, public time_base, public _STLP_PRIV time_init<_Ch> {
249 public:
250  typedef _Ch char_type;
251  typedef _OutIt iter_type;
252 
253  explicit time_put(size_t __refs = 0) : locale::facet(__refs)
254  {}
255 
256  _OutIt put(iter_type __s, ios_base& __f, _Ch __fill,
257  const tm* __tmb,
258  const _Ch* __pat, const _Ch* __pat_end) const;
259 
260  _OutIt put(iter_type __s, ios_base& __f, _Ch __fill,
261  const tm* __tmb, char __format, char __modifier = 0) const
262  { return do_put(__s, __f, __fill, __tmb, __format, __modifier); }
263 
264  static locale::id id;
265 
266 protected:
267  time_put(const char* __name, size_t __refs)
268  : locale::facet(__refs), _STLP_PRIV time_init<_Ch>(__name)
269  {}
271  : _STLP_PRIV time_init<_Ch>(__time)
272  {}
274  virtual iter_type do_put(iter_type __s, ios_base& __f,
275  char_type /* __fill */, const tm* __tmb,
276  char __format, char /* __modifier */) const;
277 };
278 
279 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
280 template <class _Ch, class _OutIt>
281 #else
282 template <class _Ch, class _OutIt = ostreambuf_iterator<_Ch, char_traits<_Ch> > >
283 #endif
284 class time_put_byname : public time_put<_Ch, _OutIt> {
285  friend class _Locale_impl;
286 public:
288  typedef _OutIt iter_type;
289  typedef _Ch char_type;
290 
291  explicit time_put_byname(const char * __name, size_t __refs = 0)
292  : time_put<_Ch, _OutIt>(__name, __refs)
293  {}
294 
295 protected:
297 
298 private:
300  : time_put<_Ch, _OutIt>(__time)
301  {}
302 
304  //explicitely defined as private to avoid warnings:
305  time_put_byname(_Self const&);
306  _Self& operator = (_Self const&);
307 };
308 
309 #if defined (_STLP_USE_TEMPLATE_EXPORT)
312 # if !defined (_STLP_NO_WCHAR_T)
315 # endif
316 
317 #endif
318 
320 
321 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
322 # include <stl/_time_facets.c>
323 #endif
324 
325 #endif /* _STLP_INTERNAL_TIME_FACETS_H */
326 
327 // Local Variables:
328 // mode:C++
329 // End:
_Check_return_ wchar_t _Ch
Definition: string.h:647
time_base::dateorder _M_dateorder
Definition: _time_facets.h:124
_OutIt iter_type
Definition: _time_facets.h:251
string _M_time_format
Definition: _time_facets.h:65
_OutIt put(iter_type __s, ios_base &__f, _Ch __fill, const tm *__tmb, const _Ch *__pat, const _Ch *__pat_end) const
_InIt iter_type
Definition: _time_facets.h:134
_Ch char_type
Definition: _time_facets.h:133
virtual iter_type do_get_year(iter_type __s, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.c:349
_Self & operator=(_Self const &)
string _M_date_time_format
Definition: _time_facets.h:67
time_put_byname< _Ch, _OutIt > _Self
Definition: _time_facets.h:303
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
time_put(size_t __refs=0)
Definition: _time_facets.h:253
virtual iter_type do_get_monthname(iter_type __s, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.c:385
Definition: _locale.h:75
static locale::id id
Definition: _time_facets.h:264
static locale::id id
Definition: _time_facets.h:156
time_put_byname(_Locale_time *__time)
Definition: _time_facets.h:299
unsigned char
Definition: typeof.h:29
string _M_date_format
Definition: _time_facets.h:66
time_get(size_t __refs=0)
Definition: _time_facets.h:136
unsigned short wchar_t
Definition: crtdefs.h:324
_Self & operator=(_Self const &)
time_get(const char *__name, size_t __refs)
Definition: _time_facets.h:159
virtual iter_type do_get_time(iter_type __s, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.c:329
iter_type get_year(iter_type __s, iter_type __end, ios_base &__str, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.h:152
time_put(_Locale_time *__time)
Definition: _time_facets.h:270
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_DECLSPEC void _STLP_CALL __write_formatted_time(__iostring &, const ctype< char > &__ct, char __format, char __modifier, const _Time_Info &__table, const tm *__t)
time_get_byname(const char *__name, size_t __refs=0)
Definition: _time_facets.h:203
_Time_Info _M_timeinfo
Definition: _time_facets.h:109
#define _STLP_EXPORT_TEMPLATE_CLASS
Definition: features.h:987
int iostate
Definition: _ios_base.h:58
virtual iter_type do_put(iter_type __s, ios_base &__f, char_type, const tm *__tmb, char __format, char) const
Definition: _time_facets.c:426
facet(size_t __init_count=0)
Definition: _locale.h:84
_Ch char_type
Definition: _time_facets.h:250
dateorder date_order() const
Definition: _time_facets.h:139
iter_type get_time(iter_type __s, iter_type __end, ios_base &__str, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.h:140
#define _STLP_PRIV
Definition: _dm.h:70
#define _STLP_DECLSPEC
Definition: features.h:982
dateorder do_date_order() const
Definition: _time_facets.h:208
Definition: time.h:76
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
time_put(const char *__name, size_t __refs)
Definition: _time_facets.h:267
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
_OutIt put(iter_type __s, ios_base &__f, _Ch __fill, const tm *__tmb, char __format, char __modifier=0) const
Definition: _time_facets.h:260
time_base::dateorder dateorder
Definition: _time_facets.h:200
_WTime_Info _M_timeinfo
Definition: _time_facets.h:123
virtual iter_type do_get_date(iter_type __s, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.c:305
#define _STLP_END_NAMESPACE
Definition: features.h:503
string _M_long_date_time_format
Definition: _time_facets.h:69
time_base::dateorder dateorder
Definition: _time_facets.h:287
virtual iter_type do_get_weekday(iter_type __s, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.c:368
virtual dateorder do_date_order() const
Definition: _time_facets.h:168
Definition: name.c:36
string _M_long_date_format
Definition: _time_facets.h:68
iter_type get_date(iter_type __s, iter_type __end, ios_base &__str, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.h:143
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
time_base::dateorder _M_dateorder
Definition: _time_facets.h:110
time_get_byname(_Locale_time *__time)
Definition: _time_facets.h:211
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
time_put_byname(const char *__name, size_t __refs=0)
Definition: _time_facets.h:291
time_get_byname< _Ch, _InIt > _Self
Definition: _time_facets.h:215
#define _STLP_CALL
Definition: _bc.h:131
iter_type get_monthname(iter_type __s, iter_type __end, ios_base &__str, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.h:149
time_get(_Locale_time *__time)
Definition: _time_facets.h:162
iter_type get_weekday(iter_type __s, iter_type __end, ios_base &__str, ios_base::iostate &__err, tm *__t) const
Definition: _time_facets.h:146