ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_time_facets.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 // WARNING: This is an internal header file, included by other C++
00019 // standard library headers.  You should not attempt to use this header
00020 // file directly.
00021 
00022 
00023 #ifndef _STLP_INTERNAL_TIME_FACETS_H
00024 #define _STLP_INTERNAL_TIME_FACETS_H
00025 
00026 #ifndef _STLP_INTERNAL_CTIME
00027 #  include <stl/_ctime.h>                // Needed (for struct tm) by time facets
00028 #endif
00029 
00030 #ifndef _STLP_C_LOCALE_H
00031 #  include <stl/c_locale.h>
00032 #endif
00033 
00034 #ifndef _STLP_IOS_BASE_H
00035 #  include <stl/_ios_base.h>
00036 #endif
00037 
00038 #ifndef _STLP_INTERNAL_IOSTREAM_STRING_H
00039 #  include <stl/_iostream_string.h>
00040 #endif
00041 
00042 #ifndef _STLP_FACETS_FWD_H
00043 #  include <stl/_facets_fwd.h>
00044 #endif
00045 
00046 _STLP_BEGIN_NAMESPACE
00047 
00048 _STLP_MOVE_TO_PRIV_NAMESPACE
00049 
00050 // Template functions used by time_get
00051 
00052 /* Both time_get and time_put need a structure of type _Time_Info
00053  * to provide names and abbreviated names for months and days,
00054  * as well as the am/pm designator.  The month and weekday tables
00055  * have the all the abbreviated names before all the full names.
00056  * The _Time_Info tables are initialized using the non-template
00057  * time_base class, which has a default constructor and two protected.
00058  * The default one initialize _Time_Info with "C" time info. The
00059  * protected initialize _time_Info using a _Locale_time instance
00060  * or using a name( in fact the name is used to build a _Locale_time
00061  * instance that is then used for initialization). */
00062 
00063 class _STLP_CLASS_DECLSPEC _Time_Info_Base {
00064 public:
00065   string _M_time_format;
00066   string _M_date_format;
00067   string _M_date_time_format;
00068   string _M_long_date_format;
00069   string _M_long_date_time_format;
00070 };
00071 
00072 class _STLP_CLASS_DECLSPEC _Time_Info : public _Time_Info_Base {
00073 public:
00074   string _M_dayname[14];
00075   string _M_monthname[24];
00076   string _M_am_pm[2];
00077 };
00078 
00079 #ifndef _STLP_NO_WCHAR_T
00080 class _STLP_CLASS_DECLSPEC _WTime_Info : public _Time_Info_Base {
00081 public:
00082   wstring _M_dayname[14];
00083   wstring _M_monthname[24];
00084   wstring _M_am_pm[2];
00085 };
00086 #endif
00087 
00088 _STLP_MOVE_TO_STD_NAMESPACE
00089 
00090 class _STLP_CLASS_DECLSPEC time_base {
00091 public:
00092   enum dateorder {no_order, dmy, mdy, ymd, ydm};
00093 };
00094 
00095 _STLP_MOVE_TO_PRIV_NAMESPACE
00096 
00097 template <class _Ch>
00098 class time_init;
00099 
00100 _STLP_TEMPLATE_NULL
00101 class _STLP_CLASS_DECLSPEC time_init<char> {
00102 protected:
00103   time_init();
00104   time_init(const char *name);
00105   time_init(_Locale_time*);
00106 #if defined (__BORLANDC__)
00107   static
00108 #endif
00109   _Time_Info _M_timeinfo;
00110   time_base::dateorder _M_dateorder;
00111 };
00112 
00113 #ifndef _STLP_NO_WCHAR_T
00114 _STLP_TEMPLATE_NULL
00115 class _STLP_CLASS_DECLSPEC time_init<wchar_t> {
00116 protected:
00117   time_init();
00118   time_init(const char *name);
00119   time_init(_Locale_time*);
00120 #if defined (__BORLANDC__)
00121   static
00122 #endif
00123   _WTime_Info _M_timeinfo;
00124   time_base::dateorder _M_dateorder;
00125 };
00126 #endif
00127 
00128 _STLP_MOVE_TO_STD_NAMESPACE
00129 
00130 template <class _Ch, class _InIt>
00131 class time_get : public locale::facet, public time_base, public _STLP_PRIV time_init<_Ch> {
00132 public:
00133   typedef _Ch   char_type;
00134   typedef _InIt iter_type;
00135 
00136   explicit time_get(size_t __refs = 0) : locale::facet(__refs)
00137   {}
00138 
00139   dateorder date_order() const { return do_date_order(); }
00140   iter_type get_time(iter_type __s, iter_type  __end, ios_base&  __str,
00141                      ios_base::iostate&  __err, tm* __t) const
00142   { return do_get_time(__s,  __end,  __str,  __err, __t); }
00143   iter_type get_date(iter_type __s, iter_type  __end, ios_base&  __str,
00144                      ios_base::iostate&  __err, tm* __t) const
00145   { return do_get_date(__s,  __end,  __str,  __err, __t); }
00146   iter_type get_weekday(iter_type __s, iter_type  __end, ios_base&  __str,
00147                         ios_base::iostate&  __err, tm* __t) const
00148   { return do_get_weekday(__s,  __end,  __str,  __err, __t); }
00149   iter_type get_monthname(iter_type __s, iter_type  __end, ios_base&  __str,
00150                           ios_base::iostate&  __err, tm* __t) const
00151   { return do_get_monthname(__s,  __end,  __str,  __err, __t); }
00152   iter_type get_year(iter_type __s, iter_type  __end, ios_base&  __str,
00153                      ios_base::iostate&  __err, tm* __t) const
00154   { return do_get_year(__s,  __end,  __str,  __err, __t); }
00155 
00156   static locale::id id;
00157 
00158 protected:
00159   time_get(const char* __name, size_t __refs)
00160     : locale::facet(__refs), _STLP_PRIV time_init<_Ch>(__name)
00161   {}
00162   time_get(_Locale_time *__time)
00163     : _STLP_PRIV time_init<_Ch>(__time)
00164   {}
00165 
00166   ~time_get() {}
00167 
00168   virtual dateorder do_date_order() const { return this->_M_dateorder; }
00169 
00170   virtual iter_type do_get_time(iter_type __s, iter_type  __end,
00171                                 ios_base&, ios_base::iostate&  __err,
00172                                 tm* __t) const;
00173 
00174   virtual iter_type do_get_date(iter_type __s, iter_type  __end,
00175                                 ios_base&, ios_base::iostate& __err,
00176                                 tm* __t) const;
00177 
00178   virtual iter_type do_get_weekday(iter_type __s, iter_type  __end,
00179                                    ios_base&,
00180                                    ios_base::iostate& __err,
00181                                    tm* __t) const;
00182   virtual iter_type do_get_monthname(iter_type __s, iter_type  __end,
00183                                      ios_base&,
00184                                      ios_base::iostate& __err,
00185                                      tm* __t) const;
00186 
00187   virtual iter_type do_get_year(iter_type __s, iter_type  __end,
00188                                 ios_base&, ios_base::iostate& __err,
00189                                 tm* __t) const;
00190 };
00191 
00192 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
00193 template <class _Ch, class _InIt>
00194 #else
00195 template <class _Ch, class _InIt = istreambuf_iterator<_Ch, char_traits<_Ch> > >
00196 #endif
00197 class time_get_byname : public time_get<_Ch, _InIt> {
00198   friend class _Locale_impl;
00199 public:
00200   typedef  time_base::dateorder dateorder;
00201   typedef _InIt                 iter_type;
00202 
00203   explicit time_get_byname(const char* __name, size_t __refs = 0)
00204     : time_get<_Ch, _InIt>(__name, __refs) {}
00205 
00206 protected:
00207   ~time_get_byname() {}
00208   dateorder do_date_order() const { return this->_M_dateorder; }
00209 
00210 private:
00211   time_get_byname(_Locale_time *__time)
00212     : time_get<_Ch, _InIt>(__time)
00213   {}
00214 
00215   typedef time_get_byname<_Ch, _InIt> _Self;
00216   //explicitely defined as private to avoid warnings:
00217   time_get_byname(_Self const&);
00218   _Self& operator = (_Self const&);
00219 };
00220 
00221 // time_put facet
00222 
00223 // For the formats 'x, 'X', and 'c', do_put calls the first form of
00224 // put with the pattern obtained from _M_timeinfo._M_date_format or
00225 // _M_timeinfo._M_time_format.
00226 
00227 // Helper function:  __  takes a single-character
00228 // format.  As indicated by the foregoing remark, this will never be
00229 // 'x', 'X', or 'c'.
00230 
00231 _STLP_MOVE_TO_PRIV_NAMESPACE
00232 
00233 _STLP_DECLSPEC void _STLP_CALL
00234 __write_formatted_time(__iostring&, const ctype<char>& __ct,
00235                        char __format, char __modifier,
00236                        const _Time_Info& __table, const tm* __t);
00237 
00238 #ifndef _STLP_NO_WCHAR_T
00239 _STLP_DECLSPEC void _STLP_CALL
00240 __write_formatted_time(__iowstring&, const ctype<wchar_t>& __ct,
00241                        char __format, char __modifier,
00242                        const _WTime_Info& __table, const tm* __t);
00243 #endif
00244 
00245 _STLP_MOVE_TO_STD_NAMESPACE
00246 
00247 template <class _Ch, class _OutIt>
00248 class time_put : public locale::facet, public time_base, public _STLP_PRIV time_init<_Ch> {
00249 public:
00250   typedef _Ch      char_type;
00251   typedef _OutIt iter_type;
00252 
00253   explicit time_put(size_t __refs = 0) : locale::facet(__refs)
00254   {}
00255 
00256   _OutIt put(iter_type __s, ios_base& __f, _Ch __fill,
00257                   const tm* __tmb,
00258                   const _Ch* __pat, const _Ch* __pat_end) const;
00259 
00260   _OutIt put(iter_type __s, ios_base& __f, _Ch  __fill,
00261                   const tm* __tmb, char __format, char __modifier = 0) const
00262   { return do_put(__s, __f,  __fill, __tmb, __format, __modifier); }
00263 
00264   static locale::id id;
00265 
00266 protected:
00267   time_put(const char* __name, size_t __refs)
00268     : locale::facet(__refs), _STLP_PRIV time_init<_Ch>(__name)
00269   {}
00270   time_put(_Locale_time *__time)
00271     : _STLP_PRIV time_init<_Ch>(__time)
00272   {}
00273   ~time_put() {}
00274   virtual iter_type do_put(iter_type __s, ios_base& __f,
00275                            char_type  /* __fill */, const tm* __tmb,
00276                            char __format, char /* __modifier */) const;
00277 };
00278 
00279 #if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
00280 template <class _Ch, class _OutIt>
00281 #else
00282 template <class _Ch, class _OutIt = ostreambuf_iterator<_Ch, char_traits<_Ch> > >
00283 #endif
00284 class time_put_byname : public time_put<_Ch, _OutIt> {
00285   friend class _Locale_impl;
00286 public:
00287   typedef time_base::dateorder dateorder;
00288   typedef _OutIt iter_type;
00289   typedef _Ch   char_type;
00290 
00291   explicit time_put_byname(const char * __name, size_t __refs = 0)
00292     : time_put<_Ch, _OutIt>(__name, __refs)
00293   {}
00294 
00295 protected:
00296   ~time_put_byname() {}
00297 
00298 private:
00299   time_put_byname(_Locale_time *__time)
00300     : time_put<_Ch, _OutIt>(__time)
00301   {}
00302 
00303   typedef time_put_byname<_Ch, _OutIt> _Self;
00304   //explicitely defined as private to avoid warnings:
00305   time_put_byname(_Self const&);
00306   _Self& operator = (_Self const&);
00307 };
00308 
00309 #if defined (_STLP_USE_TEMPLATE_EXPORT)
00310 _STLP_EXPORT_TEMPLATE_CLASS time_get<char, istreambuf_iterator<char, char_traits<char> > >;
00311 _STLP_EXPORT_TEMPLATE_CLASS time_put<char, ostreambuf_iterator<char, char_traits<char> > >;
00312 #  if !defined (_STLP_NO_WCHAR_T)
00313 _STLP_EXPORT_TEMPLATE_CLASS time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00314 _STLP_EXPORT_TEMPLATE_CLASS time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
00315 #  endif
00316 
00317 #endif
00318 
00319 _STLP_END_NAMESPACE
00320 
00321 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
00322 #  include <stl/_time_facets.c>
00323 #endif
00324 
00325 #endif /* _STLP_INTERNAL_TIME_FACETS_H */
00326 
00327 // Local Variables:
00328 // mode:C++
00329 // End:

Generated on Sun May 27 2012 04:29:39 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.