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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2979
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2979
|
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 |
5775
|
35 // FIXME -- eliminate the following kluge? |
3618
|
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) |
5846
|
47 : val (v), type (), idx (), chg_fcn (f), nel (1), 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), |
5846
|
51 nel (vr.nel), 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; |
5846
|
61 nel = vr.nel; |
3357
|
62 index_set = vr.index_set; |
2979
|
63 } |
|
64 |
|
65 return *this; |
|
66 } |
|
67 |
|
68 ~octave_lvalue (void) { } |
|
69 |
|
70 bool is_defined (void) { return val->is_defined (); } |
|
71 |
|
72 bool is_undefined (void) { return val->is_undefined (); } |
|
73 |
|
74 bool is_map (void) { return val->is_map (); } |
|
75 |
|
76 void define (const octave_value& v) { *val = v; } |
|
77 |
|
78 void assign (octave_value::assign_op, const octave_value&); |
|
79 |
5846
|
80 void numel (octave_idx_type n) { nel = n; } |
|
81 |
|
82 octave_idx_type numel (void) const { return nel; } |
|
83 |
4219
|
84 void set_index (const std::string& t, const std::list<octave_value_list>& i); |
2979
|
85 |
3933
|
86 void clear_index (void) { type = std::string (); idx.clear (); } |
2984
|
87 |
3203
|
88 void do_unary_op (octave_value::unary_op op); |
2979
|
89 |
5001
|
90 octave_value value (void); |
2979
|
91 |
4234
|
92 const octave_value *object (void) const { return val; } |
|
93 |
2979
|
94 private: |
|
95 |
|
96 octave_value *val; |
|
97 |
3933
|
98 std::string type; |
2979
|
99 |
4219
|
100 std::list<octave_value_list> idx; |
3929
|
101 |
3005
|
102 symbol_record::change_function chg_fcn; |
2979
|
103 |
5846
|
104 octave_idx_type nel; |
|
105 |
3357
|
106 bool index_set; |
2979
|
107 }; |
|
108 |
|
109 #endif |
|
110 |
|
111 /* |
|
112 ;;; Local Variables: *** |
|
113 ;;; mode: C++ *** |
|
114 ;;; End: *** |
|
115 */ |