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 (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include <iostream.h> |
|
32 |
|
33 #include "oct-stream.h" |
|
34 #include "ops.h" |
|
35 #include "ov-file.h" |
|
36 #include "ov-scalar.h" |
|
37 #include "unwind-prot.h" |
|
38 |
|
39 octave_allocator |
|
40 octave_file::allocator (sizeof (octave_file)); |
|
41 |
|
42 int |
|
43 octave_file::t_id (-1); |
|
44 |
|
45 const string |
|
46 octave_file::t_name ("file"); |
|
47 |
|
48 static octave_value * |
|
49 default_numeric_conversion_function (const octave_value& a) |
|
50 { |
|
51 CAST_CONV_ARG (const octave_file&); |
|
52 |
|
53 return new octave_scalar (static_cast<double> (v.stream_number ())); |
|
54 } |
|
55 |
|
56 type_conv_fcn |
|
57 octave_file::numeric_conversion_function (void) const |
|
58 { |
|
59 return default_numeric_conversion_function; |
|
60 } |
|
61 |
|
62 void |
|
63 octave_file::print (ostream& os, bool) const |
|
64 { |
|
65 print_raw (os); |
|
66 newline (os); |
|
67 } |
|
68 |
|
69 void |
|
70 octave_file::print_raw (ostream& os, bool) const |
|
71 { |
2916
|
72 indent (os); os << "{"; newline (os); |
2901
|
73 |
|
74 if (stream) |
|
75 { |
|
76 increment_indent_level (); |
|
77 |
|
78 string name = stream->name (); |
|
79 string mode = octave_stream::mode_as_string (stream->mode ()); |
|
80 string arch |
|
81 = oct_mach_info::float_format_as_string (stream->float_format ()); |
|
82 |
|
83 indent (os); os << "id = " << number; newline (os); |
|
84 indent (os); os << "name = " << name; newline (os); |
|
85 indent (os); os << "mode = " << mode; newline (os); |
|
86 indent (os); os << "arch = " << arch; newline (os); |
|
87 |
|
88 decrement_indent_level (); |
|
89 } |
|
90 |
|
91 indent (os); os << "}"; |
|
92 } |
|
93 |
|
94 bool |
|
95 octave_file::print_name_tag (ostream& os, const string& name) const |
|
96 { |
|
97 indent (os); |
|
98 os << name << " ="; |
|
99 newline (os); |
|
100 return false; |
|
101 } |
|
102 |
|
103 /* |
|
104 ;;; Local Variables: *** |
|
105 ;;; mode: C++ *** |
|
106 ;;; End: *** |
|
107 */ |