1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_fstream.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_fstream.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,22 +1,22 @@
1.4 /*
1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.6 + * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.7 *
1.8 * Copyright (c) 1999
1.9 * Silicon Graphics Computer Systems, Inc.
1.10 *
1.11 - * Copyright (c) 1999
1.12 + * Copyright (c) 1999
1.13 * Boris Fomitchev
1.14 *
1.15 * This material is provided "as is", with absolutely no warranty expressed
1.16 * or implied. Any use is at your own risk.
1.17 *
1.18 - * Permission to use or copy this software for any purpose is hereby granted
1.19 + * Permission to use or copy this software for any purpose is hereby granted
1.20 * without fee, provided the above notices are retained on all copies.
1.21 * Permission to modify the code and to distribute modified code is granted,
1.22 * provided the above notices are retained, and a notice that the code was
1.23 * modified is included with the above copyright notice.
1.24 *
1.25 - */
1.26 + */
1.27 // This header defines classes basic_filebuf, basic_ifstream,
1.28 // basic_ofstream, and basic_fstream. These classes represent
1.29 // streambufs and streams whose sources or destinations are files.
1.30 @@ -25,67 +25,54 @@
1.31 #define _STLP_INTERNAL_FSTREAM_H
1.32
1.33 #if defined(__sgi) && !defined(__GNUC__) && !defined(_STANDARD_C_PLUS_PLUS)
1.34 -#error This header file requires the -LANG:std option
1.35 +# error This header file requires the -LANG:std option
1.36 #endif
1.37
1.38 #ifndef _STLP_INTERNAL_STREAMBUF
1.39 -# include <stl/_streambuf.h>
1.40 +# include <stl/_streambuf.h>
1.41 #endif
1.42
1.43 -#ifndef _STLP_INTERNAL_ISTREAM_H
1.44 -#include <stl/_istream.h>
1.45 +#ifndef _STLP_INTERNAL_ISTREAM
1.46 +# include <stl/_istream.h>
1.47 #endif
1.48
1.49 #ifndef _STLP_INTERNAL_CODECVT_H
1.50 -#include <stl/_codecvt.h>
1.51 +# include <stl/_codecvt.h>
1.52 #endif
1.53
1.54 -#ifndef _STLP_STDIO_FILE_H
1.55 -#include <stl/_stdio_file.h>
1.56 -#endif
1.57 +#if !defined (_STLP_USE_UNIX_IO) && !defined(_STLP_USE_WIN32_IO) && \
1.58 + !defined (_STLP_USE_UNIX_EMULATION_IO) && !defined (_STLP_USE_STDIO_IO)
1.59
1.60 -// fbp : let us map 1 MB maximum, just be sure not to trash VM
1.61 -//for hardware defining 8kb of mmap chunk
1.62 -# ifdef __SYMBIAN32__
1.63 -# define MMAP_CHUNK 0x2000UL
1.64 -# else
1.65 -# define MMAP_CHUNK 0x100000UL
1.66 -# endif
1.67 -
1.68 -#if !defined (_STLP_USE_UNIX_IO) && !defined(_STLP_USE_WIN32_IO) \
1.69 - && ! defined (_STLP_USE_UNIX_EMULATION_IO) && !defined (_STLP_USE_STDIO_IO)
1.70 -
1.71 -# if defined (_STLP_UNIX) || defined (__CYGWIN__) || defined (__amigaos__) || defined (__EMX__) || defined (__SYMBIAN32__)
1.72 +# if defined (_STLP_UNIX) || defined (__CYGWIN__) || defined (__amigaos__) || defined (__EMX__)
1.73 // open/close/read/write
1.74 -# define _STLP_USE_UNIX_IO
1.75 -# elif defined (_STLP_WIN32) && ! defined (__CYGWIN__)
1.76 +# define _STLP_USE_UNIX_IO
1.77 +# elif defined (_STLP_WIN32) && !defined (__SYMBIAN32__)
1.78 // CreateFile/ReadFile/WriteFile
1.79 -# define _STLP_USE_WIN32_IO
1.80 -# elif defined (_STLP_WIN16) || defined (_STLP_WIN32) || defined (_STLP_MAC)
1.81 +# define _STLP_USE_WIN32_IO
1.82 +# elif defined (_STLP_WIN16) || defined (_STLP_MAC)
1.83 // _open/_read/_write
1.84 -# define _STLP_USE_UNIX_EMULATION_IO
1.85 -# else
1.86 +# define _STLP_USE_UNIX_EMULATION_IO
1.87 +# else
1.88 // fopen/fread/fwrite
1.89 -# define _STLP_USE_STDIO_IO
1.90 -# endif /* _STLP_UNIX */
1.91 -
1.92 +# define _STLP_USE_STDIO_IO
1.93 +# endif /* _STLP_UNIX */
1.94 #endif /* mode selection */
1.95
1.96 -
1.97 #if defined (_STLP_USE_WIN32_IO)
1.98 typedef void* _STLP_fd;
1.99 #elif defined (_STLP_USE_UNIX_EMULATION_IO) || defined (_STLP_USE_STDIO_IO) || defined (_STLP_USE_UNIX_IO)
1.100 typedef int _STLP_fd;
1.101 #else
1.102 -#error "Configure i/o !"
1.103 +# error "Configure i/o !"
1.104 #endif
1.105
1.106 +#if defined(__SYMBIAN32__WSD__)
1.107 +size_t& get_fstream_Filebuf_Base_GetPageSize();
1.108 +#define _M_page_size get_fstream_Filebuf_Base_GetPageSize()
1.109 +#endif //__SYMBIAN32__WSD__
1.110
1.111 _STLP_BEGIN_NAMESPACE
1.112
1.113 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.114 -_STLP_DECLSPEC size_t& get_fstream_Filebuf_Base_GetPageSize();
1.115 -#endif //__LIBSTD_CPP_SYMBIAN32_WSD__
1.116 //----------------------------------------------------------------------
1.117 // Class _Filebuf_base, a private base class to factor out the system-
1.118 // dependent code from basic_filebuf<>.
1.119 @@ -97,6 +84,9 @@
1.120 _STLP_DECLSPEC bool _M_open(const char*, ios_base::openmode, long __protection);
1.121 _STLP_DECLSPEC bool _M_open(const char*, ios_base::openmode);
1.122 _STLP_DECLSPEC bool _M_open(int __id, ios_base::openmode = ios_base::__default_mode);
1.123 +#if defined (_STLP_USE_WIN32_IO)
1.124 + bool _M_open(_STLP_fd __id, ios_base::openmode = ios_base::__default_mode);
1.125 +#endif /* _STLP_USE_WIN32_IO */
1.126 _STLP_DECLSPEC bool _M_close();
1.127
1.128 public: // Low-level I/O, like Unix read/write
1.129 @@ -120,40 +110,41 @@
1.130 streamoff _M_get_offset(char* __first, char* __last) {
1.131 #if defined (_STLP_UNIX) || defined (_STLP_MAC)
1.132 return __last - __first;
1.133 -#else // defined (_STLP_WIN32) || defined (_STLP_WIN16) || defined (_STLP_DOS)
1.134 +#else // defined (_STLP_WIN32) || defined (_STLP_WIN16) || defined (_STLP_DOS) || defined(N_PLAT_NLM)
1.135 return ( (_M_openmode & ios_base::binary) != 0 )
1.136 ? (__last - __first)
1.137 : count(__first, __last, '\n') + (__last - __first);
1.138 #endif
1.139 }
1.140
1.141 - // Returns true if we're in binary mode or if we're using an OS or file
1.142 + // Returns true if we're in binary mode or if we're using an OS or file
1.143 // system where there is no distinction between text and binary mode.
1.144 bool _M_in_binary_mode() const {
1.145 -# if defined (_STLP_UNIX) || defined (_STLP_MAC) || defined(__BEOS__) || defined (__amigaos__) || defined (_STLP_VXWORKS_TORNADO)
1.146 +#if defined (_STLP_UNIX) || defined (_STLP_MAC) || defined(__BEOS__) || defined (__amigaos__) || defined (__SYMBIAN32__)
1.147 return true;
1.148 -# elif defined (_STLP_WIN32) || defined (_STLP_WIN16) || defined (_STLP_DOS) || defined (_STLP_VM) || defined (__EMX__)
1.149 +#elif defined (_STLP_WIN32) || defined (_STLP_WIN16) || defined (_STLP_DOS) || defined (_STLP_VM) || defined (__EMX__) || defined(N_PLAT_NLM)
1.150 return (_M_openmode & ios_base::binary) != 0;
1.151 -# else
1.152 -//# error "Port!"
1.153 -#pragma message(" Symbian I/O stream support on progress."__FILE__)
1.154 -# endif
1.155 +#else
1.156 +# error "Port!"
1.157 +#endif
1.158 }
1.159
1.160 + static void _S_initialize();
1.161 +
1.162 protected: // Static data members.
1.163 -# if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.164 +# if !defined(__SYMBIAN32__WSD__)
1.165 static size_t _M_page_size;
1.166 #endif //__SYMBIAN32__
1.167
1.168 protected: // Data members.
1.169 _STLP_fd _M_file_id;
1.170 -# ifdef _STLP_USE_STDIO_IO
1.171 +#if defined (_STLP_USE_STDIO_IO)
1.172 // for stdio, the whole FILE* is being kept here
1.173 FILE* _M_file;
1.174 -# endif
1.175 -# ifdef _STLP_USE_WIN32_IO
1.176 - void* _M_view_id;
1.177 -# endif
1.178 +#endif
1.179 +#if defined (_STLP_USE_WIN32_IO)
1.180 + _STLP_fd _M_view_id;
1.181 +#endif
1.182
1.183 ios_base::openmode _M_openmode ;
1.184 unsigned char _M_is_open ;
1.185 @@ -161,21 +152,19 @@
1.186 unsigned char _M_regular_file ;
1.187
1.188 public :
1.189 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.190 - static size_t _STLP_CALL __page_size() { return get_fstream_Filebuf_Base_GetPageSize(); }
1.191 +#if defined(__SYMBIAN32__) && defined (__EPOC32__)
1.192 + /* On Symbian,we can't make this inline. It violates one address rule */
1.193 + _STLP_DECLSPEC static size_t __page_size();
1.194 #else
1.195 - static size_t _STLP_CALL __page_size() { return _M_page_size; }
1.196 + static size_t _STLP_CALL __page_size() { return _M_page_size; }
1.197 #endif
1.198 - int __o_mode() const { return (int)_M_openmode; }
1.199 - bool __is_open() const { return (_M_is_open !=0 ); }
1.200 - bool __should_close() const { return (_M_should_close != 0); }
1.201 + int __o_mode() const { return (int)_M_openmode; }
1.202 + bool __is_open() const { return (_M_is_open !=0 ); }
1.203 + bool __should_close() const { return (_M_should_close != 0); }
1.204 bool __regular_file() const { return (_M_regular_file != 0); }
1.205 _STLP_fd __get_fd() const { return _M_file_id; }
1.206 };
1.207
1.208 -
1.209 -
1.210 -
1.211 //----------------------------------------------------------------------
1.212 // Class basic_filebuf<>.
1.213
1.214 @@ -194,11 +183,10 @@
1.215 template <class _CharT, class _Traits>
1.216 class _Underflow;
1.217
1.218 - _STLP_TEMPLATE_NULL class _Underflow< char, char_traits<char> >;
1.219 +_STLP_TEMPLATE_NULL class _Underflow< char, char_traits<char> >;
1.220
1.221 template <class _CharT, class _Traits>
1.222 -class basic_filebuf : public basic_streambuf<_CharT, _Traits>
1.223 -{
1.224 +class basic_filebuf : public basic_streambuf<_CharT, _Traits> {
1.225 public: // Types.
1.226 typedef _CharT char_type;
1.227 typedef typename _Traits::int_type int_type;
1.228 @@ -211,9 +199,9 @@
1.229 typedef basic_filebuf<_CharT, _Traits> _Self;
1.230
1.231 public: // Constructors, destructor.
1.232 - basic_filebuf();
1.233 + basic_filebuf();
1.234 ~basic_filebuf();
1.235 -
1.236 +
1.237 public: // Opening and closing files.
1.238 bool is_open() const { return _M_base.__is_open(); }
1.239
1.240 @@ -221,19 +209,26 @@
1.241 return _M_base._M_open(__s, __m) ? this : 0;
1.242 }
1.243
1.244 -# ifndef _STLP_NO_EXTENSIONS
1.245 +#if !defined (_STLP_NO_EXTENSIONS)
1.246 // These two version of open() and file descriptor getter are extensions.
1.247 _Self* open(const char* __s, ios_base::openmode __m,
1.248 - long __protection) {
1.249 + long __protection) {
1.250 return _M_base._M_open(__s, __m, __protection) ? this : 0;
1.251 }
1.252 -
1.253 +
1.254 _STLP_fd fd() const { return _M_base.__get_fd(); }
1.255
1.256 _Self* open(int __id, ios_base::openmode _Init_mode = ios_base::__default_mode) {
1.257 return this->_M_open(__id, _Init_mode);
1.258 }
1.259 -# endif
1.260 +
1.261 +# if defined (_STLP_USE_WIN32_IO)
1.262 + _Self* open(_STLP_fd __id, ios_base::openmode _Init_mode = ios_base::__default_mode) {
1.263 + return _M_base._M_open(__id, _Init_mode) ? this : 0;
1.264 + }
1.265 +# endif /* _STLP_USE_WIN32_IO */
1.266 +
1.267 +#endif
1.268
1.269 _Self* _M_open(int __id, ios_base::openmode _Init_mode = ios_base::__default_mode) {
1.270 return _M_base._M_open(__id, _Init_mode) ? this : 0;
1.271 @@ -257,11 +252,6 @@
1.272 virtual int sync();
1.273 virtual void imbue(const locale&);
1.274
1.275 -#ifdef __SYMBIAN32__
1.276 - virtual int save_read_buffer ();
1.277 - virtual void _change_input_mode();
1.278 -#endif
1.279 -
1.280 private: // Helper functions.
1.281
1.282 // Precondition: we are currently in putback input mode. Effect:
1.283 @@ -291,27 +281,22 @@
1.284 if (__off != -1) {
1.285 if (_M_in_input_mode)
1.286 _M_exit_input_mode();
1.287 -#ifndef __SYMBIAN32__
1.288 - _M_in_input_mode = false; //moved down, because setg again sets input mode
1.289 -#endif
1.290 + _M_in_input_mode = false;
1.291 _M_in_output_mode = false;
1.292 _M_in_putback_mode = false;
1.293 _M_in_error_mode = false;
1.294 this->setg(0, 0, 0);
1.295 this->setp(0, 0);
1.296 -#ifdef __SYMBIAN32__
1.297 - _M_in_input_mode = false;
1.298 -#endif
1.299 }
1.300 -
1.301 +
1.302 pos_type __result(__off);
1.303 __result.state(__state);
1.304 return __result;
1.305 }
1.306 -
1.307 +
1.308 bool _M_seek_init(bool __do_unshift);
1.309
1.310 - void _M_setup_codecvt(const locale&);
1.311 + void _M_setup_codecvt(const locale&, bool __on_imbue = true);
1.312
1.313 private: // Data members used in all modes.
1.314
1.315 @@ -321,7 +306,7 @@
1.316
1.317 unsigned char _M_constant_width;
1.318 unsigned char _M_always_noconv;
1.319 -
1.320 +
1.321 // private: // Mode flags.
1.322 unsigned char _M_int_buf_dynamic; // True if internal buffer is heap allocated,
1.323 // false if it was supplied by the user.
1.324 @@ -329,11 +314,11 @@
1.325 unsigned char _M_in_output_mode;
1.326 unsigned char _M_in_error_mode;
1.327 unsigned char _M_in_putback_mode;
1.328 -
1.329 +
1.330 // Internal buffer: characters seen by the filebuf's clients.
1.331 _CharT* _M_int_buf;
1.332 _CharT* _M_int_buf_EOS;
1.333 -
1.334 +
1.335 // External buffer: characters corresponding to the external file.
1.336 char* _M_ext_buf;
1.337 char* _M_ext_buf_EOS;
1.338 @@ -382,23 +367,22 @@
1.339 int_type
1.340 _M_do_noconv_input() {
1.341 _M_ext_buf_converted = _M_ext_buf_end;
1.342 - this->setg((char_type*)_M_ext_buf, (char_type*)_M_ext_buf, (char_type*)_M_ext_buf_end);
1.343 + /* this-> */ _Base::setg((char_type*)_M_ext_buf, (char_type*)_M_ext_buf, (char_type*)_M_ext_buf_end);
1.344 return traits_type::to_int_type(*_M_ext_buf);
1.345 }
1.346 };
1.347
1.348 -# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.349 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
1.350 _STLP_EXPORT_TEMPLATE_CLASS basic_filebuf<char, char_traits<char> >;
1.351 # if ! defined (_STLP_NO_WCHAR_T)
1.352 _STLP_EXPORT_TEMPLATE_CLASS basic_filebuf<wchar_t, char_traits<wchar_t> >;
1.353 # endif
1.354 -# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.355 +#endif /* _STLP_USE_TEMPLATE_EXPORT */
1.356
1.357 // public:
1.358 // helper class.
1.359 template <class _CharT>
1.360 -struct _Filebuf_Tmp_Buf
1.361 -{
1.362 +struct _Filebuf_Tmp_Buf {
1.363 _CharT* _M_ptr;
1.364 _Filebuf_Tmp_Buf(ptrdiff_t __n) : _M_ptr(0) { _M_ptr = new _CharT[__n]; }
1.365 ~_Filebuf_Tmp_Buf() { delete[] _M_ptr; }
1.366 @@ -413,26 +397,19 @@
1.367 class _Noconv_output {
1.368 public:
1.369 typedef typename _Traits::char_type char_type;
1.370 - static bool _STLP_CALL _M_doit(basic_filebuf<char_type, _Traits >*,
1.371 + static bool _STLP_CALL _M_doit(basic_filebuf<char_type, _Traits >*,
1.372 char_type*, char_type*)
1.373 - {
1.374 - return false;
1.375 - }
1.376 + { return false; }
1.377 };
1.378
1.379 _STLP_TEMPLATE_NULL
1.380 class _STLP_CLASS_DECLSPEC _Noconv_output< char_traits<char> > {
1.381 public:
1.382 static bool _STLP_CALL
1.383 - _M_doit(basic_filebuf<char, char_traits<char> >* __buf,
1.384 - char* __first, char* __last)
1.385 - {
1.386 + _M_doit(basic_filebuf<char, char_traits<char> >* __buf,
1.387 + char* __first, char* __last) {
1.388 ptrdiff_t __n = __last - __first;
1.389 - if (__buf->_M_write(__first, __n)) {
1.390 - return true;
1.391 - }
1.392 - else
1.393 - return false;
1.394 + return (__buf->_M_write(__first, __n));
1.395 }
1.396 };
1.397
1.398 @@ -454,17 +431,15 @@
1.399 typedef typename _Traits::char_type char_type;
1.400
1.401 static inline int_type _STLP_CALL
1.402 - _M_doit(basic_filebuf<char_type, _Traits>*)
1.403 - {
1.404 - return 0;
1.405 - }
1.406 + _M_doit(basic_filebuf<char_type, _Traits>*)
1.407 + { return _Traits::eof(); }
1.408 };
1.409
1.410 _STLP_TEMPLATE_NULL
1.411 class _Noconv_input<char_traits<char> > {
1.412 public:
1.413 static inline int _STLP_CALL
1.414 - _M_doit(basic_filebuf<char, char_traits<char> >* __buf) {
1.415 + _M_doit(basic_filebuf<char, char_traits<char> >* __buf) {
1.416 return __buf->_M_do_noconv_input();
1.417 }
1.418 };
1.419 @@ -472,13 +447,13 @@
1.420 // underflow() may be called for one of two reasons. (1) We've
1.421 // been going through the special putback buffer, and we need to move back
1.422 // to the regular internal buffer. (2) We've exhausted the internal buffer,
1.423 -// and we need to replentish it.
1.424 +// and we need to replentish it.
1.425 template <class _CharT, class _Traits>
1.426 class _Underflow {
1.427 public:
1.428 typedef typename _Traits::int_type int_type;
1.429 typedef _Traits traits_type;
1.430 -
1.431 +
1.432 static int_type _STLP_CALL _M_doit(basic_filebuf<_CharT, _Traits>* __this);
1.433 };
1.434
1.435 @@ -498,13 +473,11 @@
1.436
1.437 template <class _CharT, class _Traits>
1.438 _STLP_TYPENAME_ON_RETURN_TYPE _Underflow<_CharT, _Traits>::int_type // _STLP_CALL
1.439 - _Underflow<_CharT, _Traits>::_M_doit(basic_filebuf<_CharT, _Traits>* __this)
1.440 -{
1.441 + _Underflow<_CharT, _Traits>::_M_doit(basic_filebuf<_CharT, _Traits>* __this) {
1.442 if (!__this->_M_in_input_mode) {
1.443 if (!__this->_M_switch_to_input_mode())
1.444 return traits_type::eof();
1.445 }
1.446 -
1.447 else if (__this->_M_in_putback_mode) {
1.448 __this->_M_exit_putback_mode();
1.449 if (__this->gptr() != __this->egptr()) {
1.450 @@ -512,21 +485,19 @@
1.451 return __c;
1.452 }
1.453 }
1.454 -
1.455 +
1.456 return __this->_M_underflow_aux();
1.457 }
1.458
1.459 -#if defined( _STLP_USE_TEMPLATE_EXPORT ) && ! defined (_STLP_NO_WCHAR_T)
1.460 +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_NO_WCHAR_T)
1.461 _STLP_EXPORT_TEMPLATE_CLASS _Underflow<wchar_t, char_traits<wchar_t> >;
1.462 #endif
1.463
1.464 -
1.465 //----------------------------------------------------------------------
1.466 // Class basic_ifstream<>
1.467
1.468 template <class _CharT, class _Traits>
1.469 -class basic_ifstream : public basic_istream<_CharT, _Traits>
1.470 -{
1.471 +class basic_ifstream : public basic_istream<_CharT, _Traits> {
1.472 public: // Types
1.473 typedef _CharT char_type;
1.474 typedef typename _Traits::int_type int_type;
1.475 @@ -540,35 +511,43 @@
1.476
1.477 public: // Constructors, destructor.
1.478
1.479 - basic_ifstream() :
1.480 + basic_ifstream() :
1.481 basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
1.482 this->init(&_M_buf);
1.483 }
1.484
1.485 - explicit basic_ifstream(const char* __s, ios_base::openmode __mod = ios_base::in) :
1.486 + explicit basic_ifstream(const char* __s, ios_base::openmode __mod = ios_base::in) :
1.487 basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0),
1.488 _M_buf() {
1.489 this->init(&_M_buf);
1.490 if (!_M_buf.open(__s, __mod | ios_base::in))
1.491 - this->setstate(ios_base::failbit);
1.492 + this->setstate(ios_base::failbit);
1.493 }
1.494
1.495 -# ifndef _STLP_NO_EXTENSIONS
1.496 - explicit basic_ifstream(int __id, ios_base::openmode __mod = ios_base::in) :
1.497 +#if !defined (_STLP_NO_EXTENSIONS)
1.498 + explicit basic_ifstream(int __id, ios_base::openmode __mod = ios_base::in) :
1.499 basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
1.500 this->init(&_M_buf);
1.501 if (!_M_buf.open(__id, __mod | ios_base::in))
1.502 this->setstate(ios_base::failbit);
1.503 }
1.504 basic_ifstream(const char* __s, ios_base::openmode __m,
1.505 - long __protection) :
1.506 + long __protection) :
1.507 basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
1.508 this->init(&_M_buf);
1.509 if (!_M_buf.open(__s, __m | ios_base::in, __protection))
1.510 - this->setstate(ios_base::failbit);
1.511 + this->setstate(ios_base::failbit);
1.512 }
1.513 -
1.514 -# endif
1.515 +
1.516 +# if defined (_STLP_USE_WIN32_IO)
1.517 + explicit basic_ifstream(_STLP_fd __id, ios_base::openmode __mod = ios_base::in) :
1.518 + basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
1.519 + this->init(&_M_buf);
1.520 + if (!_M_buf.open(__id, __mod | ios_base::in))
1.521 + this->setstate(ios_base::failbit);
1.522 + }
1.523 +# endif /* _STLP_USE_WIN32_IO */
1.524 +#endif
1.525
1.526 ~basic_ifstream() {}
1.527
1.528 @@ -590,7 +569,6 @@
1.529 this->setstate(ios_base::failbit);
1.530 }
1.531
1.532 -
1.533 private:
1.534 basic_filebuf<_CharT, _Traits> _M_buf;
1.535 };
1.536 @@ -600,8 +578,7 @@
1.537 // Class basic_ofstream<>
1.538
1.539 template <class _CharT, class _Traits>
1.540 -class basic_ofstream : public basic_ostream<_CharT, _Traits>
1.541 -{
1.542 +class basic_ofstream : public basic_ostream<_CharT, _Traits> {
1.543 public: // Types
1.544 typedef _CharT char_type;
1.545 typedef typename _Traits::int_type int_type;
1.546 @@ -614,40 +591,48 @@
1.547 typedef basic_filebuf<_CharT, _Traits> _Buf;
1.548
1.549 public: // Constructors, destructor.
1.550 - basic_ofstream() :
1.551 - basic_ios<_CharT, _Traits>(),
1.552 + basic_ofstream() :
1.553 + basic_ios<_CharT, _Traits>(),
1.554 basic_ostream<_CharT, _Traits>(0), _M_buf() {
1.555 this->init(&_M_buf);
1.556 }
1.557 - explicit basic_ofstream(const char* __s, ios_base::openmode __mod = ios_base::out)
1.558 - : basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0),
1.559 - _M_buf() {
1.560 - this->init(&_M_buf);
1.561 - if (!_M_buf.open(__s, __mod | ios_base::out))
1.562 - this->setstate(ios_base::failbit);
1.563 + explicit basic_ofstream(const char* __s, ios_base::openmode __mod = ios_base::out)
1.564 + : basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), _M_buf() {
1.565 + this->init(&_M_buf);
1.566 + if (!_M_buf.open(__s, __mod | ios_base::out))
1.567 + this->setstate(ios_base::failbit);
1.568 }
1.569
1.570 -# ifndef _STLP_NO_EXTENSIONS
1.571 - explicit basic_ofstream(int __id, ios_base::openmode __mod = ios_base::out)
1.572 +#if !defined (_STLP_NO_EXTENSIONS)
1.573 + explicit basic_ofstream(int __id, ios_base::openmode __mod = ios_base::out)
1.574 : basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0),
1.575 _M_buf() {
1.576 - this->init(&_M_buf);
1.577 - if (!_M_buf.open(__id, __mod | ios_base::out))
1.578 - this->setstate(ios_base::failbit);
1.579 + this->init(&_M_buf);
1.580 + if (!_M_buf.open(__id, __mod | ios_base::out))
1.581 + this->setstate(ios_base::failbit);
1.582 }
1.583 - basic_ofstream(const char* __s, ios_base::openmode __m, long __protection) :
1.584 + basic_ofstream(const char* __s, ios_base::openmode __m, long __protection) :
1.585 basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), _M_buf() {
1.586 this->init(&_M_buf);
1.587 if (!_M_buf.open(__s, __m | ios_base::out, __protection))
1.588 - this->setstate(ios_base::failbit);
1.589 + this->setstate(ios_base::failbit);
1.590 }
1.591 -# endif
1.592 -
1.593 +# if defined (_STLP_USE_WIN32_IO)
1.594 + explicit basic_ofstream(_STLP_fd __id, ios_base::openmode __mod = ios_base::out)
1.595 + : basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0),
1.596 + _M_buf() {
1.597 + this->init(&_M_buf);
1.598 + if (!_M_buf.open(__id, __mod | ios_base::out))
1.599 + this->setstate(ios_base::failbit);
1.600 + }
1.601 +# endif /* _STLP_USE_WIN32_IO */
1.602 +#endif
1.603 +
1.604 ~basic_ofstream() {}
1.605
1.606 public: // File and buffer operations.
1.607 basic_filebuf<_CharT, _Traits>* rdbuf() const
1.608 - { return __CONST_CAST(_Buf*,&_M_buf); }
1.609 + { return __CONST_CAST(_Buf*,&_M_buf); }
1.610
1.611 bool is_open() {
1.612 return this->rdbuf()->is_open();
1.613 @@ -672,8 +657,7 @@
1.614 // Class basic_fstream<>
1.615
1.616 template <class _CharT, class _Traits>
1.617 -class basic_fstream : public basic_iostream<_CharT, _Traits>
1.618 -{
1.619 +class basic_fstream : public basic_iostream<_CharT, _Traits> {
1.620 public: // Types
1.621 typedef _CharT char_type;
1.622 typedef typename _Traits::int_type int_type;
1.623 @@ -686,17 +670,21 @@
1.624 typedef basic_filebuf<_CharT, _Traits> _Buf;
1.625
1.626 public: // Constructors, destructor.
1.627 -
1.628 - _STLP_DECLSPEC basic_fstream();
1.629 +
1.630 + basic_fstream()
1.631 + : basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
1.632 + this->init(&_M_buf);
1.633 + }
1.634 +
1.635 explicit basic_fstream(const char* __s,
1.636 ios_base::openmode __mod = ios_base::in | ios_base::out) :
1.637 basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
1.638 this->init(&_M_buf);
1.639 if (!_M_buf.open(__s, __mod))
1.640 - this->setstate(ios_base::failbit);
1.641 + this->setstate(ios_base::failbit);
1.642 }
1.643
1.644 -# ifndef _STLP_NO_EXTENSIONS
1.645 +#if !defined (_STLP_NO_EXTENSIONS)
1.646 explicit basic_fstream(int __id,
1.647 ios_base::openmode __mod = ios_base::in | ios_base::out) :
1.648 basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
1.649 @@ -704,27 +692,36 @@
1.650 if (!_M_buf.open(__id, __mod))
1.651 this->setstate(ios_base::failbit);
1.652 }
1.653 - basic_fstream(const char* __s, ios_base::openmode __m, long __protection) :
1.654 + basic_fstream(const char* __s, ios_base::openmode __m, long __protection) :
1.655 basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
1.656 this->init(&_M_buf);
1.657 if (!_M_buf.open(__s, __m, __protection))
1.658 - this->setstate(ios_base::failbit);
1.659 + this->setstate(ios_base::failbit);
1.660 }
1.661 -# endif
1.662 - _STLP_DECLSPEC ~basic_fstream();
1.663 +# if defined (_STLP_USE_WIN32_IO)
1.664 + explicit basic_fstream(_STLP_fd __id,
1.665 + ios_base::openmode __mod = ios_base::in | ios_base::out) :
1.666 + basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
1.667 + this->init(&_M_buf);
1.668 + if (!_M_buf.open(__id, __mod))
1.669 + this->setstate(ios_base::failbit);
1.670 + }
1.671 +# endif /* _STLP_USE_WIN32_IO */
1.672 +#endif
1.673 + ~basic_fstream() {}
1.674
1.675 public: // File and buffer operations.
1.676
1.677 basic_filebuf<_CharT, _Traits>* rdbuf() const
1.678 - { return __CONST_CAST(_Buf*,&_M_buf); }
1.679 + { return __CONST_CAST(_Buf*,&_M_buf); }
1.680
1.681 bool is_open() {
1.682 return this->rdbuf()->is_open();
1.683 }
1.684
1.685 - void open(const char* __s,
1.686 - ios_base::openmode __mod =
1.687 - ios_base::in | ios_base::out) {
1.688 + void open(const char* __s,
1.689 + ios_base::openmode __mod =
1.690 + ios_base::in | ios_base::out) {
1.691 if (!this->rdbuf()->open(__s, __mod))
1.692 this->setstate(ios_base::failbit);
1.693 }
1.694 @@ -736,17 +733,24 @@
1.695
1.696 private:
1.697 basic_filebuf<_CharT, _Traits> _M_buf;
1.698 +
1.699 +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310)
1.700 + typedef basic_fstream<_CharT, _Traits> _Self;
1.701 + //explicitely defined as private to avoid warnings:
1.702 + basic_fstream(_Self const&);
1.703 + _Self& operator = (_Self const&);
1.704 +#endif
1.705 };
1.706
1.707 _STLP_END_NAMESPACE
1.708
1.709 -# if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.710 +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
1.711 # include <stl/_fstream.c>
1.712 -# endif
1.713 +#endif
1.714
1.715 _STLP_BEGIN_NAMESPACE
1.716
1.717 -# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.718 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
1.719 _STLP_EXPORT_TEMPLATE_CLASS basic_ifstream<char, char_traits<char> >;
1.720 _STLP_EXPORT_TEMPLATE_CLASS basic_ofstream<char, char_traits<char> >;
1.721 _STLP_EXPORT_TEMPLATE_CLASS basic_fstream<char, char_traits<char> >;
1.722 @@ -755,7 +759,7 @@
1.723 _STLP_EXPORT_TEMPLATE_CLASS basic_ofstream<wchar_t, char_traits<wchar_t> >;
1.724 _STLP_EXPORT_TEMPLATE_CLASS basic_fstream<wchar_t, char_traits<wchar_t> >;
1.725 # endif
1.726 -# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.727 +#endif /* _STLP_USE_TEMPLATE_EXPORT */
1.728
1.729 _STLP_END_NAMESPACE
1.730