00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
#ifndef __SGI_STL_STRSTREAM
00049
#define __SGI_STL_STRSTREAM
00050
00051
#include "backward_warning.h"
00052
#include <iosfwd>
00053
#include <ios>
00054
#include <istream>
00055
#include <ostream>
00056
#include <string>
00057
00058
namespace std
00059 {
00060
00061
00062
class strstreambuf :
public basic_streambuf<char, char_traits<char> >
00063 {
00064
public:
00065
00066
typedef char_traits<char> _Traits;
00067
typedef basic_streambuf<char, _Traits> _Base;
00068
00069
public:
00070
00071
explicit strstreambuf(streamsize __initial_capacity = 0);
00072 strstreambuf(
void* (*__alloc)(size_t),
void (*__free)(
void*));
00073
00074 strstreambuf(
char* __get, streamsize __n,
char* __put = 0);
00075 strstreambuf(
signed char* __get, streamsize __n,
signed char* __put = 0);
00076 strstreambuf(
unsigned char* __get, streamsize __n,
unsigned char* __put=0);
00077
00078 strstreambuf(
const char* __get, streamsize __n);
00079 strstreambuf(
const signed char* __get, streamsize __n);
00080 strstreambuf(
const unsigned char* __get, streamsize __n);
00081
00082
virtual ~strstreambuf();
00083
00084
public:
00085
void freeze(
bool =
true);
00086
char* str();
00087
int pcount() const;
00088
00089 protected:
00090 virtual int_type overflow(int_type __c = _Traits::eof());
00091 virtual int_type pbackfail(int_type __c = _Traits::eof());
00092 virtual int_type underflow();
00093 virtual _Base* setbuf(
char* __buf, streamsize __n);
00094 virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
00095 ios_base::openmode __mode
00096 = ios_base::in | ios_base::out);
00097 virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
00098 = ios_base::in | ios_base::out);
00099
00100 private:
00101
00102
char* _M_alloc(size_t);
00103
void _M_free(
char*);
00104
00105
00106
void _M_setup(
char* __get,
char* __put, streamsize __n);
00107
00108 private:
00109
00110
void* (*_M_alloc_fun)(size_t);
00111
void (*_M_free_fun)(
void*);
00112
00113
bool _M_dynamic : 1;
00114
bool _M_frozen : 1;
00115
bool _M_constant : 1;
00116 };
00117
00118
00119 class istrstream : public basic_istream<
char>
00120 {
00121
public:
00122
explicit istrstream(
char*);
00123
explicit istrstream(
const char*);
00124 istrstream(
char* , streamsize);
00125 istrstream(
const char*, streamsize);
00126
virtual ~istrstream();
00127
00128 strstreambuf* rdbuf() const;
00129
char* str();
00130
00131 private:
00132 strstreambuf _M_buf;
00133 };
00134
00135
00136 class ostrstream : public basic_ostream<
char>
00137 {
00138
public:
00139 ostrstream();
00140 ostrstream(
char*,
int, ios_base::openmode = ios_base::out);
00141
virtual ~ostrstream();
00142
00143 strstreambuf* rdbuf() const;
00144
void freeze(
bool = true);
00145
char* str();
00146
int pcount() const;
00147
00148 private:
00149 strstreambuf _M_buf;
00150 };
00151
00152
00153 class strstream : public basic_iostream<
char>
00154 {
00155
public:
00156
typedef char char_type;
00157
typedef char_traits<char>::int_type int_type;
00158
typedef char_traits<char>::pos_type pos_type;
00159
typedef char_traits<char>::off_type off_type;
00160
00161 strstream();
00162 strstream(
char*,
int, ios_base::openmode = ios_base::in | ios_base::out);
00163
virtual ~strstream();
00164
00165 strstreambuf* rdbuf() const;
00166
void freeze(
bool = true);
00167
int pcount() const;
00168
char* str();
00169
00170 private:
00171 strstreambuf _M_buf;
00172 };
00173 }
00174 #endif