2979
|
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_lvalue_h) |
|
24 #define octave_lvalue_h 1 |
|
25 |
|
26 class octave_value; |
|
27 class octave_value_list; |
|
28 |
|
29 #include <string> |
|
30 |
|
31 #include "oct-obj.h" |
3929
|
32 #include "pt-idx.h" |
2979
|
33 #include "symtab.h" |
|
34 |
3618
|
35 // XXX FIXME XXX -- eliminate the following kluge? |
|
36 |
|
37 // This variable is used when creating dummy octave_lvalue objects. |
|
38 static octave_value dummy_val; |
|
39 |
2979
|
40 class |
|
41 octave_lvalue |
|
42 { |
|
43 public: |
|
44 |
3618
|
45 octave_lvalue (octave_value *v = &dummy_val, |
|
46 symbol_record::change_function f = 0) |
3933
|
47 : val (v), type (), idx (), chg_fcn (f), index_set (false) { } |
2979
|
48 |
|
49 octave_lvalue (const octave_lvalue& vr) |
3933
|
50 : val (vr.val), type (vr.type), idx (vr.idx), chg_fcn (vr.chg_fcn), |
|
51 index_set (vr.index_set) { } |
2979
|
52 |
|
53 octave_lvalue& operator = (const octave_lvalue& vr) |
|
54 { |
|
55 if (this != &vr) |
|
56 { |
|
57 val = vr.val; |
3933
|
58 type = vr.type; |
2979
|
59 idx = vr.idx; |
|
60 chg_fcn = vr.chg_fcn; |
3357
|
61 index_set = vr.index_set; |
2979
|
62 } |
|
63 |
|
64 return *this; |
|
65 } |
|
66 |
|
67 ~octave_lvalue (void) { } |
|
68 |
|
69 bool is_defined (void) { return val->is_defined (); } |
|
70 |
|
71 bool is_undefined (void) { return val->is_undefined (); } |
|
72 |
|
73 bool is_map (void) { return val->is_map (); } |
|
74 |
|
75 void define (const octave_value& v) { *val = v; } |
|
76 |
|
77 void assign (octave_value::assign_op, const octave_value&); |
|
78 |
4219
|
79 void set_index (const std::string& t, const std::list<octave_value_list>& i); |
2979
|
80 |
3933
|
81 void clear_index (void) { type = std::string (); idx.clear (); } |
2984
|
82 |
3203
|
83 void do_unary_op (octave_value::unary_op op); |
2979
|
84 |
5001
|
85 octave_value value (void); |
2979
|
86 |
4234
|
87 const octave_value *object (void) const { return val; } |
|
88 |
2979
|
89 private: |
|
90 |
|
91 octave_value *val; |
|
92 |
3933
|
93 std::string type; |
2979
|
94 |
4219
|
95 std::list<octave_value_list> idx; |
3929
|
96 |
3005
|
97 symbol_record::change_function chg_fcn; |
2979
|
98 |
3357
|
99 bool index_set; |
2979
|
100 }; |
|
101 |
|
102 #endif |
|
103 |
|
104 /* |
|
105 ;;; Local Variables: *** |
|
106 ;;; mode: C++ *** |
|
107 ;;; End: *** |
|
108 */ |