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