2081
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2007 |
|
4 John W. Eaton |
2081
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
2081
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
2081
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_octave_fstream_h) |
|
25 #define octave_octave_fstream_h 1 |
|
26 |
3503
|
27 #include <fstream> |
3775
|
28 #include <string> |
2081
|
29 |
|
30 #include "oct-stream.h" |
|
31 |
|
32 class |
|
33 octave_fstream : public octave_base_stream |
|
34 { |
|
35 public: |
|
36 |
3523
|
37 octave_fstream (const std::string& nm_arg, |
3570
|
38 std::ios::openmode arg_md = std::ios::in|std::ios::out, |
5015
|
39 oct_mach_info::float_format flt_fmt |
|
40 = oct_mach_info::native_float_format ()); |
2081
|
41 |
3340
|
42 static octave_stream |
3544
|
43 create (const std::string& nm_arg, |
3570
|
44 std::ios::openmode arg_md = std::ios::in|std::ios::out, |
5015
|
45 oct_mach_info::float_format flt_fmt |
|
46 = oct_mach_info::native_float_format ()); |
2081
|
47 |
|
48 // Position a stream at OFFSET relative to ORIGIN. |
|
49 |
4797
|
50 int seek (long offset, int origin); |
2081
|
51 |
|
52 // Return current stream position. |
|
53 |
4797
|
54 long tell (void); |
2081
|
55 |
|
56 // Return non-zero if EOF has been reached on this stream. |
|
57 |
|
58 bool eof (void) const; |
|
59 |
3652
|
60 void do_close (void); |
|
61 |
2081
|
62 // The name of the file. |
|
63 |
3523
|
64 std::string name (void) const { return nm; } |
2081
|
65 |
3523
|
66 std::istream *input_stream (void); |
2081
|
67 |
3523
|
68 std::ostream *output_stream (void); |
2081
|
69 |
3340
|
70 protected: |
|
71 |
|
72 ~octave_fstream (void) { } |
|
73 |
2081
|
74 private: |
|
75 |
3523
|
76 std::string nm; |
2081
|
77 |
3551
|
78 std::fstream fs; |
2081
|
79 |
|
80 // No copying! |
|
81 |
|
82 octave_fstream (const octave_fstream&); |
|
83 |
|
84 octave_fstream& operator = (const octave_fstream&); |
|
85 }; |
|
86 |
|
87 #endif |