00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _STLP_INTERNAL_TIME_FACETS_H
00024 #define _STLP_INTERNAL_TIME_FACETS_H
00025
00026 #ifndef _STLP_CTIME
00027 # include <ctime>
00028 #endif
00029
00030 #include <stl/c_locale.h>
00031 #include <stl/_ios_base.h>
00032
00033 _STLP_BEGIN_NAMESPACE
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #define _MAXNAMES 64
00065 #define _MAX_NAME_LENGTH 64
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 class _STLP_CLASS_DECLSPEC _Time_Info {
00080 public:
00081 string _M_dayname[14];
00082 string _M_monthname[24];
00083 string _M_am_pm[2];
00084 string _M_time_format;
00085 string _M_date_format;
00086 string _M_date_time_format;
00087 string _M_long_date_format;
00088 string _M_long_date_time_format;
00089 };
00090
00091 void _STLP_CALL _Init_timeinfo(_Time_Info&);
00092 void _STLP_CALL _Init_timeinfo(_Time_Info&, _Locale_time*);
00093
00094 class _STLP_CLASS_DECLSPEC time_base {
00095 public:
00096 enum dateorder {no_order, dmy, mdy, ymd, ydm};
00097 };
00098
00099
00100 template <class _Ch, __DFL_TMPL_PARAM( _InIt , istreambuf_iterator<_Ch>) >
00101 class time_get : public locale::facet, public time_base
00102 {
00103 friend class _Locale;
00104
00105 public:
00106 typedef _Ch char_type;
00107 typedef _InIt iter_type;
00108
00109 explicit time_get(size_t __refs = 0) : _BaseFacet(__refs) {
00110 _Init_timeinfo(_M_timeinfo);
00111 }
00112 dateorder date_order() const { return do_date_order(); }
00113 iter_type get_time(iter_type __s, iter_type __end, ios_base& __str,
00114 ios_base::iostate& __err, tm* __t) const
00115 { return do_get_time(__s, __end, __str, __err, __t); }
00116 iter_type get_date(iter_type __s, iter_type __end, ios_base& __str,
00117 ios_base::iostate& __err, tm* __t) const
00118 { return do_get_date(__s, __end, __str, __err, __t); }
00119 iter_type get_weekday(iter_type __s, iter_type __end, ios_base& __str,
00120 ios_base::iostate& __err, tm* __t) const
00121 { return do_get_weekday(__s, __end, __str, __err, __t); }
00122 iter_type get_monthname(iter_type __s, iter_type __end, ios_base& __str,
00123 ios_base::iostate& __err, tm* __t) const
00124 { return do_get_monthname(__s, __end, __str, __err, __t); }
00125 iter_type get_year(iter_type __s, iter_type __end, ios_base& __str,
00126 ios_base::iostate& __err, tm* __t) const
00127 { return do_get_year(__s, __end, __str, __err, __t); }
00128
00129 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00130
00131 protected:
00132 _Time_Info _M_timeinfo;
00133
00134 time_get(_Locale_time *, size_t __refs) : _BaseFacet(__refs) {}
00135
00136 ~time_get() {}
00137
00138 virtual dateorder do_date_order() const {return no_order;}
00139
00140 virtual iter_type do_get_time(iter_type __s, iter_type __end,
00141 ios_base&, ios_base::iostate& __err,
00142 tm* __t) const;
00143
00144 virtual iter_type do_get_date(iter_type __s, iter_type __end,
00145 ios_base&, ios_base::iostate& __err,
00146 tm* __t) const;
00147
00148 virtual iter_type do_get_weekday(iter_type __s, iter_type __end,
00149 ios_base&,
00150 ios_base::iostate& __err,
00151 tm* __t) const;
00152 virtual iter_type do_get_monthname(iter_type __s, iter_type __end,
00153 ios_base&,
00154 ios_base::iostate& __err,
00155 tm* __t) const;
00156
00157 virtual iter_type do_get_year(iter_type __s, iter_type __end,
00158 ios_base&, ios_base::iostate& __err,
00159 tm* __t) const;
00160 };
00161
00162 time_base::dateorder _STLP_CALL
00163 __get_date_order(_Locale_time*);
00164 _Locale_time* _STLP_CALL __acquire_time(const char* __name);
00165 void _STLP_CALL __release_time(_Locale_time* __time);
00166
00167 template <class _Ch, __DFL_TMPL_PARAM( _InIt , istreambuf_iterator<_Ch>) >
00168 class time_get_byname : public time_get<_Ch, _InIt>
00169 {
00170 public:
00171 typedef time_base::dateorder dateorder;
00172 typedef _InIt iter_type;
00173
00174 explicit time_get_byname(const char* __name, size_t __refs = 0)
00175 : time_get<_Ch, _InIt>((_Locale_time*) 0, __refs),
00176 _M_time(__acquire_time(__name))
00177 { _Init_timeinfo(this->_M_timeinfo, this->_M_time); }
00178
00179 protected:
00180 ~time_get_byname() { __release_time(_M_time); }
00181 dateorder do_date_order() const { return __get_date_order(_M_time); }
00182 private:
00183 _Locale_time* _M_time;
00184 };
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 char * _STLP_CALL
00197 __write_formatted_time(char * __buf, char __format, char __modifier,
00198 const _Time_Info& __table, const tm* __t);
00199
00200 template <class _OuIt>
00201 inline _OuIt _STLP_CALL __put_time(char * __first, char * __last, _OuIt __out,
00202 const ios_base& , char) {
00203 return copy(__first, __last, __out);
00204 }
00205
00206 # ifndef _STLP_NO_WCHAR_T
00207 template <class _OuIt>
00208 _OuIt _STLP_CALL __put_time(char * __first, char * __last, _OuIt __out,
00209 const ios_base& __s, wchar_t);
00210 # endif
00211
00212 template<class _Ch, __DFL_TMPL_PARAM( _OutputIter , ostreambuf_iterator<_Ch> ) >
00213 class time_put : public locale::facet, public time_base
00214 {
00215 friend class _Locale;
00216 public:
00217 typedef _Ch char_type;
00218 typedef _OutputIter iter_type;
00219
00220 explicit time_put(size_t __refs = 0) : _BaseFacet(__refs) {
00221 _Init_timeinfo(_M_timeinfo);
00222 }
00223
00224 _OutputIter put(iter_type __s, ios_base& __f, _Ch __fill,
00225 const tm* __tmb,
00226 const _Ch* __pat, const _Ch* __pat_end) const;
00227
00228 _OutputIter put(iter_type __s, ios_base& __f, _Ch __fill,
00229 const tm* __tmb, char __format, char __modifier = 0) const {
00230 return do_put(__s, __f, __fill, __tmb, __format, __modifier);
00231 }
00232
00233 _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00234
00235 protected:
00236 _Time_Info _M_timeinfo;
00237
00238 time_put(_Locale_time* , size_t __refs) : _BaseFacet(__refs) {
00239
00240 }
00241
00242 ~time_put() {}
00243 virtual iter_type do_put(iter_type __s, ios_base& __f,
00244 char_type , const tm* __tmb,
00245 char __format, char ) const;
00246 };
00247
00248 template <class _Ch, __DFL_TMPL_PARAM( _InIt , ostreambuf_iterator<_Ch> ) >
00249 class time_put_byname : public time_put<_Ch, _InIt>
00250 {
00251 friend class _Locale;
00252 public:
00253 typedef time_base::dateorder dateorder;
00254 typedef _InIt iter_type;
00255 typedef _Ch char_type;
00256
00257 explicit time_put_byname(const char * __name, size_t __refs = 0)
00258 : time_put<_Ch, _InIt>((_Locale_time*) 0, __refs),
00259 _M_time(__acquire_time(__name))
00260 { _Init_timeinfo(this->_M_timeinfo, this->_M_time); }
00261
00262 protected:
00263 ~time_put_byname() { __release_time(_M_time); }
00264
00265 private:
00266 _Locale_time* _M_time;
00267 };
00268
00269 # ifdef _STLP_USE_TEMPLATE_EXPORT
00270 _STLP_EXPORT_TEMPLATE_CLASS time_get<char, istreambuf_iterator<char, char_traits<char> > >;
00271 _STLP_EXPORT_TEMPLATE_CLASS time_put<char, ostreambuf_iterator<char, char_traits<char> > >;
00272
00273
00274 # ifndef _STLP_NO_WCHAR_T
00275 _STLP_EXPORT_TEMPLATE_CLASS time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00276 _STLP_EXPORT_TEMPLATE_CLASS time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00277
00278
00279 # endif
00280
00281 # endif
00282
00283 # if defined (__BORLANDC__) && defined (_RTLDLL)
00284 inline void _Stl_loc_init_time_facets() {
00285
00286 time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 16;
00287 time_get<char, const char*>::id._M_index = 17;
00288 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 18;
00289 time_put<char, char*>::id._M_index = 19;
00290
00291 # ifndef _STLP_NO_WCHAR_T
00292
00293 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 35;
00294 time_get<wchar_t, const wchar_t*>::id._M_index = 36;
00295 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 37;
00296 time_put<wchar_t, wchar_t*>::id._M_index = 38;
00297
00298 # endif
00299
00300 }
00301 # endif
00302
00303 _STLP_END_NAMESPACE
00304
00305 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
00306 # include <stl/_time_facets.c>
00307 # endif
00308
00309 #endif
00310
00311
00312
00313
00314
00315