1 /* 2 For wchar support, you need to include the wchar.i file 3 before this file, ie: 4 5 %include <wchar.i> 6 %include <std_sstream.i> 7 8 or equivalently, just include 9 10 %include <std_wsstream.i> 11 */ 12 13 %include <std_alloc.i> 14 %include <std_basic_string.i> 15 %include <std_string.i> 16 %include <std_ios.i> 17 #if defined(SWIG_WCHAR) 18 %include <std_wstring.i> 19 #endif 20 %include <std_streambuf.i> 21 %include <std_iostream.i> 22 23 %{ 24 #include <sstream> 25 %} 26 27 28 namespace std 29 { 30 template<typename _CharT, typename _Traits = char_traits<_CharT>, 31 typename _Alloc = allocator<_CharT> > 32 class basic_stringbuf : public basic_streambuf<_CharT, _Traits> 33 { 34 public: 35 // Types: 36 typedef _CharT char_type; 37 typedef _Traits traits_type; 38 // 251. basic_stringbuf missing allocator_type 39 typedef _Alloc allocator_type; 40 typedef typename traits_type::int_type int_type; 41 typedef typename traits_type::pos_type pos_type; 42 typedef typename traits_type::off_type off_type; 43 44 public: 45 // Constructors: 46 explicit 47 basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out); 48 49 explicit 50 basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __str, 51 ios_base::openmode __mode = ios_base::in | ios_base::out); 52 53 // Get and set: 54 basic_string<_CharT, _Traits, _Alloc> 55 str() const; 56 57 void 58 str(const basic_string<_CharT, _Traits, _Alloc>& __s); 59 60 }; 61 62 63 // 27.7.2 Template class basic_istringstream 64 template<typename _CharT, typename _Traits = char_traits<_CharT>, 65 typename _Alloc = allocator<_CharT> > 66 class basic_istringstream : public basic_istream<_CharT, _Traits> 67 { 68 public: 69 // Types: 70 typedef _CharT char_type; 71 typedef _Traits traits_type; 72 // 251. basic_stringbuf missing allocator_type 73 typedef _Alloc allocator_type; 74 typedef typename traits_type::int_type int_type; 75 typedef typename traits_type::pos_type pos_type; 76 typedef typename traits_type::off_type off_type; 77 78 79 public: 80 // Constructors: 81 explicit 82 basic_istringstream(ios_base::openmode __mode = ios_base::in); 83 84 explicit 85 basic_istringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, 86 ios_base::openmode __mode = ios_base::in); 87 88 ~basic_istringstream(); 89 90 // Members: 91 basic_stringbuf<_CharT, _Traits, _Alloc>* 92 rdbuf() const; 93 94 basic_string<_CharT, _Traits, _Alloc> 95 str() const; 96 97 void 98 str(const basic_string<_CharT, _Traits, _Alloc>& __s); 99 }; 100 101 102 // 27.7.3 Template class basic_ostringstream 103 template<typename _CharT, typename _Traits = char_traits<_CharT>, 104 typename _Alloc = allocator<_CharT> > 105 class basic_ostringstream : public basic_ostream<_CharT, _Traits> 106 { 107 public: 108 // Types: 109 typedef _CharT char_type; 110 typedef _Traits traits_type; 111 // 251. basic_stringbuf missing allocator_type 112 typedef _Alloc allocator_type; 113 typedef typename traits_type::int_type int_type; 114 typedef typename traits_type::pos_type pos_type; 115 typedef typename traits_type::off_type off_type; 116 117 118 public: 119 // Constructors/destructor: 120 explicit 121 basic_ostringstream(ios_base::openmode __mode = ios_base::out); 122 123 explicit 124 basic_ostringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, 125 ios_base::openmode __mode = ios_base::out); 126 127 ~basic_ostringstream(); 128 129 // Members: 130 basic_stringbuf<_CharT, _Traits, _Alloc>* 131 rdbuf() const; 132 133 basic_string<_CharT, _Traits, _Alloc> 134 str() const; 135 136 #if 0 137 void 138 str(const basic_string<_CharT, _Traits, _Alloc>& __s); 139 #endif 140 }; 141 142 143 // 27.7.4 Template class basic_stringstream 144 template<typename _CharT, typename _Traits = char_traits<_CharT>, 145 typename _Alloc = allocator<_CharT> > 146 class basic_stringstream : public basic_iostream<_CharT, _Traits> 147 { 148 public: 149 // Types: 150 typedef _CharT char_type; 151 typedef _Traits traits_type; 152 // 251. basic_stringbuf missing allocator_type 153 typedef _Alloc allocator_type; 154 typedef typename traits_type::int_type int_type; 155 typedef typename traits_type::pos_type pos_type; 156 typedef typename traits_type::off_type off_type; 157 158 public: 159 // Constructors/destructors 160 explicit 161 basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in); 162 163 explicit 164 basic_stringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, 165 ios_base::openmode __m = ios_base::out | ios_base::in); 166 167 ~basic_stringstream(); 168 169 // Members: 170 basic_stringbuf<_CharT, _Traits, _Alloc>* 171 rdbuf() const; 172 173 basic_string<_CharT, _Traits, _Alloc> 174 str() const; 175 176 void 177 str(const basic_string<_CharT, _Traits, _Alloc>& __s); 178 }; 179 180 181 } // namespace std 182 183 184 namespace std { 185 %template(istringstream) basic_istringstream<char>; 186 %template(ostringstream) basic_ostringstream<char>; 187 %template(stringstream) basic_stringstream<char>; 188 189 190 #if defined(SWIG_WCHAR) 191 %template(wistringstream) basic_istringstream<wchar_t>; 192 %template(wostringstream) basic_ostringstream<wchar_t>; 193 %template(wstringstream) basic_stringstream<wchar_t>; 194 #endif 195 } 196