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 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2882
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2882
|
33 #include <string> |
|
34 |
|
35 #include "mx-base.h" |
|
36 #include "str-vec.h" |
|
37 |
4591
|
38 #include "Cell.h" |
2882
|
39 #include "error.h" |
|
40 #include "oct-alloc.h" |
|
41 #include "ov-base.h" |
|
42 #include "ov-typeinfo.h" |
|
43 |
|
44 class tree_walker; |
|
45 |
|
46 // Lists. |
|
47 |
|
48 class |
|
49 octave_list : public octave_base_value |
|
50 { |
|
51 public: |
|
52 |
|
53 octave_list (void) |
|
54 : octave_base_value () { } |
|
55 |
|
56 octave_list (const octave_value_list& l) |
4591
|
57 : octave_base_value (), data (l) { } |
2882
|
58 |
4513
|
59 octave_list (const Cell& c); |
|
60 |
2882
|
61 octave_list (const octave_list& l) |
4591
|
62 : octave_base_value (), data (l.data) { } |
2882
|
63 |
|
64 ~octave_list (void) { } |
|
65 |
3933
|
66 octave_value *clone (void) const { return new octave_list (*this); } |
|
67 octave_value *empty_clone (void) const { return new octave_list (); } |
|
68 |
4247
|
69 octave_value subsref (const std::string& type, |
4219
|
70 const std::list<octave_value_list>& idx); |
2882
|
71 |
4661
|
72 octave_value_list subsref (const std::string&, |
|
73 const std::list<octave_value_list>&, int) |
4271
|
74 { |
|
75 panic_impossible (); |
|
76 return octave_value_list (); |
|
77 } |
|
78 |
3933
|
79 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
|
80 |
4247
|
81 octave_value subsasgn (const std::string& type, |
4219
|
82 const std::list<octave_value_list>& idx, |
3933
|
83 const octave_value& rhs); |
2882
|
84 |
3196
|
85 void assign (const octave_value_list& idx, const octave_value& rhs); |
|
86 |
4591
|
87 dim_vector dims (void) const { return dim_vector (1, data.length ()); } |
4559
|
88 |
2882
|
89 bool is_defined (void) const { return true; } |
|
90 |
2974
|
91 bool is_constant (void) const { return true; } |
|
92 |
2882
|
93 bool is_list (void) const { return true; } |
|
94 |
4591
|
95 octave_value_list list_value (void) const; |
2882
|
96 |
3523
|
97 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
98 |
3523
|
99 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
100 |
3523
|
101 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2882
|
102 |
4499
|
103 protected: |
2882
|
104 |
|
105 // The list of Octave values. |
4591
|
106 Cell data; |
2882
|
107 |
4499
|
108 private: |
|
109 |
4612
|
110 DECLARE_OCTAVE_ALLOCATOR |
2882
|
111 |
4612
|
112 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2882
|
113 }; |
|
114 |
|
115 #endif |
|
116 |
|
117 /* |
|
118 ;;; Local Variables: *** |
|
119 ;;; mode: C++ *** |
|
120 ;;; End: *** |
|
121 */ |