epoc32/include/stdapis/stlport/stl/_fstream.c
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
 * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
williamr@2
     3
 *
williamr@2
     4
 * Copyright (c) 1996,1997
williamr@2
     5
 * Silicon Graphics Computer Systems, Inc.
williamr@2
     6
 *
williamr@2
     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@2
    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@2
    19
 */
williamr@2
    20
#ifndef _STLP_FSTREAM_C
williamr@2
    21
#define _STLP_FSTREAM_C
williamr@2
    22
williamr@2
    23
# ifndef _STLP_INTERNAL_FSTREAM_H
williamr@2
    24
#  include <stl/_fstream.h>
williamr@2
    25
# endif
williamr@2
    26
williamr@2
    27
# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
williamr@2
    28
williamr@2
    29
_STLP_BEGIN_NAMESPACE
williamr@2
    30
williamr@2
    31
# if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
williamr@2
    32
// no wchar_t is supported for this mode
williamr@2
    33
# define __BF_int_type__ int
williamr@2
    34
# define __BF_pos_type__ streampos
williamr@2
    35
# define __BF_off_type__ streamoff
williamr@2
    36
# else
williamr@2
    37
# define __BF_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::int_type
williamr@2
    38
# define __BF_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::pos_type
williamr@2
    39
# define __BF_off_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::off_type
williamr@2
    40
# endif
williamr@2
    41
williamr@2
    42
williamr@2
    43
//----------------------------------------------------------------------
williamr@2
    44
// Public basic_filebuf<> member functions
williamr@2
    45
williamr@2
    46
template <class _CharT, class _Traits>
williamr@2
    47
basic_filebuf<_CharT, _Traits>::basic_filebuf()
williamr@2
    48
     :  basic_streambuf<_CharT, _Traits>(), _M_base(),
williamr@2
    49
    _M_constant_width(false), _M_always_noconv(false),
williamr@2
    50
    _M_int_buf_dynamic(false),
williamr@2
    51
    _M_in_input_mode(false), _M_in_output_mode(false),
williamr@2
    52
    _M_in_error_mode(false), _M_in_putback_mode(false),
williamr@2
    53
    _M_int_buf(0), _M_int_buf_EOS(0),
williamr@2
    54
    _M_ext_buf(0), _M_ext_buf_EOS(0),
williamr@2
    55
    _M_ext_buf_converted(0), _M_ext_buf_end(0),
williamr@2
    56
    _M_state(_STLP_DEFAULT_CONSTRUCTED(_State_type)),
williamr@2
    57
    _M_end_state(_STLP_DEFAULT_CONSTRUCTED(_State_type)),
williamr@2
    58
    _M_mmap_base(0), _M_mmap_len(0),
williamr@2
    59
    _M_saved_eback(0), _M_saved_gptr(0), _M_saved_egptr(0),
williamr@2
    60
    _M_codecvt(0),
williamr@2
    61
    _M_width(1), _M_max_width(1)
williamr@2
    62
{
williamr@2
    63
  this->_M_setup_codecvt(locale());
williamr@2
    64
}
williamr@2
    65
williamr@2
    66
template <class _CharT, class _Traits>
williamr@2
    67
basic_filebuf<_CharT, _Traits>::~basic_filebuf() {
williamr@2
    68
  this->close();
williamr@2
    69
  _M_deallocate_buffers();
williamr@2
    70
}
williamr@2
    71
williamr@2
    72
williamr@2
    73
template <class _CharT, class _Traits>
williamr@2
    74
_STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::int_type 
williamr@2
    75
basic_filebuf<_CharT, _Traits>::underflow() 
williamr@2
    76
{
williamr@2
    77
  return _Underflow<_CharT, _Traits>::_M_doit(this);
williamr@2
    78
}
williamr@2
    79
williamr@2
    80
template <class _CharT, class _Traits>
williamr@2
    81
basic_filebuf<_CharT, _Traits>* 
williamr@2
    82
basic_filebuf<_CharT, _Traits>::close()
williamr@2
    83
{
williamr@2
    84
  bool __ok = this->is_open();
williamr@2
    85
williamr@2
    86
  if (_M_in_output_mode) {
williamr@2
    87
    __ok = __ok && !_Traits::eq_int_type(this->overflow(traits_type::eof()),
williamr@2
    88
                                         traits_type::eof());
williamr@2
    89
    __ok == __ok && this->_M_unshift();
williamr@2
    90
  }
williamr@2
    91
  else if (_M_in_input_mode)
williamr@2
    92
      this->_M_exit_input_mode();
williamr@2
    93
williamr@2
    94
  // Note order of arguments.  We close the file even if __ok is false.
williamr@2
    95
  __ok = _M_base._M_close() && __ok;
williamr@2
    96
williamr@2
    97
  // Restore the initial state, except that we don't deallocate the buffer
williamr@2
    98
  // or mess with the cached codecvt information.
williamr@2
    99
  _M_state = _M_end_state = _State_type();
williamr@2
   100
  _M_ext_buf_converted = _M_ext_buf_end = 0;
williamr@2
   101
williamr@2
   102
  _M_mmap_base = 0;
williamr@2
   103
  _M_mmap_len = 0;
williamr@2
   104
williamr@2
   105
#ifdef __SYMBIAN32__
williamr@2
   106
  if (__ok) {
williamr@2
   107
#endif // __SYMBIAN32__
williamr@2
   108
  this->setg(0, 0, 0);
williamr@2
   109
  this->setp(0, 0);
williamr@2
   110
#ifdef __SYMBIAN32__  
williamr@2
   111
  }
williamr@2
   112
#endif // __SYMBIAN32__
williamr@2
   113
williamr@2
   114
  _M_saved_eback = _M_saved_gptr = _M_saved_egptr = 0;
williamr@2
   115
williamr@2
   116
  _M_in_input_mode = _M_in_output_mode = _M_in_error_mode = _M_in_putback_mode
williamr@2
   117
    = false;
williamr@2
   118
williamr@2
   119
  return __ok ? this : 0;
williamr@2
   120
}
williamr@2
   121
williamr@2
   122
// This member function is called whenever we exit input mode.
williamr@2
   123
// It unmaps the memory-mapped file, if any, and sets
williamr@2
   124
// _M_in_input_mode to false.  
williamr@2
   125
template <class _CharT, class _Traits>
williamr@2
   126
void basic_filebuf<_CharT, _Traits>::_M_exit_input_mode()
williamr@2
   127
{
williamr@2
   128
   if (_M_mmap_base != 0)
williamr@2
   129
     _M_base._M_unmap(_M_mmap_base, _M_mmap_len); 
williamr@2
   130
   _M_in_input_mode = false;
williamr@2
   131
   _M_mmap_base = 0;
williamr@2
   132
}
williamr@2
   133
williamr@2
   134
williamr@2
   135
//----------------------------------------------------------------------
williamr@2
   136
// basic_filebuf<> overridden protected virtual member functions
williamr@2
   137
williamr@2
   138
template <class _CharT, class _Traits>
williamr@2
   139
streamsize basic_filebuf<_CharT, _Traits>::showmanyc()
williamr@2
   140
{
williamr@2
   141
  // Is there any possibility that reads can succeed?
williamr@2
   142
#ifdef __SYMBIAN32__
williamr@2
   143
  if (!this->is_open() || !(_M_base.__o_mode() & (int)ios_base::in) || _M_in_error_mode)
williamr@2
   144
#else
williamr@2
   145
  if (!this->is_open() || _M_in_output_mode || _M_in_error_mode)
williamr@2
   146
#endif
williamr@2
   147
    return -1;
williamr@2
   148
williamr@2
   149
  else if (_M_in_putback_mode)
williamr@2
   150
    return this->egptr() - this->gptr();
williamr@2
   151
williamr@2
   152
  else if (_M_constant_width) {
williamr@2
   153
    streamoff __pos  = _M_base._M_seek(0, ios_base::cur);
williamr@2
   154
    streamoff __size = _M_base._M_file_size();
williamr@2
   155
#ifdef __SYMBIAN32__
williamr@2
   156
    if(__size == 0)
williamr@2
   157
        return 0;
williamr@2
   158
#endif
williamr@2
   159
    return __pos >= 0 && __size > __pos ? __size - __pos : -1;
williamr@2
   160
  }
williamr@2
   161
williamr@2
   162
  else 
williamr@2
   163
    return 0;
williamr@2
   164
}
williamr@2
   165
williamr@2
   166
williamr@2
   167
// Make a putback position available, if necessary, by switching to a 
williamr@2
   168
// special internal buffer used only for putback.  The buffer is
williamr@2
   169
// [_M_pback_buf, _M_pback_buf + _S_pback_buf_size), but the base
williamr@2
   170
// class only sees a piece of it at a time.  (We want to make sure
williamr@2
   171
// that we don't try to read a character that hasn't been initialized.)
williamr@2
   172
// The end of the putback buffer is always _M_pback_buf + _S_pback_buf_size,
williamr@2
   173
// but the beginning is usually not _M_pback_buf.
williamr@2
   174
template <class _CharT, class _Traits>
williamr@2
   175
__BF_int_type__ 
williamr@2
   176
basic_filebuf<_CharT, _Traits>::pbackfail(int_type __c)
williamr@2
   177
{
williamr@2
   178
  const int_type __eof = traits_type::eof();
williamr@2
   179
williamr@2
   180
  // If we aren't already in input mode, pushback is impossible.
williamr@2
   181
  if (!_M_in_input_mode)
williamr@2
   182
    return __eof;
williamr@2
   183
williamr@2
   184
  // We can use the ordinary get buffer if there's enough space, and
williamr@2
   185
  // if it's a buffer that we're allowed to write to.
williamr@2
   186
  if (this->gptr() != this->eback() &&
williamr@2
   187
      (traits_type::eq_int_type(__c, __eof) ||
williamr@2
   188
       traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]) ||
williamr@2
   189
       !_M_mmap_base)) {
williamr@2
   190
    this->gbump(-1);
williamr@2
   191
    if (traits_type::eq_int_type(__c, __eof) ||
williamr@2
   192
        traits_type::eq(traits_type::to_char_type(__c), *this->gptr()))
williamr@2
   193
      return traits_type::to_int_type(*this->gptr());
williamr@2
   194
  }
williamr@2
   195
  else if (!traits_type::eq_int_type(__c, __eof)) {
williamr@2
   196
    // Are we in the putback buffer already?
williamr@2
   197
    _CharT* __pback_end = _M_pback_buf + __STATIC_CAST(int,_S_pback_buf_size);
williamr@2
   198
    if (_M_in_putback_mode) {
williamr@2
   199
      // Do we have more room in the putback buffer?
williamr@2
   200
      if (this->eback() != _M_pback_buf) 
williamr@2
   201
        this->setg(this->egptr() - 1, this->egptr() - 1, __pback_end);
williamr@2
   202
      else
williamr@2
   203
        return __eof;           // No more room in the buffer, so fail.
williamr@2
   204
    }
williamr@2
   205
    else {                      // We're not yet in the putback buffer.
williamr@2
   206
      _M_saved_eback = this->eback();
williamr@2
   207
      _M_saved_gptr  = this->gptr();
williamr@2
   208
      _M_saved_egptr = this->egptr();
williamr@2
   209
      this->setg(__pback_end - 1, __pback_end - 1, __pback_end);
williamr@2
   210
      _M_in_putback_mode = true;
williamr@2
   211
    }
williamr@2
   212
  }
williamr@2
   213
  else
williamr@2
   214
  {
williamr@2
   215
#ifdef __SYMBIAN32__
williamr@2
   216
    if (traits_type::eq_int_type(__c, __eof) )
williamr@2
   217
    {
williamr@2
   218
        if(_M_in_putback_mode)
williamr@2
   219
        {
williamr@2
   220
            _M_in_putback_mode = false;
williamr@2
   221
            // we are at putback mode
williamr@2
   222
            if(_M_saved_eback != _M_saved_gptr)
williamr@2
   223
            {
williamr@2
   224
                this->setg(_M_saved_eback, _M_saved_gptr - 1, _M_saved_egptr);
williamr@2
   225
                return *this->gptr();
williamr@2
   226
            }
williamr@2
   227
            else
williamr@2
   228
                this->setg(_M_saved_eback, _M_saved_gptr, _M_saved_egptr);
williamr@2
   229
         
williamr@2
   230
         }
williamr@2
   231
         else
williamr@2
   232
         {
williamr@2
   233
            if(!this->eback())
williamr@2
   234
            {
williamr@2
   235
                streamoff __pos  = _M_base._M_seek(0, ios_base::cur);
williamr@2
   236
                streamoff __size = _M_base._M_file_size();
williamr@2
   237
                if( __size > 0 && __pos > 0 && __pos == __size)
williamr@2
   238
                    __pos  = _M_base._M_seek(__pos - 1, ios_base::beg);
williamr@2
   239
                this->underflow();
williamr@2
   240
                this->setg(this->eback(), this->gptr(), this->egptr());
williamr@2
   241
                return *this->gptr();
williamr@2
   242
            }
williamr@2
   243
            else
williamr@2
   244
            {
williamr@2
   245
                this->setg(this->eback(), this->gptr() - 1, this->egptr());
williamr@2
   246
                return *this->gptr();
williamr@2
   247
            }
williamr@2
   248
         }
williamr@2
   249
    }
williamr@2
   250
#endif
williamr@2
   251
    return __eof;
williamr@2
   252
  }
williamr@2
   253
  // We have made a putback position available.  Assign to it, and return.
williamr@2
   254
  *this->gptr() = traits_type::to_char_type(__c);
williamr@2
   255
  return __c;
williamr@2
   256
}
williamr@2
   257
williamr@2
   258
// This member function flushes the put area, and also outputs the
williamr@2
   259
// character __c (unless __c is eof).  Invariant: we always leave room
williamr@2
   260
// in the internal buffer for one character more than the base class knows
williamr@2
   261
// about.  We see the internal buffer as [_M_int_buf, _M_int_buf_EOS), but
williamr@2
   262
// the base class only sees [_M_int_buf, _M_int_buf_EOS - 1).
williamr@2
   263
template <class _CharT, class _Traits>
williamr@2
   264
__BF_int_type__
williamr@2
   265
basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
williamr@2
   266
{
williamr@2
   267
  // Switch to output mode, if necessary.
williamr@2
   268
  bool putflag = false;
williamr@2
   269
  if (!_M_in_output_mode)
williamr@2
   270
  {
williamr@2
   271
#ifdef __SYMBIAN32__
williamr@2
   272
    if(this->_M_int_buf)
williamr@2
   273
        putflag = true;
williamr@2
   274
#endif
williamr@2
   275
    if (!_M_switch_to_output_mode())
williamr@2
   276
      return traits_type::eof();
williamr@2
   277
  }
williamr@2
   278
  _CharT* __ibegin = this->_M_int_buf;
williamr@2
   279
  _CharT* __iend   = this->pptr();
williamr@2
   280
  this->setp(_M_int_buf, _M_int_buf_EOS - 1);
williamr@2
   281
williamr@2
   282
  // Put __c at the end of the internal buffer.
williamr@2
   283
  if (!traits_type::eq_int_type(__c, traits_type::eof()))
williamr@2
   284
    *__iend++ = __c;
williamr@2
   285
#ifdef __SYMBIAN32__
williamr@2
   286
  int current_pos = this->gptr() - this->eback();
williamr@2
   287
  streamoff __size = _M_base._M_file_size();
williamr@2
   288
  if(current_pos > 0 && current_pos < __size && _M_base.__is_open())
williamr@2
   289
    _M_base._M_seek(current_pos, ios_base::beg);
williamr@2
   290
#endif
williamr@2
   291
williamr@2
   292
  // For variable-width encodings, output may take more than one pass.
williamr@2
   293
  while (__ibegin != __iend) {
williamr@2
   294
    const _CharT* __inext = __ibegin;
williamr@2
   295
    char* __enext         = _M_ext_buf;
williamr@2
   296
    typename _Codecvt::result __status
williamr@2
   297
      = _M_codecvt->out(_M_state, __ibegin, __iend, __inext,
williamr@2
   298
                                  _M_ext_buf, _M_ext_buf_EOS, __enext);
williamr@2
   299
    if (__status == _Codecvt::noconv)
williamr@2
   300
#ifdef __SYMBIAN32__    
williamr@2
   301
    {
williamr@2
   302
      if(_Noconv_output<_Traits>::_M_doit(this, __ibegin, __iend))
williamr@2
   303
      {
williamr@2
   304
        if (this->eback())
williamr@2
   305
            {
williamr@2
   306
            *(this->gptr()) = __c;
williamr@2
   307
            this->setg(this->eback(), this->gptr() + 1, this->egptr());
williamr@2
   308
            }
williamr@2
   309
        if(putflag && this->pptr()  < this->epptr())
williamr@2
   310
            this->setp(this->pptr() + 1, this->epptr());
williamr@2
   311
        return traits_type::not_eof(__c);
williamr@2
   312
      }
williamr@2
   313
      else
williamr@2
   314
        return _M_output_error();
williamr@2
   315
    }
williamr@2
   316
#else
williamr@2
   317
      return _Noconv_output<_Traits>::_M_doit(this, __ibegin, __iend)
williamr@2
   318
        ? traits_type::not_eof(__c)
williamr@2
   319
        : _M_output_error();
williamr@2
   320
#endif
williamr@2
   321
    // For a constant-width encoding we know that the external buffer
williamr@2
   322
    // is large enough, so failure to consume the entire internal buffer
williamr@2
   323
    // or to produce the correct number of external characters, is an error.
williamr@2
   324
    // For a variable-width encoding, however, we require only that we 
williamr@2
   325
    // consume at least one internal character
williamr@2
   326
    else if (__status != _Codecvt::error && 
williamr@2
   327
             ((__inext == __iend && (__enext - _M_ext_buf == 
williamr@2
   328
                                     _M_width * (__iend - __ibegin))) ||
williamr@2
   329
              (!_M_constant_width && __inext != __ibegin))) {
williamr@2
   330
        // We successfully converted part or all of the internal buffer.
williamr@2
   331
      ptrdiff_t __n = __enext - _M_ext_buf;
williamr@2
   332
      if (_M_write(_M_ext_buf, __n))
williamr@2
   333
        __ibegin += __inext - __ibegin;
williamr@2
   334
      else
williamr@2
   335
        return _M_output_error();
williamr@2
   336
    }
williamr@2
   337
    else
williamr@2
   338
      return _M_output_error();
williamr@2
   339
  }
williamr@2
   340
williamr@2
   341
  return traits_type::not_eof(__c);
williamr@2
   342
}
williamr@2
   343
williamr@2
   344
// This member function must be called before any I/O has been
williamr@2
   345
// performed on the stream, otherwise it has no effect.
williamr@2
   346
//
williamr@2
   347
// __buf == 0 && __n == 0 means to make ths stream unbuffered.
williamr@2
   348
// __buf != 0 && __n > 0 means to use __buf as the stream's internal
williamr@2
   349
// buffer, rather than the buffer that would otherwise be allocated
williamr@2
   350
// automatically.  __buf must be a pointer to an array of _CharT whose
williamr@2
   351
// size is at least __n.
williamr@2
   352
template <class _CharT, class _Traits>
williamr@2
   353
basic_streambuf<_CharT, _Traits>*
williamr@2
   354
basic_filebuf<_CharT, _Traits>::setbuf(_CharT* __buf, streamsize __n)
williamr@2
   355
{
williamr@2
   356
  if (!_M_in_input_mode &&! _M_in_output_mode && !_M_in_error_mode &&
williamr@2
   357
      _M_int_buf == 0) {
williamr@2
   358
    if (__buf == 0 && __n == 0)
williamr@2
   359
      _M_allocate_buffers(0, 1);
williamr@2
   360
    else if (__buf != 0 && __n > 0)
williamr@2
   361
      _M_allocate_buffers(__buf, __n);
williamr@2
   362
  }
williamr@2
   363
  return this;
williamr@2
   364
}
williamr@2
   365
williamr@2
   366
template <class _CharT, class _Traits>
williamr@2
   367
__BF_pos_type__
williamr@2
   368
basic_filebuf<_CharT, _Traits>::seekoff(off_type __off,
williamr@2
   369
                                        ios_base::seekdir __whence,
williamr@2
   370
                                        ios_base::openmode /* dummy */)
williamr@2
   371
{
williamr@2
   372
  if (this->is_open() &&
williamr@2
   373
      (__off == 0 || (_M_constant_width && this->_M_base._M_in_binary_mode()))) {
williamr@2
   374
williamr@2
   375
    if (!_M_seek_init(__off != 0 || __whence != ios_base::cur))
williamr@2
   376
      return pos_type(-1);
williamr@2
   377
williamr@2
   378
    // Seek to beginning or end, regardless of whether we're in input mode.
williamr@2
   379
    if (__whence == ios_base::beg || __whence == ios_base::end)
williamr@2
   380
      return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence),
williamr@2
   381
                            _State_type());
williamr@2
   382
williamr@2
   383
    // Seek relative to current position.  Complicated if we're in input mode.
williamr@2
   384
    else if (__whence == ios_base::cur) {
williamr@2
   385
williamr@2
   386
      if (!_M_in_input_mode)
williamr@2
   387
        return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence),
williamr@2
   388
                              _State_type());
williamr@2
   389
      else if (_M_mmap_base != 0) {
williamr@2
   390
        // __off is relative to gptr().  We need to do a bit of arithmetic
williamr@2
   391
        // to get an offset relative to the external file pointer.
williamr@2
   392
        streamoff __adjust = _M_mmap_len - (this->gptr() - (_CharT*) _M_mmap_base);
williamr@2
   393
williamr@2
   394
        // if __off == 0, we do not need to exit input mode and to shift file pointer
williamr@2
   395
        if (__off == 0) {
williamr@2
   396
          return pos_type(_M_base._M_seek(0, ios_base::cur) - __adjust);
williamr@2
   397
        }
williamr@2
   398
        else
williamr@2
   399
#ifdef __SYMBIAN32__       
williamr@2
   400
        return _M_seek_return(_M_base._M_seek(__off, ios_base::cur), _State_type());
williamr@2
   401
#else      
williamr@2
   402
          return _M_seek_return(_M_base._M_seek(__off - __adjust, ios_base::cur), _State_type());
williamr@2
   403
#endif
williamr@2
   404
      }
williamr@2
   405
      else if (_M_constant_width) { // Get or set the position.  
williamr@2
   406
williamr@2
   407
        streamoff __iadj = _M_width * (this->gptr() - this->eback());
williamr@2
   408
        
williamr@2
   409
        // Compensate for offset relative to gptr versus offset relative
williamr@2
   410
        // to external pointer.  For a text-oriented stream, where the 
williamr@2
   411
        // compensation is more than just pointer arithmetic, we may get
williamr@2
   412
        // but not set the current position.
williamr@2
   413
        
williamr@2
   414
        if (__iadj <= _M_ext_buf_end - _M_ext_buf) {
williamr@2
   415
          
williamr@2
   416
          streamoff __eadj =  _M_base._M_get_offset(_M_ext_buf + __iadj, _M_ext_buf_end);
williamr@2
   417
williamr@2
   418
          if (__off == 0) {
williamr@2
   419
            return pos_type(_M_base._M_seek(0, ios_base::cur) - __eadj);
williamr@2
   420
          }  else {
williamr@2
   421
            return _M_seek_return(_M_base._M_seek(__off - __eadj, ios_base::cur), _State_type());
williamr@2
   422
          }
williamr@2
   423
        }
williamr@2
   424
        else
williamr@2
   425
          return pos_type(-1);
williamr@2
   426
      }
williamr@2
   427
      else {                    // Get the position.  Encoding is var width.
williamr@2
   428
        // Get position in internal buffer.
williamr@2
   429
        ptrdiff_t __ipos = this->gptr() - this->eback();
williamr@2
   430
        
williamr@2
   431
        // Get corresponding position in external buffer.
williamr@2
   432
        _State_type __state = _M_state;
williamr@2
   433
        int __epos = _M_codecvt->length(__state, _M_ext_buf, _M_ext_buf_end,
williamr@2
   434
                                        __ipos);
williamr@2
   435
williamr@2
   436
        // Sanity check (expensive): make sure __epos is the right answer.
williamr@2
   437
        _State_type __tmp_state = _M_state;
williamr@2
   438
        _Filebuf_Tmp_Buf<_CharT> __buf(__ipos);
williamr@2
   439
        _CharT* __ibegin = __buf._M_ptr;
williamr@2
   440
        _CharT* __inext  = __ibegin;
williamr@2
   441
williamr@2
   442
        const char* __dummy;
williamr@2
   443
        typename _Codecvt::result __status
williamr@2
   444
          = _M_codecvt->in(__tmp_state,
williamr@2
   445
                           _M_ext_buf, _M_ext_buf + __epos, __dummy,
williamr@2
   446
                           __ibegin, __ibegin + __ipos, __inext);
williamr@2
   447
        if (__status != _Codecvt::error &&
williamr@2
   448
            (__status == _Codecvt::noconv ||
williamr@2
   449
             (__inext == __ibegin + __ipos &&
williamr@2
   450
              equal(this->gptr(), this->eback(), __ibegin,
williamr@2
   451
                    _Eq_traits<traits_type>())))) {
williamr@2
   452
          // Get the current position (at the end of the external buffer),
williamr@2
   453
          // then adjust it.  Again, it might be a text-oriented stream.
williamr@2
   454
          streamoff __cur = _M_base._M_seek(0, ios_base::cur);
williamr@2
   455
          streamoff __adj =
williamr@2
   456
            _M_base._M_get_offset(_M_ext_buf, _M_ext_buf + __epos) -
williamr@2
   457
            _M_base._M_get_offset(_M_ext_buf, _M_ext_buf_end);
williamr@2
   458
          if (__cur != -1 && __cur + __adj >= 0)
williamr@2
   459
            return _M_seek_return(__cur + __adj, __state);
williamr@2
   460
          else
williamr@2
   461
            return pos_type(-1);
williamr@2
   462
        }
williamr@2
   463
        else                    // We failed the sanity check.
williamr@2
   464
          return pos_type(-1);
williamr@2
   465
      }
williamr@2
   466
    }
williamr@2
   467
    else                        // Unrecognized value for __whence.
williamr@2
   468
      return pos_type(-1);
williamr@2
   469
  }
williamr@2
   470
  else
williamr@2
   471
    return pos_type(-1);
williamr@2
   472
}
williamr@2
   473
williamr@2
   474
williamr@2
   475
template <class _CharT, class _Traits>
williamr@2
   476
__BF_pos_type__
williamr@2
   477
basic_filebuf<_CharT, _Traits>::seekpos(pos_type __pos,
williamr@2
   478
                                        ios_base::openmode /* dummy */)
williamr@2
   479
{
williamr@2
   480
  if (this->is_open()) {
williamr@2
   481
    if (!_M_seek_init(true))
williamr@2
   482
      return pos_type(-1);
williamr@2
   483
williamr@2
   484
    streamoff __off = off_type(__pos);
williamr@2
   485
    if (__off != -1 && _M_base._M_seek(__off, ios_base::beg) != -1) {
williamr@2
   486
      _M_state = __pos.state();
williamr@2
   487
      return _M_seek_return(__off, __pos.state());
williamr@2
   488
    }
williamr@2
   489
    else
williamr@2
   490
      return pos_type(-1);
williamr@2
   491
  }
williamr@2
   492
  else
williamr@2
   493
    return pos_type(-1);
williamr@2
   494
}
williamr@2
   495
williamr@2
   496
williamr@2
   497
template <class _CharT, class _Traits>
williamr@2
   498
int basic_filebuf<_CharT, _Traits>::sync()
williamr@2
   499
{
williamr@2
   500
  if (_M_in_output_mode)
williamr@2
   501
    return traits_type::eq_int_type(this->overflow(traits_type::eof()),
williamr@2
   502
                                    traits_type::eof())
williamr@2
   503
      ? -1
williamr@2
   504
      : 0;
williamr@2
   505
  else
williamr@2
   506
    return 0;
williamr@2
   507
}
williamr@2
   508
williamr@2
   509
williamr@2
   510
// Change the filebuf's locale.  This member function has no effect
williamr@2
   511
// unless it is called before any I/O is performed on the stream.
williamr@2
   512
template <class _CharT, class _Traits>
williamr@2
   513
void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
williamr@2
   514
{
williamr@2
   515
  if (!_M_in_input_mode &&! _M_in_output_mode && !_M_in_error_mode) {
williamr@2
   516
    this->_M_setup_codecvt(__loc);
williamr@2
   517
  }
williamr@2
   518
}
williamr@2
   519
williamr@2
   520
//----------------------------------------------------------------------
williamr@2
   521
// basic_filebuf<> helper functions.
williamr@2
   522
williamr@2
   523
//----------------------------------------
williamr@2
   524
// Helper functions for switching between modes.
williamr@2
   525
williamr@2
   526
// This member function is called if we're performing the first I/O
williamr@2
   527
// operation on a filebuf, or if we're performing an input operation 
williamr@2
   528
// immediately after a seek.
williamr@2
   529
template <class _CharT, class _Traits>
williamr@2
   530
bool basic_filebuf<_CharT, _Traits>::_M_switch_to_input_mode()
williamr@2
   531
{
williamr@2
   532
williamr@2
   533
  if (this->is_open() && (((int)_M_base.__o_mode() & (int)ios_base::in) !=0)
williamr@2
   534
#ifndef __SYMBIAN32__
williamr@2
   535
      && (_M_in_output_mode == 0) 
williamr@2
   536
#endif
williamr@2
   537
      && (_M_in_error_mode == 0)) {
williamr@2
   538
#ifdef __STLP_NO_WRITE_SIDE_BUFFERING__
williamr@2
   539
    // If file has been opened in input|output mode
williamr@2
   540
    if ((((int)_M_base.__o_mode() & (int)ios_base::out) !=0) 
williamr@2
   541
#ifndef __SYMBIAN32__
williamr@2
   542
        && sync()
williamr@2
   543
#endif
williamr@2
   544
        && !_M_int_buf && !_M_allocate_buffers(0, 1))
williamr@2
   545
#else
williamr@2
   546
    if (!_M_int_buf && !_M_allocate_buffers())
williamr@2
   547
#endif
williamr@2
   548
      return false;
williamr@2
   549
williamr@2
   550
    _M_ext_buf_converted = _M_ext_buf;
williamr@2
   551
    _M_ext_buf_end       = _M_ext_buf;
williamr@2
   552
williamr@2
   553
    _M_end_state    = _M_state;
williamr@2
   554
williamr@2
   555
    _M_in_input_mode = true;
williamr@2
   556
    return true;
williamr@2
   557
  }
williamr@2
   558
  else
williamr@2
   559
williamr@2
   560
    return false;
williamr@2
   561
}
williamr@2
   562
williamr@2
   563
williamr@2
   564
// This member function is called if we're performing the first I/O
williamr@2
   565
// operation on a filebuf, or if we're performing an output operation 
williamr@2
   566
// immediately after a seek.
williamr@2
   567
template <class _CharT, class _Traits>
williamr@2
   568
bool basic_filebuf<_CharT, _Traits>::_M_switch_to_output_mode()
williamr@2
   569
{
williamr@2
   570
  if (this->is_open() && (_M_base.__o_mode() & (int)ios_base::out) &&
williamr@2
   571
#ifdef __SYMBIAN32__  
williamr@2
   572
      _M_in_error_mode == 0) {
williamr@2
   573
#else      
williamr@2
   574
      _M_in_input_mode == 0 && _M_in_error_mode == 0) {
williamr@2
   575
#endif //__SYMBIAN32__      
williamr@2
   576
williamr@2
   577
#ifdef __STLP_NO_WRITE_SIDE_BUFFERING__
williamr@2
   578
    if (!_M_int_buf && !_M_allocate_buffers(0, 1))
williamr@2
   579
#else
williamr@2
   580
    if (!_M_int_buf && !_M_allocate_buffers())
williamr@2
   581
#endif
williamr@2
   582
      return false;
williamr@2
   583
williamr@2
   584
    // In append mode, every write does an implicit seek to the end
williamr@2
   585
    // of the file.  Whenever leaving output mode, the end of file
williamr@2
   586
    // get put in the initial shift state.
williamr@2
   587
    if (_M_base.__o_mode() & ios_base::app)
williamr@2
   588
      _M_state = _State_type();
williamr@2
   589
williamr@2
   590
    this->setp(_M_int_buf, _M_int_buf_EOS - 1);
williamr@2
   591
    _M_in_output_mode = true;
williamr@2
   592
williamr@2
   593
    return true;
williamr@2
   594
  }
williamr@2
   595
  else
williamr@2
   596
    return false;
williamr@2
   597
}
williamr@2
   598
williamr@2
   599
williamr@2
   600
//----------------------------------------
williamr@2
   601
// Helper functions for input
williamr@2
   602
williamr@2
   603
// This member function is called if there is an error during input.
williamr@2
   604
// It puts the filebuf in error mode, clear the get area buffer, and
williamr@2
   605
// returns eof.
williamr@2
   606
// returns eof.  Error mode is sticky; it is cleared only by close or
williamr@2
   607
// seek.
williamr@2
   608
williamr@2
   609
template <class _CharT, class _Traits>
williamr@2
   610
__BF_int_type__
williamr@2
   611
basic_filebuf<_CharT, _Traits>::_M_input_error()
williamr@2
   612
{
williamr@2
   613
   this->_M_exit_input_mode();   
williamr@2
   614
  _M_in_output_mode = false;
williamr@2
   615
  _M_in_error_mode = true;
williamr@2
   616
  this->setg(0, 0, 0);
williamr@2
   617
  return traits_type::eof();
williamr@2
   618
}
williamr@2
   619
williamr@2
   620
template <class _CharT, class _Traits>
williamr@2
   621
__BF_int_type__ 
williamr@2
   622
basic_filebuf<_CharT, _Traits>::_M_underflow_aux() 
williamr@2
   623
{
williamr@2
   624
  // We have the state and file position from the end of the internal
williamr@2
   625
  // buffer.  This round, they become the beginning of the internal buffer.
williamr@2
   626
  _M_state    = _M_end_state;
williamr@2
   627
williamr@2
   628
  // Fill the external buffer.  Start with any leftover characters that
williamr@2
   629
  // didn't get converted last time.
williamr@2
   630
  if (_M_ext_buf_end > _M_ext_buf_converted)
williamr@2
   631
williamr@2
   632
    _M_ext_buf_end = copy(_M_ext_buf_converted, _M_ext_buf_end, _M_ext_buf);
williamr@2
   633
    // boris : copy_backward did not work
williamr@2
   634
    //_M_ext_buf_end = copy_backward(_M_ext_buf_converted, _M_ext_buf_end, 
williamr@2
   635
    //_M_ext_buf+ (_M_ext_buf_end - _M_ext_buf_converted));
williamr@2
   636
  else
williamr@2
   637
    {
williamr@2
   638
#ifdef __SYMBIAN32__
williamr@2
   639
     if(_M_ext_buf == NULL)
williamr@2
   640
    _M_allocate_buffers(0, MMAP_CHUNK);
williamr@2
   641
#endif
williamr@2
   642
    _M_ext_buf_end = _M_ext_buf;
williamr@2
   643
    }
williamr@2
   644
  // Now fill the external buffer with characters from the file.  This is
williamr@2
   645
  // a loop because occasonally we don't get enough external characters
williamr@2
   646
  // to make progress.
williamr@2
   647
  while (true) {
williamr@2
   648
    ptrdiff_t __n = _M_base._M_read(_M_ext_buf_end, _M_ext_buf_EOS - _M_ext_buf_end);
williamr@2
   649
 
williamr@2
   650
    // Don't enter error mode for a failed read.  Error mode is sticky,
williamr@2
   651
    // and we might succeed if we try again.
williamr@2
   652
#ifdef __SYMBIAN32__    //plum hall bug 577
williamr@2
   653
    int nn = (char*)_M_ext_buf_end-(char*)_M_ext_buf; //number of chars unconverted last time
williamr@2
   654
    if ( (__n <= 0) && ( nn<=0 ) )
williamr@2
   655
#else
williamr@2
   656
	if (__n <= 0)
williamr@2
   657
#endif    
williamr@2
   658
      return traits_type::eof();
williamr@2
   659
williamr@2
   660
    // Convert the external buffer to internal characters.  
williamr@2
   661
    _M_ext_buf_end += __n;
williamr@2
   662
    const char*   __enext;
williamr@2
   663
    _CharT* __inext;
williamr@2
   664
williamr@2
   665
    typename _Codecvt::result __status
williamr@2
   666
      = _M_codecvt->in(_M_end_state,
williamr@2
   667
                       _M_ext_buf, _M_ext_buf_end, __enext,
williamr@2
   668
                       _M_int_buf, _M_int_buf_EOS, __inext);
williamr@2
   669
williamr@2
   670
    // Error conditions: (1) Return value of error.  (2) Producing internal
williamr@2
   671
    // characters without consuming external characters.  (3) In fixed-width
williamr@2
   672
    // encodings, producing an internal sequence whose length is inconsistent
williamr@2
   673
    // with that of the internal sequence.  (4) Failure to produce any 
williamr@2
   674
    // characters if we have enough characters in the external buffer, where
williamr@2
   675
    // "enough" means the largest possible width of a single character.
williamr@2
   676
    if (__status == _Codecvt::noconv)
williamr@2
   677
      return _Noconv_input<_Traits>::_M_doit(this);
williamr@2
   678
williamr@2
   679
    else if (__status == _Codecvt::error ||
williamr@2
   680
             (__inext != _M_int_buf && __enext == _M_ext_buf) ||
williamr@2
   681
             (_M_constant_width &&
williamr@2
   682
              //         __inext - _M_int_buf != _M_width * (__enext - _M_ext_buf)) ||
williamr@2
   683
              (__inext - _M_int_buf) *  _M_width != (__enext - _M_ext_buf)) ||
williamr@2
   684
             (__inext == _M_int_buf && __enext - _M_ext_buf >= _M_max_width))
williamr@2
   685
      return _M_input_error();
williamr@2
   686
    
williamr@2
   687
    else if (__inext != _M_int_buf) {
williamr@2
   688
      _M_ext_buf_converted = _M_ext_buf + (__enext - _M_ext_buf);
williamr@2
   689
      this->setg(_M_int_buf, _M_int_buf, __inext);
williamr@2
   690
      return traits_type::to_int_type(*_M_int_buf);
williamr@2
   691
    }
williamr@2
   692
    // We need to go around the loop again to get more external characters.
williamr@2
   693
  } 
williamr@2
   694
}
williamr@2
   695
williamr@2
   696
//----------------------------------------
williamr@2
   697
// Helper functions for output
williamr@2
   698
williamr@2
   699
// This member function is called if there is an error during output.
williamr@2
   700
// It puts the filebuf in error mode, clear the put area buffer, and
williamr@2
   701
// returns eof.  Error mode is sticky; it is cleared only by close or
williamr@2
   702
// seek.
williamr@2
   703
template <class _CharT, class _Traits>
williamr@2
   704
__BF_int_type__
williamr@2
   705
basic_filebuf<_CharT, _Traits>::_M_output_error()
williamr@2
   706
{
williamr@2
   707
  _M_in_output_mode = false;
williamr@2
   708
  _M_in_input_mode = false;
williamr@2
   709
  _M_in_error_mode = true;
williamr@2
   710
  this->setp(0, 0);
williamr@2
   711
  return traits_type::eof();
williamr@2
   712
}
williamr@2
   713
williamr@2
   714
williamr@2
   715
// Write whatever sequence of characters is necessary to get back to
williamr@2
   716
// the initial shift state.  This function overwrites the external
williamr@2
   717
// buffer, changes the external file position, and changes the state.
williamr@2
   718
// Precondition: the internal buffer is empty.
williamr@2
   719
template <class _CharT, class _Traits>
williamr@2
   720
bool basic_filebuf<_CharT, _Traits>::_M_unshift()
williamr@2
   721
{
williamr@2
   722
  if (_M_in_output_mode && !_M_constant_width) {
williamr@2
   723
    typename _Codecvt::result __status;
williamr@2
   724
    do {
williamr@2
   725
      char* __enext = _M_ext_buf;
williamr@2
   726
      __status = _M_codecvt->unshift(_M_state,
williamr@2
   727
                                     _M_ext_buf, _M_ext_buf_EOS, __enext);
williamr@2
   728
      if (__status == _Codecvt::noconv ||
williamr@2
   729
          (__enext == _M_ext_buf && __status == _Codecvt::ok))
williamr@2
   730
        return true;
williamr@2
   731
      else if (__status == _Codecvt::error)
williamr@2
   732
        return false;
williamr@2
   733
      else if (!_M_write(_M_ext_buf, __enext - _M_ext_buf))
williamr@2
   734
        return false;
williamr@2
   735
    } while(__status == _Codecvt::partial);
williamr@2
   736
  }
williamr@2
   737
williamr@2
   738
  return true;
williamr@2
   739
}
williamr@2
   740
williamr@2
   741
williamr@2
   742
//----------------------------------------
williamr@2
   743
// Helper functions for buffer allocation and deallocation
williamr@2
   744
williamr@2
   745
// This member function is called when we're initializing a filebuf's
williamr@2
   746
// internal and external buffers.  The argument is the size of the
williamr@2
   747
// internal buffer; the external buffer is sized using the character
williamr@2
   748
// width in the current encoding.  Preconditions: the buffers are currently
williamr@2
   749
// null.  __n >= 1.  __buf is either a null pointer or a pointer to an 
williamr@2
   750
// array show size is at least __n.
williamr@2
   751
williamr@2
   752
// We need __n >= 1 for two different reasons.  For input, the base
williamr@2
   753
// class always needs a buffer because of the sementics of underflow().
williamr@2
   754
// For output, we want to have an internal buffer that's larger by one
williamr@2
   755
// element than the buffer that the base class knows about.  (See 
williamr@2
   756
// basic_filebuf<>::overflow() for the reason.)
williamr@2
   757
template <class _CharT, class _Traits>
williamr@2
   758
bool 
williamr@2
   759
basic_filebuf<_CharT, _Traits>::_M_allocate_buffers(_CharT* __buf, streamsize __n)
williamr@2
   760
{
williamr@2
   761
williamr@2
   762
  if (__buf == 0) {
williamr@2
   763
    _M_int_buf = __STATIC_CAST(_CharT*,malloc(__n * sizeof(_CharT)));
williamr@2
   764
    if (! _M_int_buf)
williamr@2
   765
      return false;
williamr@2
   766
    _M_int_buf_dynamic = true;
williamr@2
   767
  }
williamr@2
   768
  else {
williamr@2
   769
    _M_int_buf = __buf;
williamr@2
   770
    _M_int_buf_dynamic = false;
williamr@2
   771
  }
williamr@2
   772
  
williamr@2
   773
  size_t __ebufsiz = (max)(__n * (max)(_M_codecvt->encoding(), 1),
williamr@2
   774
                      streamsize(_M_codecvt->max_length()));
williamr@2
   775
williamr@2
   776
  _M_ext_buf = __STATIC_CAST(char*,malloc(__ebufsiz));
williamr@2
   777
  if (!_M_ext_buf) {
williamr@2
   778
    _M_deallocate_buffers();
williamr@2
   779
    return false;
williamr@2
   780
  }
williamr@2
   781
williamr@2
   782
  _M_int_buf_EOS = _M_int_buf + __n;
williamr@2
   783
  _M_ext_buf_EOS = _M_ext_buf + __ebufsiz;
williamr@2
   784
  return true;
williamr@2
   785
}
williamr@2
   786
williamr@2
   787
// Abbreviation for the most common case.
williamr@2
   788
template <class _CharT, class _Traits>
williamr@2
   789
bool basic_filebuf<_CharT, _Traits>::_M_allocate_buffers()
williamr@2
   790
{
williamr@2
   791
  // Choose a buffer that's at least 4096 characters long and that's a
williamr@2
   792
  // multiple of the page size.
williamr@2
   793
  streamsize __default_bufsiz =
williamr@2
   794
    ((_M_base.__page_size() + 4095UL) / _M_base.__page_size()) * _M_base.__page_size();
williamr@2
   795
  return _M_allocate_buffers(0, __default_bufsiz);
williamr@2
   796
}
williamr@2
   797
williamr@2
   798
template <class _CharT, class _Traits>
williamr@2
   799
void basic_filebuf<_CharT, _Traits>::_M_deallocate_buffers()
williamr@2
   800
{
williamr@2
   801
  if (_M_int_buf_dynamic)
williamr@2
   802
    free(_M_int_buf);
williamr@2
   803
  free(_M_ext_buf);
williamr@2
   804
  _M_int_buf     = 0;
williamr@2
   805
  _M_int_buf_EOS = 0;
williamr@2
   806
  _M_ext_buf     = 0;
williamr@2
   807
  _M_ext_buf_EOS = 0;
williamr@2
   808
}
williamr@2
   809
williamr@2
   810
williamr@2
   811
//----------------------------------------
williamr@2
   812
// Helper functiosn for seek and imbue
williamr@2
   813
williamr@2
   814
template <class _CharT, class _Traits>
williamr@2
   815
bool basic_filebuf<_CharT, _Traits>::_M_seek_init(bool __do_unshift) {
williamr@2
   816
  // If we're in error mode, leave it.
williamr@2
   817
   _M_in_error_mode = false;
williamr@2
   818
   
williamr@2
   819
  // Flush the output buffer if we're in output mode, and (conditionally)
williamr@2
   820
  // emit an unshift sequence.
williamr@2
   821
  if (_M_in_output_mode) {
williamr@2
   822
    bool __ok = !traits_type::eq_int_type(this->overflow(traits_type::eof()),
williamr@2
   823
                                          traits_type::eof());
williamr@2
   824
    if (__do_unshift)
williamr@2
   825
      __ok = __ok && this->_M_unshift();
williamr@2
   826
    if (!__ok) {
williamr@2
   827
      _M_in_output_mode = false;
williamr@2
   828
      _M_in_error_mode = true;
williamr@2
   829
      this->setp(0, 0);
williamr@2
   830
      return false;
williamr@2
   831
    }
williamr@2
   832
  }
williamr@2
   833
williamr@2
   834
  // Discard putback characters, if any.
williamr@2
   835
  if (_M_in_input_mode && _M_in_putback_mode)
williamr@2
   836
    _M_exit_putback_mode();
williamr@2
   837
williamr@2
   838
  return true;
williamr@2
   839
}
williamr@2
   840
williamr@2
   841
williamr@2
   842
// Change the filebuf's locale.  This member function has no effect
williamr@2
   843
// unless it is called before any I/O is performed on the stream.
williamr@2
   844
template <class _CharT, class _Traits>
williamr@2
   845
void basic_filebuf<_CharT, _Traits>::_M_setup_codecvt(const locale& __loc)
williamr@2
   846
{
williamr@2
   847
  _M_codecvt = &use_facet<_Codecvt>(__loc) ;
williamr@2
   848
  int __encoding    = _M_codecvt->encoding();
williamr@2
   849
williamr@2
   850
  _M_width          = (max)(__encoding, 1);
williamr@2
   851
  _M_max_width      = _M_codecvt->max_length();
williamr@2
   852
  _M_constant_width = __encoding > 0;
williamr@2
   853
  _M_always_noconv  = _M_codecvt->always_noconv();
williamr@2
   854
}
williamr@2
   855
williamr@2
   856
williamr@2
   857
williamr@2
   858
template <class _CharT, class _Traits>
williamr@2
   859
  _STLP_EXP_DECLSPEC basic_fstream<_CharT, _Traits>::basic_fstream()
williamr@2
   860
    : basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
williamr@2
   861
      this->init(&_M_buf);
williamr@2
   862
  }
williamr@2
   863
williamr@2
   864
williamr@2
   865
template <class _CharT, class _Traits>
williamr@2
   866
  _STLP_EXP_DECLSPEC basic_fstream<_CharT, _Traits>::~basic_fstream(){}
williamr@2
   867
  
williamr@2
   868
#ifdef __SYMBIAN32__
williamr@2
   869
template <class _CharT, class _Traits>
williamr@2
   870
int basic_filebuf<_CharT, _Traits>::save_read_buffer ()
williamr@2
   871
    {
williamr@2
   872
    return _M_in_putback_mode ? _M_saved_egptr - _M_saved_gptr : 0;
williamr@2
   873
    }
williamr@2
   874
template <class _CharT, class _Traits>
williamr@2
   875
void basic_filebuf<_CharT, _Traits>::_change_input_mode ()
williamr@2
   876
    {
williamr@2
   877
    _M_in_input_mode = 1;
williamr@2
   878
    }
williamr@2
   879
williamr@2
   880
#endif
williamr@2
   881
williamr@2
   882
_STLP_END_NAMESPACE
williamr@2
   883
williamr@2
   884
# undef __BF_int_type__
williamr@2
   885
# undef __BF_pos_type__
williamr@2
   886
# undef __BF_off_type__
williamr@2
   887
williamr@2
   888
# endif /* defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) */
williamr@2
   889
williamr@2
   890
#endif /* _STLP_FSTREAM_C */
williamr@2
   891