2979
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2004, 2005, 2006, |
|
4 2007 John W. Eaton |
2979
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
2979
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
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 |
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 |
7336
|
45 octave_lvalue (octave_value *v = &dummy_val) |
|
46 : val (v), type (), idx (), nel (1), index_set (false) { } |
2979
|
47 |
|
48 octave_lvalue (const octave_lvalue& vr) |
7336
|
49 : val (vr.val), type (vr.type), idx (vr.idx), nel (vr.nel), |
|
50 index_set (vr.index_set) { } |
2979
|
51 |
|
52 octave_lvalue& operator = (const octave_lvalue& vr) |
|
53 { |
|
54 if (this != &vr) |
|
55 { |
|
56 val = vr.val; |
3933
|
57 type = vr.type; |
2979
|
58 idx = vr.idx; |
5846
|
59 nel = vr.nel; |
3357
|
60 index_set = vr.index_set; |
2979
|
61 } |
|
62 |
|
63 return *this; |
|
64 } |
|
65 |
|
66 ~octave_lvalue (void) { } |
|
67 |
|
68 bool is_defined (void) { return val->is_defined (); } |
|
69 |
|
70 bool is_undefined (void) { return val->is_undefined (); } |
|
71 |
|
72 bool is_map (void) { return val->is_map (); } |
|
73 |
|
74 void define (const octave_value& v) { *val = v; } |
|
75 |
|
76 void assign (octave_value::assign_op, const octave_value&); |
|
77 |
5846
|
78 void numel (octave_idx_type n) { nel = n; } |
|
79 |
|
80 octave_idx_type numel (void) const { return nel; } |
|
81 |
4219
|
82 void set_index (const std::string& t, const std::list<octave_value_list>& i); |
2979
|
83 |
3933
|
84 void clear_index (void) { type = std::string (); idx.clear (); } |
2984
|
85 |
3203
|
86 void do_unary_op (octave_value::unary_op op); |
2979
|
87 |
5001
|
88 octave_value value (void); |
2979
|
89 |
4234
|
90 const octave_value *object (void) const { return val; } |
|
91 |
2979
|
92 private: |
|
93 |
|
94 octave_value *val; |
|
95 |
3933
|
96 std::string type; |
2979
|
97 |
4219
|
98 std::list<octave_value_list> idx; |
3929
|
99 |
5846
|
100 octave_idx_type nel; |
|
101 |
3357
|
102 bool index_set; |
2979
|
103 }; |
|
104 |
|
105 #endif |
|
106 |
|
107 /* |
|
108 ;;; Local Variables: *** |
|
109 ;;; mode: C++ *** |
|
110 ;;; End: *** |
|
111 */ |