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 |
3503
|
31 #include <iostream> |
2901
|
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 |
3219
|
39 DEFINE_OCTAVE_ALLOCATOR (octave_file); |
2901
|
40 |
3219
|
41 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_file, "file"); |
2901
|
42 |
|
43 static octave_value * |
|
44 default_numeric_conversion_function (const octave_value& a) |
|
45 { |
|
46 CAST_CONV_ARG (const octave_file&); |
|
47 |
|
48 return new octave_scalar (static_cast<double> (v.stream_number ())); |
|
49 } |
|
50 |
|
51 type_conv_fcn |
|
52 octave_file::numeric_conversion_function (void) const |
|
53 { |
|
54 return default_numeric_conversion_function; |
|
55 } |
|
56 |
|
57 void |
3523
|
58 octave_file::print (std::ostream& os, bool) const |
2901
|
59 { |
|
60 print_raw (os); |
|
61 newline (os); |
|
62 } |
|
63 |
|
64 void |
3523
|
65 octave_file::print_raw (std::ostream& os, bool) const |
2901
|
66 { |
2916
|
67 indent (os); os << "{"; newline (os); |
2901
|
68 |
|
69 if (stream) |
|
70 { |
|
71 increment_indent_level (); |
|
72 |
3523
|
73 std::string name = stream.name (); |
|
74 std::string mode = octave_stream::mode_as_string (stream.mode ()); |
|
75 std::string arch |
3340
|
76 = oct_mach_info::float_format_as_string (stream.float_format ()); |
3523
|
77 std::string status = stream.is_open () ? "open" : "closed"; |
2901
|
78 |
|
79 indent (os); os << "id = " << number; newline (os); |
|
80 indent (os); os << "name = " << name; newline (os); |
|
81 indent (os); os << "mode = " << mode; newline (os); |
|
82 indent (os); os << "arch = " << arch; newline (os); |
3340
|
83 indent (os); os << "status = " << status; newline (os); |
2901
|
84 |
|
85 decrement_indent_level (); |
|
86 } |
|
87 |
|
88 indent (os); os << "}"; |
|
89 } |
|
90 |
|
91 bool |
3523
|
92 octave_file::print_name_tag (std::ostream& os, const std::string& name) const |
2901
|
93 { |
|
94 indent (os); |
|
95 os << name << " ="; |
|
96 newline (os); |
|
97 return false; |
|
98 } |
|
99 |
|
100 /* |
|
101 ;;; Local Variables: *** |
|
102 ;;; mode: C++ *** |
|
103 ;;; End: *** |
|
104 */ |