Mercurial > hg > octave-lyh
comparison src/oct-obj.h @ 1968:a2e206524aa0
[project @ 1996-02-17 02:54:24 by jwe]
author | jwe |
---|---|
date | Sat, 17 Feb 1996 02:57:16 +0000 |
parents | e62277bf5fe0 |
children | 003570e69c7b |
comparison
equal
deleted
inserted
replaced
1967:4cb6aaa0f2c7 | 1968:a2e206524aa0 |
---|---|
26 | 26 |
27 #if defined (__GNUG__) | 27 #if defined (__GNUG__) |
28 #pragma interface | 28 #pragma interface |
29 #endif | 29 #endif |
30 | 30 |
31 #include <string> | |
32 | |
31 #include "Array.h" | 33 #include "Array.h" |
34 #include "str-vec.h" | |
32 | 35 |
33 // Including this is all we need because pt-const.h gives us | 36 // Including this is all we need because pt-const.h gives us |
34 // declarations for all the data types Octave knows about. | 37 // declarations for all the data types Octave knows about. |
35 | 38 |
36 #include "pt-const.h" | 39 #include "pt-const.h" |
38 class | 41 class |
39 Octave_object : public Array<tree_constant> | 42 Octave_object : public Array<tree_constant> |
40 { | 43 { |
41 public: | 44 public: |
42 | 45 |
43 Octave_object (void) : Array<tree_constant> () { } | 46 Octave_object (void) |
47 : Array<tree_constant> () { } | |
48 | |
44 Octave_object (int n, const tree_constant& val) | 49 Octave_object (int n, const tree_constant& val) |
45 : Array<tree_constant> (n, val) { } | 50 : Array<tree_constant> (n, val) { } |
46 | 51 |
47 Octave_object (const tree_constant& tc) : Array<tree_constant> (1, tc) { } | 52 Octave_object (const tree_constant& tc) |
53 : Array<tree_constant> (1, tc) { } | |
48 | 54 |
49 Octave_object (double d); | 55 Octave_object (double d) |
50 Octave_object (const Matrix& m); | 56 : Array<tree_constant> (1, tree_constant (d)) { } |
51 Octave_object (const DiagMatrix& d); | |
52 Octave_object (const RowVector& v, int pcv = -1); | |
53 Octave_object (const ColumnVector& v, int pcv = -1); | |
54 | 57 |
55 Octave_object (const Complex& c); | 58 Octave_object (const Matrix& m) |
56 Octave_object (const ComplexMatrix& m); | 59 : Array<tree_constant> (1, tree_constant (m)) { } |
57 Octave_object (const ComplexDiagMatrix& d); | |
58 Octave_object (const ComplexRowVector& v, int pcv = -1); | |
59 Octave_object (const ComplexColumnVector& v, int pcv = -1); | |
60 | 60 |
61 Octave_object (const char *s); | 61 Octave_object (const DiagMatrix& d) |
62 Octave_object (const string& s); | 62 : Array<tree_constant> (1, tree_constant (d)) { } |
63 Octave_object (const string_vector& s); | |
64 | 63 |
65 Octave_object (double base, double limit, double inc); | 64 Octave_object (const RowVector& v, int pcv) |
66 Octave_object (const Range& r); | 65 : Array<tree_constant> (1, tree_constant (v, pcv)) { } |
67 | 66 |
68 Octave_object (const Octave_object& obj) : Array<tree_constant> (obj) { } | 67 Octave_object (const ColumnVector& v, int pcv) |
68 : Array<tree_constant> (1, tree_constant (v, pcv)) { } | |
69 | |
70 Octave_object (const Complex& c) | |
71 : Array<tree_constant> (1, tree_constant (c)) { } | |
72 | |
73 Octave_object (const ComplexMatrix& m) | |
74 : Array<tree_constant> (1, tree_constant (m)) { } | |
75 | |
76 Octave_object (const ComplexDiagMatrix& d) | |
77 : Array<tree_constant> (1, tree_constant (d)) { } | |
78 | |
79 Octave_object (const ComplexRowVector& v, int pcv) | |
80 : Array<tree_constant> (1, tree_constant (v, pcv)) { } | |
81 | |
82 Octave_object (const ComplexColumnVector& v, int pcv) | |
83 : Array<tree_constant> (1, tree_constant (v, pcv)) { } | |
84 | |
85 Octave_object (const char *s) | |
86 : Array<tree_constant> (1, tree_constant (s)) { } | |
87 | |
88 Octave_object (const string& s) | |
89 : Array<tree_constant> (1, tree_constant (s)) { } | |
90 | |
91 Octave_object (const string_vector& s) | |
92 : Array<tree_constant> (1, tree_constant (s)) { } | |
93 | |
94 Octave_object (double base, double limit, double inc) | |
95 : Array<tree_constant> (1, tree_constant (base, limit, inc)) { } | |
96 | |
97 Octave_object (const Range& r) | |
98 : Array<tree_constant> (1, tree_constant (r)) { } | |
99 | |
100 Octave_object (const Octave_object& obj) | |
101 : Array<tree_constant> (obj) { } | |
69 | 102 |
70 Octave_object& operator = (const Octave_object& obj) | 103 Octave_object& operator = (const Octave_object& obj) |
71 { | 104 { |
72 Array<tree_constant>::operator = (obj); | 105 if (this != &obj) |
106 Array<tree_constant>::operator = (obj); | |
107 | |
73 return *this; | 108 return *this; |
74 } | 109 } |
75 | 110 |
76 // Assignment will resize on range errors. | 111 // Assignment will resize on range errors. |
77 | 112 |
78 tree_constant& operator () (int n); | 113 tree_constant& operator () (int n) { return elem (n); } |
79 | 114 |
80 tree_constant operator () (int n) const; | 115 tree_constant operator () (int n) const { return elem (n); } |
116 | |
117 int all_strings (void) const; | |
118 | |
119 string_vector make_argv (const string&) const; | |
81 | 120 |
82 private: | 121 private: |
83 | 122 |
84 // This constructor is private with no definition to keep statements | 123 // This constructor is private with no definition to keep statements |
85 // like | 124 // like |
94 // | 133 // |
95 // and supply a default value to create a vector-valued Octave_object. | 134 // and supply a default value to create a vector-valued Octave_object. |
96 | 135 |
97 Octave_object (int n); | 136 Octave_object (int n); |
98 | 137 |
99 void maybe_resize (int n); | 138 void maybe_resize (int n) |
139 { | |
140 if (n >= length ()) | |
141 resize (n + 1, Matrix ()); | |
142 } | |
100 | 143 |
101 tree_constant& elem (int n); | 144 tree_constant& elem (int n) |
145 { | |
146 maybe_resize (n); | |
147 return Array<tree_constant>::elem (n); | |
148 } | |
149 | |
102 tree_constant& checkelem (int n); | 150 tree_constant& checkelem (int n); |
103 | 151 |
104 tree_constant& xelem (int n); | 152 tree_constant& xelem (int n); |
105 | 153 |
106 tree_constant elem (int n) const; | 154 tree_constant elem (int n) const |
155 { | |
156 return Array<tree_constant>::operator () (n); | |
157 } | |
158 | |
107 tree_constant checkelem (int n) const; | 159 tree_constant checkelem (int n) const; |
108 }; | 160 }; |
109 | 161 |
110 #endif | 162 #endif |
111 | 163 |