comparison src/ov-struct.cc @ 4219:23d06c9e1edd

[project @ 2002-12-06 21:29:17 by jwe]
author jwe
date Fri, 06 Dec 2002 21:29:19 +0000
parents 40f76ce7a051
children fc9a075d10fb
comparison
equal deleted inserted replaced
4218:4a392a01e51a 4219:23d06c9e1edd
49 49
50 assert (idx.length () == 1); 50 assert (idx.length () == 1);
51 51
52 std::string nm = idx(0).string_value (); 52 std::string nm = idx(0).string_value ();
53 53
54 Pix p = map.seek (nm); 54 Octave_map::const_iterator p = map.seek (nm);
55 55
56 if (p) 56 if (p != map.end ())
57 retval = map.contents (p); 57 retval = map.contents (p);
58 else 58 else
59 error ("structure has no member `%s'", nm.c_str ()); 59 error ("structure has no member `%s'", nm.c_str ());
60 60
61 return retval; 61 return retval;
85 error ("assignment to structure element failed"); 85 error ("assignment to structure element failed");
86 } 86 }
87 87
88 octave_value 88 octave_value
89 octave_struct::subsref (const std::string type, 89 octave_struct::subsref (const std::string type,
90 const SLList<octave_value_list>& idx) 90 const std::list<octave_value_list>& idx)
91 { 91 {
92 octave_value retval; 92 octave_value retval;
93 93
94 int skip = 1; 94 int skip = 1;
95 95
97 { 97 {
98 case '(': 98 case '(':
99 { 99 {
100 if (type.length () > 1 && type[1] == '.') 100 if (type.length () > 1 && type[1] == '.')
101 { 101 {
102 Pix p = idx.first (); 102 std::list<octave_value_list>::const_iterator p = idx.begin ();
103 idx.next (p); 103 octave_value_list key_idx = *++p;
104 octave_value_list key_idx = idx(p);
105 104
106 octave_value_list tmp = dotref (key_idx); 105 octave_value_list tmp = dotref (key_idx);
107 106
108 if (! error_state) 107 if (! error_state)
109 { 108 {
181 return retval; 180 return retval;
182 } 181 }
183 182
184 octave_value 183 octave_value
185 octave_struct::subsasgn (const std::string type, 184 octave_struct::subsasgn (const std::string type,
186 const SLList<octave_value_list>& idx, 185 const std::list<octave_value_list>& idx,
187 const octave_value& rhs) 186 const octave_value& rhs)
188 { 187 {
189 octave_value retval; 188 octave_value retval;
190 189
191 int n = type.length (); 190 int n = type.length ();
198 { 197 {
199 case '(': 198 case '(':
200 { 199 {
201 if (type.length () > 1 && type[1] == '.') 200 if (type.length () > 1 && type[1] == '.')
202 { 201 {
203 Pix p = idx.first (); 202 std::list<octave_value_list>::const_iterator p = idx.begin ();
204 octave_value_list t_idx = idx(p); 203 octave_value_list t_idx = *p;
205 204
206 if (t_idx.length () == 1) 205 if (t_idx.length () == 1)
207 { 206 {
208 idx.next (p); 207 octave_value_list key_idx = *++p;
209 octave_value_list key_idx = idx(p);
210 208
211 assert (key_idx.length () == 1); 209 assert (key_idx.length () == 1);
212 210
213 std::string key = key_idx(0).string_value (); 211 std::string key = key_idx(0).string_value ();
214 212
229 u = numeric_conv (map_elt, type.substr (2)); 227 u = numeric_conv (map_elt, type.substr (2));
230 } 228 }
231 229
232 if (! error_state) 230 if (! error_state)
233 { 231 {
234 SLList<octave_value_list> next_idx (idx); 232 std::list<octave_value_list> next_idx (idx);
235 233
236 // We handled two index elements, so subsasgn to 234 // We handled two index elements, so subsasgn to
237 // needs to skip both of them. 235 // needs to skip both of them.
238 236
239 next_idx.remove_front (); 237 next_idx.erase (next_idx.begin ());
240 next_idx.remove_front (); 238 next_idx.erase (next_idx.begin ());
241 239
242 u.make_unique (); 240 u.make_unique ();
243 241
244 t_rhs = u.subsasgn (type.substr (2), next_idx, rhs); 242 t_rhs = u.subsasgn (type.substr (2), next_idx, rhs);
245 } 243 }
271 u = numeric_conv (map_val, type.substr (1)); 269 u = numeric_conv (map_val, type.substr (1));
272 } 270 }
273 271
274 if (! error_state) 272 if (! error_state)
275 { 273 {
276 SLList<octave_value_list> next_idx (idx); 274 std::list<octave_value_list> next_idx (idx);
277 275
278 next_idx.remove_front (); 276 next_idx.erase (next_idx.begin ());
279 277
280 u.make_unique (); 278 u.make_unique ();
281 279
282 t_rhs = u.subsasgn (type.substr (1), next_idx, rhs); 280 t_rhs = u.subsasgn (type.substr (1), next_idx, rhs);
283 } 281 }
299 { 297 {
300 case '(': 298 case '(':
301 { 299 {
302 if (n > 1 && type[1] == '.') 300 if (n > 1 && type[1] == '.')
303 { 301 {
304 Pix p = idx.first (); 302 std::list<octave_value_list>::const_iterator p = idx.begin ();
305 idx.next (p); 303 octave_value_list key_idx = *++p;
306 octave_value_list key_idx = idx(p);
307 304
308 assert (key_idx.length () == 1); 305 assert (key_idx.length () == 1);
309 306
310 std::string key = key_idx(0).string_value (); 307 std::string key = key_idx(0).string_value ();
311 308
416 413
417 increment_indent_level (); 414 increment_indent_level ();
418 415
419 int n = map.array_length (); 416 int n = map.array_length ();
420 417
421 for (Pix p = map.first (); p; map.next (p)) 418 for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++)
422 { 419 {
423 std::string key = map.key (p); 420 std::string key = map.key (p);
424 octave_value_list val = map.contents (p); 421 octave_value_list val = map.contents (p);
425 422
426 octave_value tmp = (n == 1) ? val(0) : octave_value (val); 423 octave_value tmp = (n == 1) ? val(0) : octave_value (val);