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 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2901
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2901
|
33 #include <string> |
|
34 |
|
35 #include "oct-alloc.h" |
3340
|
36 #include "oct-stream.h" |
2901
|
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) |
3340
|
53 : octave_base_value (), stream (), number (-1) { } |
2901
|
54 |
3340
|
55 octave_file (const octave_stream& s, int n) |
2901
|
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 |
3933
|
63 octave_value *clone (void) const { return new octave_file (*this); } |
|
64 octave_value *empty_clone (void) const { return new octave_file (); } |
2901
|
65 |
|
66 type_conv_fcn numeric_conversion_function (void) const; |
|
67 |
2916
|
68 double double_value (bool) const { return static_cast<double> (number); } |
|
69 |
|
70 double scalar_value (bool) const { return static_cast<double> (number); } |
2901
|
71 |
3340
|
72 octave_stream stream_value (void) const { return stream; } |
2901
|
73 |
|
74 int stream_number (void) const { return number; } |
|
75 |
|
76 bool is_defined (void) const { return true; } |
|
77 |
3340
|
78 bool is_stream (void) const { return true; } |
2901
|
79 |
3523
|
80 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
81 |
3523
|
82 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
83 |
3523
|
84 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2901
|
85 |
|
86 private: |
|
87 |
|
88 // The stream object. |
3340
|
89 octave_stream stream; |
2901
|
90 |
|
91 // The number of the beast. |
|
92 int number; |
|
93 |
3219
|
94 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2901
|
95 |
3219
|
96 DECLARE_OCTAVE_ALLOCATOR |
2901
|
97 }; |
|
98 |
|
99 #endif |
|
100 |
|
101 /* |
|
102 ;;; Local Variables: *** |
|
103 ;;; mode: C++ *** |
|
104 ;;; End: *** |
|
105 */ |