2901
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_file_h) |
|
24 #define octave_file_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "oct-alloc.h" |
|
37 #include "ov-base.h" |
|
38 #include "ov-typeinfo.h" |
|
39 |
|
40 class tree_walker; |
|
41 class octave_stream; |
|
42 class octave_value; |
|
43 class octave_value_list; |
|
44 |
|
45 // Lists. |
|
46 |
|
47 class |
|
48 octave_file : public octave_base_value |
|
49 { |
|
50 public: |
|
51 |
|
52 octave_file (void) |
|
53 : octave_base_value (), stream (0), number (-1) { } |
|
54 |
|
55 octave_file (octave_stream *s, int n) |
|
56 : octave_base_value (), stream (s), number (n) { } |
|
57 |
|
58 octave_file (const octave_file& f) |
|
59 : octave_base_value (), stream (f.stream), number (f.number) { } |
|
60 |
|
61 ~octave_file (void) { } |
|
62 |
|
63 octave_value *clone (void) { return new octave_file (*this); } |
|
64 |
|
65 type_conv_fcn numeric_conversion_function (void) const; |
|
66 |
2916
|
67 double double_value (bool) const { return static_cast<double> (number); } |
|
68 |
|
69 double scalar_value (bool) const { return static_cast<double> (number); } |
2901
|
70 |
|
71 octave_stream *stream_value (void) const { return stream; } |
|
72 |
|
73 int stream_number (void) const { return number; } |
|
74 |
|
75 bool is_defined (void) const { return true; } |
|
76 |
|
77 bool is_file (void) const { return true; } |
|
78 |
|
79 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
80 |
|
81 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
82 |
|
83 bool print_name_tag (ostream& os, const string& name) const; |
|
84 |
|
85 private: |
|
86 |
|
87 // The stream object. |
|
88 octave_stream *stream; |
|
89 |
|
90 // The number of the beast. |
|
91 int number; |
|
92 |
3219
|
93 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2901
|
94 |
3219
|
95 DECLARE_OCTAVE_ALLOCATOR |
2901
|
96 }; |
|
97 |
|
98 #endif |
|
99 |
|
100 /* |
|
101 ;;; Local Variables: *** |
|
102 ;;; mode: C++ *** |
|
103 ;;; End: *** |
|
104 */ |