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