498
|
1 /* |
|
2 |
1884
|
3 Copyright (C) 1996 John W. Eaton |
498
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
498
|
20 |
|
21 */ |
|
22 |
504
|
23 #if !defined (octave_oct_obj_h) |
|
24 #define octave_oct_obj_h 1 |
|
25 |
1297
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
1968
|
30 #include <string> |
|
31 |
498
|
32 #include "Array.h" |
1968
|
33 #include "str-vec.h" |
498
|
34 |
1738
|
35 // Including this is all we need because pt-const.h gives us |
|
36 // declarations for all the data types Octave knows about. |
|
37 |
|
38 #include "pt-const.h" |
498
|
39 |
737
|
40 class |
2086
|
41 octave_value_list : public Array<octave_value> |
508
|
42 { |
|
43 public: |
|
44 |
2086
|
45 octave_value_list (void) |
|
46 : Array<octave_value> () { } |
1968
|
47 |
2086
|
48 octave_value_list (int n, const octave_value& val) |
|
49 : Array<octave_value> (n, val) { } |
511
|
50 |
2086
|
51 octave_value_list (const octave_value& tc) |
|
52 : Array<octave_value> (1, tc) { } |
1968
|
53 |
2086
|
54 octave_value_list (double d) |
|
55 : Array<octave_value> (1, octave_value (d)) { } |
1968
|
56 |
2086
|
57 octave_value_list (const Matrix& m) |
|
58 : Array<octave_value> (1, octave_value (m)) { } |
1968
|
59 |
2086
|
60 octave_value_list (const DiagMatrix& d) |
|
61 : Array<octave_value> (1, octave_value (d)) { } |
526
|
62 |
2086
|
63 octave_value_list (const RowVector& v, int pcv) |
|
64 : Array<octave_value> (1, octave_value (v, pcv)) { } |
1968
|
65 |
2086
|
66 octave_value_list (const ColumnVector& v, int pcv) |
|
67 : Array<octave_value> (1, octave_value (v, pcv)) { } |
1968
|
68 |
2086
|
69 octave_value_list (const Complex& c) |
|
70 : Array<octave_value> (1, octave_value (c)) { } |
1968
|
71 |
2086
|
72 octave_value_list (const ComplexMatrix& m) |
|
73 : Array<octave_value> (1, octave_value (m)) { } |
526
|
74 |
2086
|
75 octave_value_list (const ComplexDiagMatrix& d) |
|
76 : Array<octave_value> (1, octave_value (d)) { } |
1968
|
77 |
2086
|
78 octave_value_list (const ComplexRowVector& v, int pcv) |
|
79 : Array<octave_value> (1, octave_value (v, pcv)) { } |
1968
|
80 |
2086
|
81 octave_value_list (const ComplexColumnVector& v, int pcv) |
|
82 : Array<octave_value> (1, octave_value (v, pcv)) { } |
1968
|
83 |
2086
|
84 octave_value_list (const char *s) |
|
85 : Array<octave_value> (1, octave_value (s)) { } |
526
|
86 |
2086
|
87 octave_value_list (const string& s) |
|
88 : Array<octave_value> (1, octave_value (s)) { } |
1968
|
89 |
2086
|
90 octave_value_list (const string_vector& s) |
|
91 : Array<octave_value> (1, octave_value (s)) { } |
526
|
92 |
2086
|
93 octave_value_list (double base, double limit, double inc) |
|
94 : Array<octave_value> (1, octave_value (base, limit, inc)) { } |
526
|
95 |
2086
|
96 octave_value_list (const Range& r) |
|
97 : Array<octave_value> (1, octave_value (r)) { } |
1968
|
98 |
2086
|
99 octave_value_list (const octave_value_list& obj) |
|
100 : Array<octave_value> (obj) { } |
508
|
101 |
2086
|
102 octave_value_list& operator = (const octave_value_list& obj) |
508
|
103 { |
1968
|
104 if (this != &obj) |
2086
|
105 Array<octave_value>::operator = (obj); |
1968
|
106 |
508
|
107 return *this; |
|
108 } |
|
109 |
526
|
110 // Assignment will resize on range errors. |
508
|
111 |
2086
|
112 octave_value& operator () (int n) { return elem (n); } |
1968
|
113 |
2086
|
114 octave_value operator () (int n) const { return elem (n); } |
526
|
115 |
1968
|
116 int all_strings (void) const; |
|
117 |
|
118 string_vector make_argv (const string&) const; |
526
|
119 |
|
120 private: |
508
|
121 |
565
|
122 // This constructor is private with no definition to keep statements |
|
123 // like |
|
124 // |
2086
|
125 // octave_value_list foo = 5; |
|
126 // octave_value_list foo = 5.0; |
565
|
127 // |
|
128 // from doing different things. Instead, you have to use the |
|
129 // constructor |
|
130 // |
2086
|
131 // octave_value_list (n, val); |
565
|
132 // |
2086
|
133 // and supply a default value to create a vector-valued octave_value_list. |
565
|
134 |
2086
|
135 octave_value_list (int n); |
565
|
136 |
1968
|
137 void maybe_resize (int n) |
|
138 { |
|
139 if (n >= length ()) |
|
140 resize (n + 1, Matrix ()); |
|
141 } |
526
|
142 |
2086
|
143 octave_value& elem (int n) |
1968
|
144 { |
|
145 maybe_resize (n); |
2086
|
146 return Array<octave_value>::elem (n); |
1968
|
147 } |
|
148 |
2086
|
149 octave_value& checkelem (int n); |
526
|
150 |
2086
|
151 octave_value& xelem (int n); |
508
|
152 |
2086
|
153 octave_value elem (int n) const |
1968
|
154 { |
2086
|
155 return Array<octave_value>::operator () (n); |
1968
|
156 } |
|
157 |
2086
|
158 octave_value checkelem (int n) const; |
508
|
159 }; |
498
|
160 |
504
|
161 #endif |
|
162 |
498
|
163 /* |
|
164 ;;; Local Variables: *** |
|
165 ;;; mode: C++ *** |
|
166 ;;; End: *** |
|
167 */ |