annotate src/ov-file.h @ 2916:4e7bea116f24

[project @ 1997-04-30 20:56:31 by jwe]
author jwe
date Wed, 30 Apr 1997 20:57:48 +0000
parents e6d25bc478dd
children 30770ba4457a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2901
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
1 /*
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
2
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
4
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
6
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
10 later version.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
11
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
15 for more details.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
16
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
20
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
21 */
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
22
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_file_h)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
24 #define octave_file_h 1
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
25
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
26 #if defined (__GNUG__)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
27 #pragma interface
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
28 #endif
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
29
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
30 #include <cstdlib>
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
31
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
32 #include <string>
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
33
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
34 class ostream;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
35
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
36 #include "oct-alloc.h"
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
37 #include "ov-base.h"
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
38 #include "ov-typeinfo.h"
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
39
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
40 class tree_walker;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
41 class octave_stream;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
42 class octave_value;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
43 class octave_value_list;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
44
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
45 // Lists.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
46
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
47 class
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
48 octave_file : public octave_base_value
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
49 {
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
50 public:
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
51
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
52 octave_file (void)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
53 : octave_base_value (), stream (0), number (-1) { }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
54
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
55 octave_file (octave_stream *s, int n)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
56 : octave_base_value (), stream (s), number (n) { }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
57
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
58 octave_file (const octave_file& f)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
59 : octave_base_value (), stream (f.stream), number (f.number) { }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
60
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
61 ~octave_file (void) { }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
62
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
63 octave_value *clone (void) { return new octave_file (*this); }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
64
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
65 void *operator new (size_t size)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
66 { return allocator.alloc (size); }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
67
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
68 void operator delete (void *p, size_t size)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
69 { allocator.free (p, size); }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
70
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
71 type_conv_fcn numeric_conversion_function (void) const;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
72
2916
4e7bea116f24 [project @ 1997-04-30 20:56:31 by jwe]
jwe
parents: 2901
diff changeset
73 double double_value (bool) const { return static_cast<double> (number); }
4e7bea116f24 [project @ 1997-04-30 20:56:31 by jwe]
jwe
parents: 2901
diff changeset
74
4e7bea116f24 [project @ 1997-04-30 20:56:31 by jwe]
jwe
parents: 2901
diff changeset
75 double scalar_value (bool) const { return static_cast<double> (number); }
2901
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
76
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
77 octave_stream *stream_value (void) const { return stream; }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
78
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
79 int stream_number (void) const { return number; }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
80
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
81 bool is_defined (void) const { return true; }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
82
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
83 bool is_file (void) const { return true; }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
84
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
85 void print (ostream& os, bool pr_as_read_syntax = false) const;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
86
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
87 void print_raw (ostream& os, bool pr_as_read_syntax = false) const;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
88
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
89 bool print_name_tag (ostream& os, const string& name) const;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
90
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
91 int type_id (void) const { return t_id; }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
92
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
93 string type_name (void) const { return t_name; }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
94
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
95 static int static_type_id (void) { return t_id; }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
96
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
97 static void register_type (void)
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
98 { t_id = octave_value_typeinfo::register_type (t_name); }
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
99
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
100 private:
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
101
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
102 // The stream object.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
103 octave_stream *stream;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
104
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
105 // The number of the beast.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
106 int number;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
107
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
108 // For custom memory management.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
109 static octave_allocator allocator;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
110
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
111 // Type id of list objects, set by register_type().
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
112 static int t_id;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
113
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
114 // Type name of list objects, defined in ov-list.cc.
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
115 static const string t_name;
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
116 };
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
117
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
118 #endif
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
119
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
120 /*
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
121 ;;; Local Variables: ***
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
122 ;;; mode: C++ ***
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
123 ;;; End: ***
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents:
diff changeset
124 */