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