/home/ntakagi/work/STLport-5.1.5/stlport/stl/_strstream.hGo to the documentation of this file.00001 /* 00002 * Copyright (c) 1999 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Copyright (c) 1999 00006 * Boris Fomitchev 00007 * 00008 * This material is provided "as is", with absolutely no warranty expressed 00009 * or implied. Any use is at your own risk. 00010 * 00011 * Permission to use or copy this software for any purpose is hereby granted 00012 * without fee, provided the above notices are retained on all copies. 00013 * Permission to modify the code and to distribute modified code is granted, 00014 * provided the above notices are retained, and a notice that the code was 00015 * modified is included with the above copyright notice. 00016 * 00017 */ 00018 #ifndef _STLP_INTERNAL_STRSTREAM 00019 #define _STLP_INTERNAL_STRSTREAM 00020 00021 #ifndef _STLP_INTERNAL_STREAMBUF 00022 # include <stl/_streambuf.h> 00023 #endif 00024 00025 #ifndef _STLP_INTERNAL_ISTREAM 00026 # include <stl/_istream.h> // Includes <ostream>, <ios>, <iosfwd> 00027 #endif 00028 00029 #ifndef _STLP_INTERNAL_STRING_H 00030 # include <stl/_string.h> 00031 #endif 00032 00033 _STLP_BEGIN_NAMESPACE 00034 00035 #ifndef _STLP_USE_NAMESPACES 00036 # define strstream _STLP_strstream 00037 # define ostrstream _STLP_ostrstream 00038 # define istrstream _STLP_istrstream 00039 # define strstreambuf _STLP_strstreambuf 00040 #endif 00041 00042 //---------------------------------------------------------------------- 00043 // Class strstreambuf, a streambuf class that manages an array of char. 00044 // Note that this class is not a template. 00045 00046 class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf<char, char_traits<char> > { 00047 public: // Types. 00048 typedef char_traits<char> _Traits; 00049 typedef basic_streambuf<char, char_traits<char> > _Base; 00050 typedef void* (*__alloc_fn)(size_t); 00051 typedef void (*__free_fn)(void*); 00052 public: // Constructor, destructor 00053 00054 explicit strstreambuf(streamsize _Initial_capacity = 0); 00055 00056 strstreambuf(__alloc_fn, __free_fn); 00057 00058 strstreambuf(char* __get, streamsize __n, char* __put = 0); 00059 strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0); 00060 strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0); 00061 00062 strstreambuf(const char* __get, streamsize __n); 00063 strstreambuf(const signed char* __get, streamsize __n); 00064 strstreambuf(const unsigned char* __get, streamsize __n); 00065 00066 virtual ~strstreambuf(); 00067 00068 public: // strstreambuf operations. 00069 void freeze(bool = true); 00070 char* str(); 00071 int pcount() const; 00072 00073 protected: // Overridden virtual member functions. 00074 virtual int_type overflow(int_type __c = _Traits::eof()); 00075 virtual int_type pbackfail(int_type __c = _Traits::eof()); 00076 virtual int_type underflow(); 00077 virtual _Base* setbuf(char* __buf, streamsize __n); 00078 virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, 00079 ios_base::openmode __mode 00080 = ios_base::in | ios_base::out); 00081 virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode 00082 = ios_base::in | ios_base::out); 00083 00084 private: // Helper functions. 00085 // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. 00086 char* _M_alloc(size_t); 00087 void _M_free(char*); 00088 00089 // Helper function used in constructors. 00090 void _M_setup(char* __get, char* __put, streamsize __n); 00091 private: // Data members. 00092 __alloc_fn _M_alloc_fun; 00093 __free_fn _M_free_fun; 00094 bool _M_dynamic : 1; 00095 bool _M_frozen : 1; 00096 bool _M_constant : 1; 00097 }; 00098 00099 //---------------------------------------------------------------------- 00100 // Class istrstream, an istream that manages a strstreambuf. 00101 00102 class _STLP_CLASS_DECLSPEC istrstream : public basic_istream<char, char_traits<char> > { 00103 public: 00104 explicit istrstream(char*); 00105 explicit istrstream(const char*); 00106 istrstream(char* , streamsize); 00107 istrstream(const char*, streamsize); 00108 virtual ~istrstream(); 00109 00110 strstreambuf* rdbuf() const; 00111 char* str(); 00112 00113 private: 00114 strstreambuf _M_buf; 00115 }; 00116 00117 //---------------------------------------------------------------------- 00118 // Class ostrstream 00119 00120 class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream<char, char_traits<char> > 00121 { 00122 public: 00123 ostrstream(); 00124 ostrstream(char*, int, ios_base::openmode = ios_base::out); 00125 virtual ~ostrstream(); 00126 00127 strstreambuf* rdbuf() const; 00128 void freeze(bool = true); 00129 char* str(); 00130 int pcount() const; 00131 00132 private: 00133 strstreambuf _M_buf; 00134 }; 00135 00136 //---------------------------------------------------------------------- 00137 // Class strstream 00138 00139 class _STLP_CLASS_DECLSPEC strstream : public basic_iostream<char, char_traits<char> > { 00140 public: 00141 typedef char char_type; 00142 typedef char_traits<char>::int_type int_type; 00143 typedef char_traits<char>::pos_type pos_type; 00144 typedef char_traits<char>::off_type off_type; 00145 00146 strstream(); 00147 strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); 00148 virtual ~strstream(); 00149 00150 strstreambuf* rdbuf() const; 00151 void freeze(bool = true); 00152 int pcount() const; 00153 char* str(); 00154 00155 private: 00156 strstreambuf _M_buf; 00157 00158 //explicitely defined as private to avoid warnings: 00159 strstream(strstream const&); 00160 strstream& operator = (strstream const&); 00161 }; 00162 00163 _STLP_END_NAMESPACE 00164 00165 #endif /* _STLP_INTERNAL_STRSTREAM */
Generated on Mon Mar 10 15:32:41 2008 by ![]() |