Mercurial > hg > octave-nkf
annotate src/oct-iostrm.h @ 9393:d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 24 Jun 2009 19:04:30 -0400 |
parents | 16f53d29049f |
children | cd96d29c5efa |
rev | line source |
---|---|
2081 | 1 /* |
2 | |
9245 | 3 Copyright (C) 1996, 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2007, |
4 2009 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_iostream_h) | |
25 #define octave_octave_iostream_h 1 | |
26 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
27 #include <iosfwd> |
2877 | 28 |
2081 | 29 #include "oct-stream.h" |
30 | |
31 class | |
32 octave_base_iostream : public octave_base_stream | |
33 { | |
34 public: | |
35 | |
3523 | 36 octave_base_iostream (const std::string& n = std::string (), |
4587 | 37 std::ios::openmode m = std::ios::in|std::ios::out, |
5015 | 38 oct_mach_info::float_format ff |
39 = oct_mach_info::native_float_format ()) | |
4587 | 40 : octave_base_stream (m, ff), nm (n) { } |
2081 | 41 |
42 // Position a stream at OFFSET relative to ORIGIN. | |
43 | |
4797 | 44 int seek (long offset, int origin); |
2081 | 45 |
46 // Return current stream position. | |
47 | |
4797 | 48 long tell (void); |
2081 | 49 |
50 // Return non-zero if EOF has been reached on this stream. | |
51 | |
52 bool eof (void) const; | |
53 | |
54 // The name of the file. | |
55 | |
3523 | 56 std::string name (void) const { return nm; } |
2081 | 57 |
58 protected: | |
59 | |
3340 | 60 ~octave_base_iostream (void) { } |
61 | |
2081 | 62 void invalid_operation (void) const; |
63 | |
64 private: | |
65 | |
3523 | 66 std::string nm; |
2081 | 67 |
68 virtual const char *stream_type (void) const = 0; | |
69 | |
70 // No copying! | |
71 | |
72 octave_base_iostream (const octave_base_iostream&); | |
73 | |
74 octave_base_iostream& operator = (const octave_base_iostream&); | |
75 }; | |
76 | |
77 class | |
78 octave_istream : public octave_base_iostream | |
79 { | |
80 public: | |
81 | |
4587 | 82 octave_istream (std::istream *arg = 0, const std::string& n = std::string ()) |
5015 | 83 : octave_base_iostream (n, std::ios::in, |
84 oct_mach_info::native_float_format ()), | |
85 is (arg) | |
86 { } | |
2081 | 87 |
3340 | 88 static octave_stream |
4587 | 89 create (std::istream *arg = 0, const std::string& n = std::string ()); |
2081 | 90 |
3342 | 91 // Return non-zero if EOF has been reached on this stream. |
92 | |
93 bool eof (void) const; | |
94 | |
3523 | 95 std::istream *input_stream (void) { return is; } |
2081 | 96 |
3523 | 97 std::ostream *output_stream (void) { return 0; } |
2081 | 98 |
3340 | 99 protected: |
100 | |
101 ~octave_istream (void) { } | |
102 | |
2081 | 103 private: |
104 | |
3523 | 105 std::istream *is; |
2081 | 106 |
107 const char *stream_type (void) const { return "octave_istream"; } | |
108 | |
109 // No copying! | |
110 | |
111 octave_istream (const octave_istream&); | |
112 | |
113 octave_istream& operator = (const octave_istream&); | |
114 }; | |
115 | |
116 class | |
117 octave_ostream : public octave_base_iostream | |
118 { | |
119 public: | |
120 | |
4587 | 121 octave_ostream (std::ostream *arg, const std::string& n = std::string ()) |
5015 | 122 : octave_base_iostream (n, std::ios::out, |
123 oct_mach_info::native_float_format ()), | |
124 os (arg) | |
125 { } | |
2081 | 126 |
3340 | 127 static octave_stream |
4587 | 128 create (std::ostream *arg, const std::string& n = std::string ()); |
2081 | 129 |
3342 | 130 // Return non-zero if EOF has been reached on this stream. |
131 | |
132 bool eof (void) const; | |
133 | |
3523 | 134 std::istream *input_stream (void) { return 0; } |
2081 | 135 |
3523 | 136 std::ostream *output_stream (void) { return os; } |
2081 | 137 |
3340 | 138 protected: |
139 | |
140 ~octave_ostream (void) { } | |
141 | |
2081 | 142 private: |
143 | |
3523 | 144 std::ostream *os; |
2081 | 145 |
146 const char *stream_type (void) const { return "octave_ostream"; } | |
147 | |
148 // No copying! | |
149 | |
150 octave_ostream (const octave_ostream&); | |
151 | |
152 octave_ostream& operator = (const octave_ostream&); | |
153 }; | |
154 | |
155 #endif | |
156 | |
157 /* | |
158 ;;; Local Variables: *** | |
159 ;;; mode: C++ *** | |
160 ;;; End: *** | |
161 */ |