2882
|
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_list_h) |
|
24 #define octave_list_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "mx-base.h" |
|
37 #include "str-vec.h" |
|
38 |
|
39 #include "error.h" |
|
40 #include "oct-alloc.h" |
|
41 #include "oct-obj.h" |
|
42 #include "ov-base.h" |
|
43 #include "ov-typeinfo.h" |
|
44 |
|
45 class tree_walker; |
|
46 |
|
47 // Lists. |
|
48 |
|
49 class |
|
50 octave_list : public octave_base_value |
|
51 { |
|
52 public: |
|
53 |
|
54 octave_list (void) |
|
55 : octave_base_value () { } |
|
56 |
|
57 octave_list (const octave_value_list& l) |
|
58 : octave_base_value (), lst (l) { } |
|
59 |
|
60 octave_list (const octave_list& l) |
|
61 : octave_base_value (), lst (l.lst) { } |
|
62 |
|
63 ~octave_list (void) { } |
|
64 |
|
65 octave_value *clone (void) { return new octave_list (*this); } |
|
66 |
|
67 void *operator new (size_t size) |
|
68 { return allocator.alloc (size); } |
|
69 |
|
70 void operator delete (void *p, size_t size) |
|
71 { allocator.free (p, size); } |
|
72 |
2962
|
73 octave_value do_index_op (const octave_value_list& idx) const; |
2882
|
74 |
|
75 bool is_defined (void) const { return true; } |
|
76 |
|
77 bool is_list (void) const { return true; } |
|
78 |
|
79 octave_value_list list_value (void) const { return lst; } |
|
80 |
2901
|
81 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
82 |
|
83 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
84 |
|
85 bool print_name_tag (ostream& os, const string& name) const; |
2882
|
86 |
|
87 int type_id (void) const { return t_id; } |
|
88 |
|
89 string type_name (void) const { return t_name; } |
|
90 |
|
91 static int static_type_id (void) { return t_id; } |
|
92 |
|
93 static void register_type (void) |
|
94 { t_id = octave_value_typeinfo::register_type (t_name); } |
|
95 |
|
96 private: |
|
97 |
|
98 // The list of Octave values. |
|
99 octave_value_list lst; |
|
100 |
|
101 // For custom memory management. |
|
102 static octave_allocator allocator; |
|
103 |
|
104 // Type id of list objects, set by register_type(). |
|
105 static int t_id; |
|
106 |
|
107 // Type name of list objects, defined in ov-list.cc. |
|
108 static const string t_name; |
|
109 }; |
|
110 |
|
111 #endif |
|
112 |
|
113 /* |
|
114 ;;; Local Variables: *** |
|
115 ;;; mode: C++ *** |
|
116 ;;; End: *** |
|
117 */ |