1 /* This is part of libio/iostream, providing -*- C++ -*- input/output.
2 Copyright (C) 1993 Free Software Foundation
4 This file is part of the GNU IO Library. This library is free
5 software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option)
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this library; see the file COPYING. If not, write to the Free
17 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 As a special exception, if you link this library with files
20 compiled with a GNU compiler to produce an executable, this does not cause
21 the resulting executable to be covered by the GNU General Public License.
22 This exception does not however invalidate any other reasons why
23 the executable file might be covered by the GNU General Public License. */
33 class fstreambase
: virtual public ios
{
34 #ifdef _IO_NEW_STREAMS
35 mutable filebuf __my_fb
; // mutable so rdbuf() can be const
41 fstreambase(int fd
, char *p
, int l
); /* Deprecated */
42 fstreambase(const char *name
, int mode
, int prot
=0664);
44 #ifdef _IO_NEW_STREAMS
45 filebuf
* rdbuf() const { return &__my_fb
; }
47 filebuf
* rdbuf() const { return (filebuf
*) ios::rdbuf(); }
49 void open(const char *name
, int mode
, int prot
=0664);
50 int is_open() const { return rdbuf()->is_open(); }
51 void setbuf(char *ptr
, int len
) { rdbuf()->setbuf(ptr
, len
); }
54 int filedesc() { return rdbuf()->fd(); }
55 fstreambase
& raw() { rdbuf()->setbuf(NULL
, 0); return *this; }
59 class ifstream
: public fstreambase
, public istream
{
61 ifstream() : fstreambase() { }
62 ifstream(int fd
) : fstreambase(fd
) { }
63 ifstream(int fd
, char *p
, int l
) : fstreambase(fd
, p
, l
) { } /*Deprecated*/
64 ifstream(const char *name
, int mode
=ios::in
, int prot
=0664)
65 : fstreambase(name
, mode
, prot
) { }
66 void open(const char *name
, int mode
=ios::in
, int prot
=0664)
67 { fstreambase::open(name
, mode
, prot
); }
70 class ofstream
: public fstreambase
, public ostream
{
72 ofstream() : fstreambase() { }
73 ofstream(int fd
) : fstreambase(fd
) { }
74 ofstream(int fd
, char *p
, int l
) : fstreambase(fd
, p
, l
) { } /*Deprecated*/
75 ofstream(const char *name
, int mode
=ios::out
, int prot
=0664)
76 : fstreambase(name
, mode
, prot
) { }
77 void open(const char *name
, int mode
=ios::out
, int prot
=0664)
78 { fstreambase::open(name
, mode
, prot
); }
81 class fstream
: public fstreambase
, public iostream
{
83 fstream() : fstreambase() { }
84 fstream(int fd
) : fstreambase(fd
) { }
85 fstream(const char *name
, int mode
, int prot
=0664)
86 : fstreambase(name
, mode
, prot
) { }
87 fstream(int fd
, char *p
, int l
) : fstreambase(fd
, p
, l
) { } /*Deprecated*/
88 void open(const char *name
, int mode
, int prot
=0664)
89 { fstreambase::open(name
, mode
, prot
); }
92 #endif /*!_FSTREAM_H*/