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 #ifndef __SGI_STL_STRSTREAM_W_COMPAT_
00034 #define __SGI_STL_STRSTREAM_W_COMPAT_
00035
00036 #if defined(__sgi) && !defined(__GNUC__) && !defined(_STANDARD_C_PLUS_PLUS)
00037 #error This header file requires the -LANG:std option
00038 #endif
00039
00040 #include <istream>
00041 #include <streambuf>
00042 #include <ostream>
00043 #include <iostream>
00044 #include <ios>
00045
00046
00047
00048 namespace shore_compat {
00049
00050 using namespace std;
00051
00052
00053
00054
00055
00056
00057 class strstreambuf : public basic_streambuf<char, char_traits<char> >
00058 {
00059 public:
00060 typedef char_traits<char> _Traits;
00061 typedef basic_streambuf<char, _Traits> _Base;
00062
00063 public:
00064 explicit strstreambuf(streamsize __initial_capacity = 0);
00065 strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*));
00066
00067 strstreambuf(char* __get, streamsize __n, char* __put = 0);
00068 strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0);
00069 strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
00070
00071 strstreambuf(const char* __get, streamsize __n);
00072 strstreambuf(const signed char* __get, streamsize __n);
00073 strstreambuf(const unsigned char* __get, streamsize __n);
00074
00075 virtual ~strstreambuf();
00076
00077 public:
00078 char* str();
00079 int pcount() const;
00080
00081 protected:
00082 virtual int_type overflow(int_type __c = _Traits::eof());
00083 virtual int_type pbackfail(int_type __c = _Traits::eof());
00084 virtual int_type underflow();
00085 virtual _Base* setbuf(char* __buf, streamsize __n);
00086 virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
00087 ios_base::openmode __mode
00088 = ios_base::in | ios_base::out);
00089 virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
00090 = ios_base::in | ios_base::out);
00091
00092 private:
00093
00094 char* _M_alloc(size_t);
00095 void _M_free(char*);
00096
00097
00098 void _M_setup(char* __get, char* __put, streamsize __n);
00099
00100 private:
00101 void* (*_M_alloc_fun)(size_t);
00102 void (*_M_free_fun)(void*);
00103
00104 bool _M_dynamic : 1;
00105 bool _M_constant : 1;
00106 };
00107
00108
00109 class istrstream : public std::basic_istream<char, std::char_traits<char> >
00110 {
00111 public:
00112 explicit istrstream(char*);
00113 explicit istrstream(const char*);
00114 istrstream(char* , streamsize);
00115 istrstream(const char*, streamsize);
00116 virtual ~istrstream();
00117
00118 strstreambuf* rdbuf() const;
00119 char* str();
00120
00121 private:
00122 strstreambuf _M_buf;
00123 };
00124
00125
00126
00127 class ostrstream : public std::basic_ostream<char, std::char_traits<char> >
00128 {
00129 public:
00130 ostrstream();
00131 ostrstream(char*, int, ios_base::openmode = ios_base::out);
00132 virtual ~ostrstream();
00133
00134 strstreambuf* rdbuf() const;
00135 char* str();
00136 int pcount() const;
00137
00138 private:
00139 strstreambuf _M_buf;
00140 };
00141
00142
00143 }
00144
00145 #endif