epoc32/include/stdapis/stlportv5/stl/_streambuf.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/stdapis/stlport/stl/_streambuf.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*
williamr@2
     2
 * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
williamr@2
     3
 *
williamr@2
     4
 * Copyright (c) 1999
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_INTERNAL_STREAMBUF
williamr@2
    21
#define _STLP_INTERNAL_STREAMBUF
williamr@2
    22
williamr@2
    23
#ifndef _STLP_IOS_BASE_H
williamr@2
    24
#include <stl/_ios_base.h>      // Needed for ios_base bitfield members.
williamr@2
    25
                                // <ios_base> includes <iosfwd>.
williamr@2
    26
#endif
williamr@2
    27
williamr@2
    28
#ifndef _STLP_STDIO_FILE_H
williamr@2
    29
#include <stl/_stdio_file.h>     // Declaration of struct FILE, and of
williamr@2
    30
                                // functions to manipulate it.
williamr@2
    31
#endif
williamr@2
    32
williamr@2
    33
_STLP_BEGIN_NAMESPACE
williamr@2
    34
williamr@2
    35
//----------------------------------------------------------------------
williamr@2
    36
// Class basic_streambuf<>, the base class of the streambuf hierarchy.
williamr@2
    37
williamr@2
    38
// A basic_streambuf<> manages an input (get) area and an output (put)
williamr@2
    39
// area.  Each is described by three pointers: a beginning, an end, and a
williamr@2
    40
// current position.  basic_streambuf<> contains some very simple member
williamr@2
    41
// functions that manipulate those six pointers, but almost all of the real
williamr@2
    42
// functionality gets delegated to protected virtual member functions.
williamr@2
    43
// All of the public member functions are inline, and most of the protected
williamr@2
    44
// member functions are virtual.
williamr@2
    45
williamr@2
    46
// Although basic_streambuf<> is not abstract, it is useful only as a base
williamr@2
    47
// class.  Its virtual member functions have default definitions such that
williamr@2
    48
// reading from a basic_streambuf<> will always yield EOF, and writing to a
williamr@2
    49
// basic_streambuf<> will always fail.
williamr@2
    50
williamr@2
    51
// The second template parameter, _Traits, defaults to char_traits<_CharT>.
williamr@2
    52
// The default is declared in header <iosfwd>, and it isn't declared here
williamr@2
    53
// because C++ language rules do not allow it to be declared twice. 
williamr@2
    54
williamr@2
    55
template <class _CharT, class _Traits>
williamr@2
    56
#ifdef __SYMBIAN32__
williamr@2
    57
class basic_streambuf 
williamr@2
    58
#else
williamr@2
    59
class basic_streambuf
williamr@2
    60
#endif
williamr@2
    61
{
williamr@2
    62
  friend class basic_istream<_CharT, _Traits>;
williamr@2
    63
  friend class basic_ostream<_CharT, _Traits>;
williamr@2
    64
williamr@2
    65
public:                         // Typedefs.
williamr@2
    66
  typedef _CharT                     char_type;
williamr@2
    67
  typedef typename _Traits::int_type int_type;
williamr@2
    68
  typedef typename _Traits::pos_type pos_type;
williamr@2
    69
  typedef typename _Traits::off_type off_type;
williamr@2
    70
  typedef _Traits                    traits_type;
williamr@2
    71
williamr@2
    72
private:                        // Data members.
williamr@2
    73
williamr@2
    74
  char_type* _M_gbegin;         // Beginning of get area
williamr@2
    75
  char_type* _M_gnext;          // Current position within the get area
williamr@2
    76
  char_type* _M_gend;           // End of get area
williamr@2
    77
williamr@2
    78
  char_type* _M_pbegin;         // Beginning of put area
williamr@2
    79
  char_type* _M_pnext;          // Current position within the put area
williamr@2
    80
  char_type* _M_pend;           // End of put area
williamr@2
    81
williamr@2
    82
  locale _M_locale;             // The streambuf's locale object
williamr@2
    83
williamr@2
    84
public:                         // Extension: locking, for thread safety.
williamr@2
    85
  _STLP_mutex _M_lock;
williamr@2
    86
williamr@2
    87
public:                         // Destructor.
williamr@2
    88
  _STLP_DECLSPEC virtual ~basic_streambuf();
williamr@2
    89
williamr@2
    90
protected:                      // The default constructor.
williamr@2
    91
  _STLP_DECLSPEC basic_streambuf();
williamr@2
    92
williamr@2
    93
protected:                      // Protected interface to the get area.
williamr@2
    94
  char_type* eback() const { return _M_gbegin; } // Beginning
williamr@2
    95
  char_type* gptr()  const { return _M_gnext; }  // Current position
williamr@2
    96
  char_type* egptr() const { return _M_gend; }   // End
williamr@2
    97
  
williamr@2
    98
  void gbump(int __n) { _M_gnext += __n; }
williamr@2
    99
  void setg(char_type* __gbegin, char_type* __gnext, char_type* __gend) {
williamr@2
   100
    _M_gbegin = __gbegin;
williamr@2
   101
    _M_gnext  = __gnext;
williamr@2
   102
    _M_gend   = __gend;
williamr@2
   103
  }
williamr@2
   104
williamr@2
   105
public:
williamr@2
   106
  // An alternate public interface to the above functions
williamr@2
   107
  // which allows us to avoid using templated friends which
williamr@2
   108
  // are not supported on some compilers.
williamr@2
   109
williamr@2
   110
  char_type* _M_eback() const { return eback(); }
williamr@2
   111
  char_type* _M_gptr()  const { return gptr(); }
williamr@2
   112
  char_type* _M_egptr() const { return egptr(); }
williamr@2
   113
  void _M_gbump(int __n)      { gbump(__n); }
williamr@2
   114
  void _M_setg(char_type* __gbegin, char_type* __gnext, char_type* __gend)
williamr@2
   115
    { setg(__gbegin, __gnext, __gend); }
williamr@2
   116
williamr@2
   117
protected:                      // Protected interface to the put area
williamr@2
   118
williamr@2
   119
  char_type* pbase() const { return _M_pbegin; } // Beginning
williamr@2
   120
  char_type* pptr()  const { return _M_pnext; }  // Current position
williamr@2
   121
  char_type* epptr() const { return _M_pend; }   // End
williamr@2
   122
williamr@2
   123
  void pbump(int __n) { _M_pnext += __n; }
williamr@2
   124
  void setp(char_type* __pbegin, char_type* __pend) {
williamr@2
   125
    _M_pbegin = __pbegin;
williamr@2
   126
    _M_pnext  = __pbegin;
williamr@2
   127
    _M_pend   = __pend;
williamr@2
   128
  }
williamr@2
   129
williamr@2
   130
protected:                      // Virtual buffer management functions.
williamr@2
   131
williamr@2
   132
  _STLP_DECLSPEC virtual basic_streambuf<_CharT, _Traits>* setbuf(char_type*, streamsize);
williamr@2
   133
williamr@2
   134
  // Alters the stream position, using an integer offset.  In this
williamr@2
   135
  // class seekoff does nothing; subclasses are expected to override it.
williamr@2
   136
  _STLP_DECLSPEC virtual pos_type seekoff(off_type, ios_base::seekdir,
williamr@2
   137
                           ios_base::openmode = ios_base::in | ios_base::out);
williamr@2
   138
williamr@2
   139
  // Alters the stream position, using a previously obtained streampos.  In
williamr@2
   140
  // this class seekpos does nothing; subclasses are expected to override it.
williamr@2
   141
  _STLP_DECLSPEC virtual pos_type
williamr@2
   142
  seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
williamr@2
   143
williamr@2
   144
  // Synchronizes (i.e. flushes) the buffer.  All subclasses are expected to 
williamr@2
   145
  // override this virtual member function.
williamr@2
   146
  _STLP_DECLSPEC virtual int sync();
williamr@2
   147
williamr@2
   148
williamr@2
   149
public:                         // Buffer management.
williamr@2
   150
  basic_streambuf<_CharT, _Traits>* pubsetbuf(char_type* __s, streamsize __n) 
williamr@2
   151
    { return this->setbuf(__s, __n); }
williamr@2
   152
williamr@2
   153
  pos_type pubseekoff(off_type __offset, ios_base::seekdir __way,
williamr@2
   154
                      ios_base::openmode __mod = ios_base::in | ios_base::out)
williamr@2
   155
    { return this->seekoff(__offset, __way, __mod); }
williamr@2
   156
williamr@2
   157
  pos_type pubseekpos(pos_type __sp,
williamr@2
   158
                      ios_base::openmode __mod = ios_base::in | ios_base::out)
williamr@2
   159
    { return this->seekpos(__sp, __mod); }
williamr@2
   160
williamr@2
   161
  int pubsync() { return this->sync(); }
williamr@2
   162
williamr@2
   163
protected:                      // Virtual get area functions, as defined in
williamr@2
   164
                                // 17.5.2.4.3 and 17.5.2.4.4 of the standard.
williamr@2
   165
  // Returns a lower bound on the number of characters that we can read,
williamr@2
   166
  // with underflow, before reaching end of file.  (-1 is a special value:
williamr@2
   167
  // it means that underflow will fail.)  Most subclasses should probably
williamr@2
   168
  // override this virtual member function.
williamr@2
   169
  _STLP_DECLSPEC virtual streamsize showmanyc();
williamr@2
   170
williamr@2
   171
  // Reads up to __n characters.  Return value is the number of 
williamr@2
   172
  // characters read.
williamr@2
   173
  _STLP_DECLSPEC virtual streamsize xsgetn(char_type* __s, streamsize __n);
williamr@2
   174
williamr@2
   175
  // Called when there is no read position, i.e. when gptr() is null
williamr@2
   176
  // or when gptr() >= egptr().  Subclasses are expected to override
williamr@2
   177
  // this virtual member function.
williamr@2
   178
  _STLP_DECLSPEC virtual int_type underflow();
williamr@2
   179
williamr@2
   180
  // Similar to underflow(), but used for unbuffered input.  Most 
williamr@2
   181
  // subclasses should probably override this virtual member function.
williamr@2
   182
  _STLP_DECLSPEC virtual int_type uflow();
williamr@2
   183
williamr@2
   184
  // Called when there is no putback position, i.e. when gptr() is null
williamr@2
   185
  // or when gptr() == eback().  All subclasses are expected to override
williamr@2
   186
  // this virtual member function.
williamr@2
   187
  _STLP_DECLSPEC virtual int_type pbackfail(int_type = traits_type::eof());
williamr@2
   188
williamr@2
   189
protected:                      // Virtual put area functions, as defined in
williamr@2
   190
                                // 27.5.2.4.5 of the standard.
williamr@2
   191
williamr@2
   192
  // Writes up to __n characters.  Return value is the number of characters
williamr@2
   193
  // written.
williamr@2
   194
  _STLP_DECLSPEC virtual streamsize xsputn(const char_type* __s, streamsize __n);
williamr@2
   195
williamr@2
   196
  // Extension: writes up to __n copies of __c.  Return value is the number
williamr@2
   197
  // of characters written.
williamr@2
   198
  _STLP_DECLSPEC virtual streamsize _M_xsputnc(char_type __c, streamsize __n);
williamr@2
   199
williamr@2
   200
  // Called when there is no write position.  All subclasses are expected to
williamr@2
   201
  // override this virtual member function.
williamr@2
   202
  _STLP_DECLSPEC virtual int_type overflow(int_type = traits_type::eof());
williamr@2
   203
williamr@2
   204
public:                         // Public members for writing characters.
williamr@2
   205
  // Write a single character.
williamr@2
   206
  int_type sputc(char_type __c) {
williamr@2
   207
    return ((_M_pnext < _M_pend) ? _Traits::to_int_type(*_M_pnext++ = __c)
williamr@2
   208
      : this->overflow(_Traits::to_int_type(__c)));
williamr@2
   209
  }
williamr@2
   210
williamr@2
   211
  // Write __n characters.
williamr@2
   212
  streamsize sputn(const char_type* __s, streamsize __n)
williamr@2
   213
    { return this->xsputn(__s, __n); }
williamr@2
   214
williamr@2
   215
  // Extension: write __n copies of __c.
williamr@2
   216
  streamsize _M_sputnc(char_type __c, streamsize __n)
williamr@2
   217
    { return this->_M_xsputnc(__c, __n); }
williamr@2
   218
williamr@2
   219
private:                        // Helper functions.
williamr@2
   220
  _STLP_DECLSPEC int_type _M_snextc_aux();
williamr@2
   221
williamr@2
   222
williamr@2
   223
public:                         // Public members for reading characters.
williamr@2
   224
  streamsize in_avail() {
williamr@2
   225
    return (_M_gnext < _M_gend) ? (_M_gend - _M_gnext) : this->showmanyc();
williamr@2
   226
  }
williamr@2
   227
  
williamr@2
   228
  // Advance to the next character and return it.
williamr@2
   229
  int_type snextc() {
williamr@2
   230
	return ( _M_gend - _M_gnext > 1 ?
williamr@2
   231
             _Traits::to_int_type(*++_M_gnext) :
williamr@2
   232
             this->_M_snextc_aux());
williamr@2
   233
  }
williamr@2
   234
williamr@2
   235
  // Return the current character and advance to the next.
williamr@2
   236
  int_type sbumpc() {
williamr@2
   237
    return _M_gnext < _M_gend ? _Traits::to_int_type(*_M_gnext++) 
williamr@2
   238
      : this->uflow();
williamr@2
   239
  }
williamr@2
   240
  
williamr@2
   241
  // Return the current character without advancing to the next.
williamr@2
   242
  int_type sgetc() {
williamr@2
   243
    return _M_gnext < _M_gend ? _Traits::to_int_type(*_M_gnext) 
williamr@2
   244
      : this->underflow();
williamr@2
   245
  }
williamr@2
   246
  
williamr@2
   247
  streamsize sgetn(char_type* __s, streamsize __n)
williamr@2
   248
  { return this->xsgetn(__s, __n); }
williamr@2
   249
  
williamr@2
   250
  int_type sputbackc(char_type __c) {
williamr@2
   251
    return ((_M_gbegin < _M_gnext) && _Traits::eq(__c, *(_M_gnext - 1)))
williamr@2
   252
      ? _Traits::to_int_type(*--_M_gnext)
williamr@2
   253
      : this->pbackfail(_Traits::to_int_type(__c));
williamr@2
   254
  }
williamr@2
   255
  
williamr@2
   256
  int_type sungetc() {
williamr@2
   257
    return (_M_gbegin < _M_gnext)
williamr@2
   258
      ? _Traits::to_int_type(*--_M_gnext)
williamr@2
   259
      : this->pbackfail();
williamr@2
   260
  }
williamr@2
   261
williamr@2
   262
protected:                      // Virtual locale functions.
williamr@2
   263
williamr@2
   264
  // This is a hook, called by pubimbue() just before pubimbue()
williamr@2
   265
  // sets the streambuf's locale to __loc.  Note that imbue should
williamr@2
   266
  // not (and cannot, since it has no access to streambuf's private
williamr@2
   267
  // members) set the streambuf's locale itself.
williamr@2
   268
  _STLP_DECLSPEC virtual void imbue(const locale&);
williamr@2
   269
williamr@2
   270
public:                         // Locale-related functions.
williamr@2
   271
  _STLP_DECLSPEC locale pubimbue(const locale&);
williamr@2
   272
  locale getloc() const { return _M_locale; }
williamr@2
   273
williamr@2
   274
# ifndef _STLP_NO_ANACHRONISMS
williamr@2
   275
  void stossc() { this->sbumpc(); }
williamr@2
   276
# endif
williamr@2
   277
#if defined(__MVS__) || defined(__OS400__)
williamr@2
   278
private: // Data members.
williamr@2
   279
williamr@2
   280
  char_type* _M_gbegin; // Beginning of get area
williamr@2
   281
  char_type* _M_gnext; // Current position within the get area
williamr@2
   282
  char_type* _M_gend; // End of get area
williamr@2
   283
williamr@2
   284
  char_type* _M_pbegin; // Beginning of put area
williamr@2
   285
  char_type* _M_pnext; // Current position within the put area
williamr@2
   286
  char_type* _M_pend; // End of put area
williamr@2
   287
#endif
williamr@2
   288
};
williamr@2
   289
williamr@2
   290
williamr@2
   291
//----------------------------------------------------------------------
williamr@2
   292
// Specialization: basic_streambuf<char, char_traits<char> >
williamr@2
   293
williamr@2
   294
// We implement basic_streambuf<char, char_traits<char> > very differently
williamr@2
   295
// than the general basic_streambuf<> template.  The main reason for this
williamr@2
   296
// difference is a requirement in the C++ standard: the standard input
williamr@2
   297
// and output streams cin and cout are required by default to be synchronized
williamr@2
   298
// with the C library components stdin and stdout.  This means it must be
williamr@2
   299
// possible to synchronize a basic_streambuf<char> with a C buffer.
williamr@2
   300
//
williamr@2
   301
// There are two basic ways to do that.  First, the streambuf could be
williamr@2
   302
// unbuffered and delegate all buffering to stdio operations.  This
williamr@2
   303
// would be correct, but slow: it would require at least one virtual
williamr@2
   304
// function call for every character.  Second, the streambuf could use 
williamr@2
   305
// a C stdio FILE as its buffer.  
williamr@2
   306
//
williamr@2
   307
// We choose the latter option.  Every streambuf has pointers to two
williamr@2
   308
// FILE objects, one for the get area and one for the put area.  Ordinarily
williamr@2
   309
// it just uses a FILE object as a convenient way to package the three
williamr@2
   310
// get/put area pointers.  If a basic_streambuf<char> is synchronized with
williamr@2
   311
// a stdio stream, though, then the pointers are to a FILE object that's
williamr@2
   312
// also used by the C library.
williamr@2
   313
//
williamr@2
   314
// The header <stl/_stdio_file.h> encapsulates the implementation details
williamr@2
   315
// of struct FILE.  It contains low-level inline functions that convert
williamr@2
   316
// between whe FILE's internal representation and the three-pointer 
williamr@2
   317
// representation that basic_streambuf<> needs.
williamr@2
   318
williamr@2
   319
_STLP_TEMPLATE_NULL 
williamr@2
   320
#ifdef __SYMBIAN32__
williamr@2
   321
class basic_streambuf<char, char_traits<char> >
williamr@2
   322
#else
williamr@2
   323
class _STLP_CLASS_DECLSPEC basic_streambuf<char, char_traits<char> >
williamr@2
   324
#endif
williamr@2
   325
{
williamr@2
   326
  friend class basic_istream<char, char_traits<char> >;
williamr@2
   327
  friend class basic_ostream<char, char_traits<char> >;
williamr@2
   328
public:                         // Typedefs.
williamr@2
   329
  typedef char                        char_type;
williamr@2
   330
  typedef char_traits<char>::int_type int_type;
williamr@2
   331
  typedef char_traits<char>::pos_type pos_type;
williamr@2
   332
  typedef char_traits<char>::off_type off_type;
williamr@2
   333
  typedef char_traits<char>           traits_type;
williamr@2
   334
williamr@2
   335
private:                        // Data members.
williamr@2
   336
williamr@2
   337
  FILE* _M_get;                 // Reference to the get area
williamr@2
   338
  FILE* _M_put;                 // Reference to the put area
williamr@2
   339
williamr@2
   340
#if defined(__hpux)
williamr@2
   341
  _FILEX  _M_default_get;          // Get area, unless we're syncing with stdio.
williamr@2
   342
  _FILEX  _M_default_put;          // Put area, unless we're syncing with stdio.
williamr@2
   343
#else
williamr@2
   344
  FILE  _M_default_get;          // Get area, unless we're syncing with stdio.
williamr@2
   345
  FILE  _M_default_put;          // Put area, unless we're syncing with stdio.
williamr@2
   346
#endif
williamr@2
   347
williamr@2
   348
  locale _M_locale;
williamr@2
   349
williamr@2
   350
public:                         // Extension: locking, for thread safety.
williamr@2
   351
  _STLP_mutex _M_lock;
williamr@2
   352
williamr@2
   353
public:                         // Destructor.
williamr@2
   354
  _STLP_DECLSPEC virtual ~basic_streambuf _STLP_PSPEC2(char, char_traits<char>) ();
williamr@2
   355
williamr@2
   356
public:
williamr@2
   357
  // The default constructor; defined here inline as some compilers require it
williamr@2
   358
  _STLP_DECLSPEC basic_streambuf _STLP_PSPEC2(char, char_traits<char>) ();
williamr@2
   359
  // Extension: a constructor for streambufs synchronized with C stdio files.
williamr@2
   360
  _STLP_DECLSPEC basic_streambuf _STLP_PSPEC2(char, char_traits<char>) (FILE* __get, FILE* __put);
williamr@2
   361
williamr@2
   362
protected:                      // Protected interface to the get area.
williamr@2
   363
  char_type* eback() const { return _FILE_I_begin(_M_get); }
williamr@2
   364
  char_type* gptr()  const { return _FILE_I_next(_M_get); }
williamr@2
   365
  char_type* egptr() const { return _FILE_I_end(_M_get); }
williamr@2
   366
  void gbump(int __n) { _FILE_I_bump(_M_get, __n); }
williamr@2
   367
  void setg(char_type* __gbegin, char_type* __gnext, char_type* __gend)
williamr@2
   368
    { 
williamr@2
   369
    _FILE_I_set(_M_get, __gbegin, __gnext, __gend); 
williamr@2
   370
#ifdef __SYMBIAN32__
williamr@2
   371
    _change_input_mode();
williamr@2
   372
#endif
williamr@2
   373
    }
williamr@2
   374
williamr@2
   375
public:
williamr@2
   376
  // An alternate public interface to the above functions
williamr@2
   377
  // which allows us to avoid using templated friends which
williamr@2
   378
  // are not supported on some compilers.
williamr@2
   379
williamr@2
   380
  char_type* _M_eback() const { return _FILE_I_begin(_M_get); }
williamr@2
   381
  char_type* _M_gptr()  const { return _FILE_I_next(_M_get); }
williamr@2
   382
  char_type* _M_egptr() const { return _FILE_I_end(_M_get); }
williamr@2
   383
williamr@2
   384
  void _M_gbump(int __n) { _FILE_I_bump(_M_get, __n); }
williamr@2
   385
  void _M_setg(char_type* __gbegin, char_type* __gnext, char_type* __gend)
williamr@2
   386
    { _FILE_I_set(_M_get, __gbegin, __gnext, __gend); }
williamr@2
   387
williamr@2
   388
protected:                      // Protected interface to the put area
williamr@2
   389
  char_type* pbase() const { return _FILE_O_begin(_M_put); }
williamr@2
   390
  char_type* pptr()  const { return _FILE_O_next(_M_put); }
williamr@2
   391
  char_type* epptr() const { return _FILE_O_end(_M_put); }
williamr@2
   392
williamr@2
   393
  void pbump(int __n) { _FILE_O_bump(_M_put, __n); }
williamr@2
   394
  void setp(char_type* __pbegin, char_type* __pend)
williamr@2
   395
    { _FILE_O_set(_M_put, __pbegin, __pbegin, __pend); }
williamr@2
   396
williamr@2
   397
protected:                      // Virtual buffer-management functions.
williamr@2
   398
  _STLP_DECLSPEC virtual basic_streambuf<char, char_traits<char> >* setbuf(char_type*, streamsize);
williamr@2
   399
  _STLP_DECLSPEC virtual pos_type seekoff(off_type, ios_base::seekdir,
williamr@2
   400
                           ios_base::openmode = ios_base::in | ios_base::out);
williamr@2
   401
  _STLP_DECLSPEC  virtual pos_type
williamr@2
   402
  seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
williamr@2
   403
  _STLP_DECLSPEC virtual int sync();
williamr@2
   404
williamr@2
   405
public:                         // Buffer management.
williamr@2
   406
  basic_streambuf<char, char_traits<char> >* pubsetbuf(char_type* __s, streamsize __n) 
williamr@2
   407
    { return this->setbuf(__s, __n); }
williamr@2
   408
williamr@2
   409
  pos_type pubseekoff(off_type __offset, ios_base::seekdir __way,
williamr@2
   410
                      ios_base::openmode __mod = ios_base::in | ios_base::out)
williamr@2
   411
    { return this->seekoff(__offset, __way, __mod); }
williamr@2
   412
williamr@2
   413
  pos_type pubseekpos(pos_type __sp,
williamr@2
   414
                      ios_base::openmode __mod = ios_base::in | ios_base::out)
williamr@2
   415
    { return this->seekpos(__sp, __mod); }
williamr@2
   416
williamr@2
   417
  int pubsync() { return this->sync(); }
williamr@2
   418
williamr@2
   419
protected:                      // Virtual get area functions.
williamr@2
   420
  _STLP_DECLSPEC virtual streamsize showmanyc();
williamr@2
   421
  _STLP_DECLSPEC virtual streamsize xsgetn(char_type* __s, streamsize __n);
williamr@2
   422
  _STLP_DECLSPEC virtual int_type underflow();
williamr@2
   423
  _STLP_DECLSPEC virtual int_type uflow();
williamr@2
   424
  _STLP_DECLSPEC virtual int_type pbackfail(int_type __c = traits_type::eof());
williamr@2
   425
williamr@2
   426
protected:                      // Virtual put area functions.
williamr@2
   427
  _STLP_DECLSPEC virtual streamsize xsputn(const char_type* __s, streamsize __n);
williamr@2
   428
  _STLP_DECLSPEC virtual streamsize _M_xsputnc(char_type __c, streamsize __n);
williamr@2
   429
  _STLP_DECLSPEC virtual int_type overflow(int_type = traits_type::eof());
williamr@2
   430
#ifdef __SYMBIAN32__  
williamr@2
   431
  virtual int save_read_buffer () { return 0; }
williamr@2
   432
  virtual void _change_input_mode() {};
williamr@2
   433
#endif
williamr@2
   434
public:                         // Public members for writing characters.
williamr@2
   435
  // Write a single character.
williamr@2
   436
  int_type sputc(char_type __c) {
williamr@2
   437
    int_type __res;
williamr@2
   438
	if( _FILE_O_avail(_M_put) > 0 )
williamr@2
   439
	{
williamr@2
   440
		_FILE_O_postincr(_M_put) = __c;
williamr@2
   441
		__res = traits_type::to_int_type(__c);
williamr@2
   442
	}
williamr@2
   443
	else
williamr@2
   444
      __res = this->overflow(traits_type::to_int_type(__c));
williamr@2
   445
    return __res;
williamr@2
   446
  }
williamr@2
   447
williamr@2
   448
  // Write __n characters.
williamr@2
   449
  streamsize sputn(const char_type* __s, streamsize __n)
williamr@2
   450
    { return this->xsputn(__s, __n); }
williamr@2
   451
williamr@2
   452
  // Extension: write __n copies of __c.
williamr@2
   453
  streamsize _M_sputnc(char_type __c, streamsize __n)
williamr@2
   454
    { return this->_M_xsputnc(__c, __n); }
williamr@2
   455
williamr@2
   456
private:                        // Helper functions.
williamr@2
   457
  _STLP_DECLSPEC int_type _M_snextc_aux();
williamr@2
   458
williamr@2
   459
public:                         // Public members for reading characters.
williamr@2
   460
  streamsize in_avail()
williamr@2
   461
    { return _FILE_I_avail(_M_get) > 0 ? _FILE_I_avail(_M_get)
williamr@2
   462
#ifdef __SYMBIAN32__  
williamr@2
   463
                                     + save_read_buffer()
williamr@2
   464
#endif
williamr@2
   465
                                     : this->showmanyc(); }
williamr@2
   466
  
williamr@2
   467
  // Advance to the next character and return it.
williamr@2
   468
  int_type snextc() {
williamr@2
   469
    return _FILE_I_avail(_M_get) > 1
williamr@2
   470
      ? traits_type::to_int_type(_FILE_I_preincr(_M_get))
williamr@2
   471
      : this->_M_snextc_aux();
williamr@2
   472
  }
williamr@2
   473
williamr@2
   474
  // Return the current character and advance to the next.
williamr@2
   475
  int_type sbumpc() {
williamr@2
   476
    return _FILE_I_avail(_M_get) > 0
williamr@2
   477
      ? traits_type::to_int_type(_FILE_I_postincr(_M_get))
williamr@2
   478
      : this->uflow();
williamr@2
   479
  }
williamr@2
   480
williamr@2
   481
  // Return the current character without advancing to the next.
williamr@2
   482
  int_type sgetc() {
williamr@2
   483
    return _FILE_I_avail(_M_get) > 0
williamr@2
   484
      ? traits_type::to_int_type(*_FILE_I_next(_M_get))
williamr@2
   485
      : this->underflow();
williamr@2
   486
  }
williamr@2
   487
    
williamr@2
   488
  streamsize sgetn(char_type* __s, streamsize __n)
williamr@2
   489
    { return this->xsgetn(__s, __n); }
williamr@2
   490
williamr@2
   491
  int_type sputbackc(char_type __c) {
williamr@2
   492
    return _FILE_I_begin(_M_get) < _FILE_I_next(_M_get) &&
williamr@2
   493
           __c == *(_FILE_I_next(_M_get) - 1)
williamr@2
   494
      ? traits_type::to_int_type(_FILE_I_predecr(_M_get))
williamr@2
   495
      : this->pbackfail(traits_type::to_int_type(__c));
williamr@2
   496
  }
williamr@2
   497
williamr@2
   498
  int_type sungetc() {
williamr@2
   499
    return _FILE_I_begin(_M_get) < _FILE_I_next(_M_get)
williamr@2
   500
      ? traits_type::to_int_type(_FILE_I_predecr(_M_get))
williamr@2
   501
      : this->pbackfail();
williamr@2
   502
  }
williamr@2
   503
williamr@2
   504
protected:                      // Virtual locale functions.
williamr@2
   505
  _STLP_DECLSPEC virtual void imbue(const locale&);
williamr@2
   506
public:                         // Locale-related functions.
williamr@2
   507
  _STLP_DECLSPEC locale pubimbue(const locale&);
williamr@2
   508
  locale getloc() const { return _M_locale; }
williamr@2
   509
williamr@2
   510
# ifndef _STLP_NO_ANACHRONISMS
williamr@2
   511
public:
williamr@2
   512
  void stossc() { this->sbumpc(); }
williamr@2
   513
# endif
williamr@2
   514
williamr@2
   515
#if defined(__MVS__) || defined(__OS400__)
williamr@2
   516
private: // Data members.
williamr@2
   517
williamr@2
   518
  char_type* _M_gbegin; // Beginning of get area
williamr@2
   519
  char_type* _M_gnext; // Current position within the get area
williamr@2
   520
  char_type* _M_gend; // End of get area
williamr@2
   521
williamr@2
   522
  char_type* _M_pbegin; // Beginning of put area
williamr@2
   523
  char_type* _M_pnext; // Current position within the put area
williamr@2
   524
  char_type* _M_pend; // End of put area
williamr@2
   525
#endif
williamr@2
   526
williamr@2
   527
};
williamr@2
   528
_STLP_END_NAMESPACE
williamr@2
   529
williamr@2
   530
# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
williamr@2
   531
#  include <stl/_streambuf.c>
williamr@2
   532
# endif
williamr@2
   533
williamr@2
   534
#endif
williamr@2
   535
// Local Variables:
williamr@2
   536
// mode:C++
williamr@2
   537
// End: