Mercurial > octave-libtiff
comparison src/oct-var-ref.h @ 2952:c4bc40161199
[project @ 1997-05-09 14:49:47 by jwe]
author | jwe |
---|---|
date | Fri, 09 May 1997 14:49:47 +0000 |
parents | |
children | c0c280cda856 |
comparison
equal
deleted
inserted
replaced
2951:ab9673e3bb5d | 2952:c4bc40161199 |
---|---|
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_variable_reference_h) | |
24 #define octave_variable_reference_h 1 | |
25 | |
26 class octave_value; | |
27 class octave_value_list; | |
28 | |
29 #include <string> | |
30 | |
31 #include "oct-obj.h" | |
32 #include "symtab.h" | |
33 | |
34 class | |
35 octave_variable_reference | |
36 { | |
37 public: | |
38 | |
39 octave_variable_reference (octave_value *v = 0, | |
40 symbol_record::sv_function f = 0) | |
41 : val (v), idx (), chg_fcn (f), struct_elt_name () { } | |
42 | |
43 octave_variable_reference (octave_value *v, const string& nm, | |
44 symbol_record::sv_function f = 0) | |
45 : val (v), idx (), chg_fcn (f), struct_elt_name (nm) { } | |
46 | |
47 octave_variable_reference (const octave_variable_reference& vr) | |
48 : val (vr.val), idx (vr.idx), chg_fcn (vr.chg_fcn), | |
49 struct_elt_name (vr.struct_elt_name) { } | |
50 | |
51 octave_variable_reference& operator = (const octave_variable_reference& vr) | |
52 { | |
53 if (this != &vr) | |
54 { | |
55 val = vr.val; | |
56 idx = vr.idx; | |
57 chg_fcn = vr.chg_fcn; | |
58 struct_elt_name = vr.struct_elt_name; | |
59 } | |
60 | |
61 return *this; | |
62 } | |
63 | |
64 ~octave_variable_reference (void) { } | |
65 | |
66 bool is_undefined (void) { return val->is_undefined (); } | |
67 | |
68 void define (const octave_value& v) { *val = v; } | |
69 | |
70 void assign (octave_value::assign_op, const octave_value&); | |
71 | |
72 octave_variable_reference struct_elt_ref (const string& nm) | |
73 { return val->struct_elt_ref (nm); } | |
74 | |
75 void index (const octave_value_list& i) { idx = i; } | |
76 | |
77 void increment (void) { val->increment (); } | |
78 | |
79 void decrement (void) { val->decrement (); } | |
80 | |
81 octave_value value (void) | |
82 { | |
83 return struct_elt_name.empty () | |
84 ? *val : val->struct_elt_val (struct_elt_name); | |
85 } | |
86 | |
87 private: | |
88 | |
89 octave_value *val; | |
90 | |
91 octave_value_list idx; | |
92 | |
93 symbol_record::sv_function chg_fcn; | |
94 | |
95 string struct_elt_name; | |
96 }; | |
97 | |
98 #endif | |
99 | |
100 /* | |
101 ;;; Local Variables: *** | |
102 ;;; mode: C++ *** | |
103 ;;; End: *** | |
104 */ |