epoc32/include/tools/stlport/stl/_strstream.h
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
 * Copyright (c) 1999
williamr@4
     3
 * Silicon Graphics Computer Systems, Inc.
williamr@4
     4
 *
williamr@4
     5
 * Copyright (c) 1999
williamr@4
     6
 * Boris Fomitchev
williamr@4
     7
 *
williamr@4
     8
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
     9
 * or implied. Any use is at your own risk.
williamr@4
    10
 *
williamr@4
    11
 * Permission to use or copy this software for any purpose is hereby granted
williamr@4
    12
 * without fee, provided the above notices are retained on all copies.
williamr@4
    13
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    14
 * provided the above notices are retained, and a notice that the code was
williamr@4
    15
 * modified is included with the above copyright notice.
williamr@4
    16
 *
williamr@4
    17
 */
williamr@4
    18
#ifndef _STLP_INTERNAL_STRSTREAM
williamr@4
    19
#define _STLP_INTERNAL_STRSTREAM
williamr@4
    20
williamr@4
    21
#ifndef _STLP_INTERNAL_STREAMBUF
williamr@4
    22
#  include <stl/_streambuf.h>
williamr@4
    23
#endif
williamr@4
    24
williamr@4
    25
#ifndef _STLP_INTERNAL_ISTREAM
williamr@4
    26
#  include <stl/_istream.h>              // Includes <ostream>, <ios>, <iosfwd>
williamr@4
    27
#endif
williamr@4
    28
williamr@4
    29
#ifndef _STLP_INTERNAL_STRING_H
williamr@4
    30
#  include <stl/_string.h>
williamr@4
    31
#endif
williamr@4
    32
williamr@4
    33
_STLP_BEGIN_NAMESPACE
williamr@4
    34
williamr@4
    35
#ifndef _STLP_USE_NAMESPACES
williamr@4
    36
#  define strstream _STLP_strstream
williamr@4
    37
#  define ostrstream _STLP_ostrstream
williamr@4
    38
#  define istrstream _STLP_istrstream
williamr@4
    39
#  define strstreambuf _STLP_strstreambuf
williamr@4
    40
#endif
williamr@4
    41
williamr@4
    42
//----------------------------------------------------------------------
williamr@4
    43
// Class strstreambuf, a streambuf class that manages an array of char.
williamr@4
    44
// Note that this class is not a template.
williamr@4
    45
williamr@4
    46
class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf<char, char_traits<char> > {
williamr@4
    47
public:                         // Types.
williamr@4
    48
  typedef char_traits<char>              _Traits;
williamr@4
    49
  typedef basic_streambuf<char, char_traits<char> > _Base;
williamr@4
    50
  typedef void* (*__alloc_fn)(size_t);
williamr@4
    51
  typedef void (*__free_fn)(void*);
williamr@4
    52
public:                         // Constructor, destructor
williamr@4
    53
williamr@4
    54
  explicit strstreambuf(streamsize _Initial_capacity = 0);
williamr@4
    55
williamr@4
    56
  strstreambuf(__alloc_fn, __free_fn);
williamr@4
    57
williamr@4
    58
  strstreambuf(char* __get, streamsize __n, char* __put = 0);
williamr@4
    59
  strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0);
williamr@4
    60
  strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
williamr@4
    61
williamr@4
    62
  strstreambuf(const char* __get, streamsize __n);
williamr@4
    63
  strstreambuf(const signed char* __get, streamsize __n);
williamr@4
    64
  strstreambuf(const unsigned char* __get, streamsize __n);
williamr@4
    65
williamr@4
    66
  virtual ~strstreambuf();
williamr@4
    67
williamr@4
    68
public:                         // strstreambuf operations.
williamr@4
    69
  void freeze(bool = true);
williamr@4
    70
  char* str();
williamr@4
    71
  int pcount() const;
williamr@4
    72
williamr@4
    73
protected:                      // Overridden virtual member functions.
williamr@4
    74
  virtual int_type overflow(int_type __c  = _Traits::eof());
williamr@4
    75
  virtual int_type pbackfail(int_type __c = _Traits::eof());
williamr@4
    76
  virtual int_type underflow();
williamr@4
    77
  virtual _Base* setbuf(char* __buf, streamsize __n);
williamr@4
    78
  virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
williamr@4
    79
                           ios_base::openmode __mode
williamr@4
    80
                                      = ios_base::in | ios_base::out);
williamr@4
    81
  virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
williamr@4
    82
                                      = ios_base::in | ios_base::out);
williamr@4
    83
williamr@4
    84
private:                        // Helper functions.
williamr@4
    85
  // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun.
williamr@4
    86
  char* _M_alloc(size_t);
williamr@4
    87
  void  _M_free(char*);
williamr@4
    88
williamr@4
    89
  // Helper function used in constructors.
williamr@4
    90
  void _M_setup(char* __get, char* __put, streamsize __n);
williamr@4
    91
private:                        // Data members.
williamr@4
    92
  __alloc_fn _M_alloc_fun;
williamr@4
    93
  __free_fn  _M_free_fun;
williamr@4
    94
  bool _M_dynamic  : 1;
williamr@4
    95
  bool _M_frozen   : 1;
williamr@4
    96
  bool _M_constant : 1;
williamr@4
    97
};
williamr@4
    98
williamr@4
    99
//----------------------------------------------------------------------
williamr@4
   100
// Class istrstream, an istream that manages a strstreambuf.
williamr@4
   101
williamr@4
   102
class _STLP_CLASS_DECLSPEC istrstream : public basic_istream<char, char_traits<char> > {
williamr@4
   103
public:
williamr@4
   104
  explicit istrstream(char*);
williamr@4
   105
  explicit istrstream(const char*);
williamr@4
   106
  istrstream(char* , streamsize);
williamr@4
   107
  istrstream(const char*, streamsize);
williamr@4
   108
  virtual ~istrstream();
williamr@4
   109
williamr@4
   110
  strstreambuf* rdbuf() const;
williamr@4
   111
  char* str();
williamr@4
   112
williamr@4
   113
private:
williamr@4
   114
  strstreambuf _M_buf;
williamr@4
   115
};
williamr@4
   116
williamr@4
   117
//----------------------------------------------------------------------
williamr@4
   118
// Class ostrstream
williamr@4
   119
williamr@4
   120
class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream<char, char_traits<char> >
williamr@4
   121
{
williamr@4
   122
public:
williamr@4
   123
  ostrstream();
williamr@4
   124
  ostrstream(char*, int, ios_base::openmode = ios_base::out);
williamr@4
   125
  virtual ~ostrstream();
williamr@4
   126
williamr@4
   127
  strstreambuf* rdbuf() const;
williamr@4
   128
  void freeze(bool = true);
williamr@4
   129
  char* str();
williamr@4
   130
  int pcount() const;
williamr@4
   131
williamr@4
   132
private:
williamr@4
   133
  strstreambuf _M_buf;
williamr@4
   134
};
williamr@4
   135
williamr@4
   136
//----------------------------------------------------------------------
williamr@4
   137
// Class strstream
williamr@4
   138
williamr@4
   139
class _STLP_CLASS_DECLSPEC strstream : public basic_iostream<char, char_traits<char> > {
williamr@4
   140
public:
williamr@4
   141
  typedef char                        char_type;
williamr@4
   142
  typedef char_traits<char>::int_type int_type;
williamr@4
   143
  typedef char_traits<char>::pos_type pos_type;
williamr@4
   144
  typedef char_traits<char>::off_type off_type;
williamr@4
   145
williamr@4
   146
  strstream();
williamr@4
   147
  strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out);
williamr@4
   148
  virtual ~strstream();
williamr@4
   149
williamr@4
   150
  strstreambuf* rdbuf() const;
williamr@4
   151
  void freeze(bool = true);
williamr@4
   152
  int pcount() const;
williamr@4
   153
  char* str();
williamr@4
   154
williamr@4
   155
private:
williamr@4
   156
  strstreambuf _M_buf;
williamr@4
   157
williamr@4
   158
  //explicitely defined as private to avoid warnings:
williamr@4
   159
  strstream(strstream const&);
williamr@4
   160
  strstream& operator = (strstream const&);
williamr@4
   161
};
williamr@4
   162
williamr@4
   163
_STLP_END_NAMESPACE
williamr@4
   164
williamr@4
   165
#endif /* _STLP_INTERNAL_STRSTREAM */