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