GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-lvalue.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_oct_lvalue_h)
24 #define octave_oct_lvalue_h 1
25 
26 class octave_value;
27 class octave_value_list;
28 
29 #include <string>
30 
31 #include "oct-obj.h"
32 #include "pt-idx.h"
33 #include "symtab.h"
34 
35 class
37 {
38 public:
39 
42  : sym (s), type (), idx (), nel (1)
43  { }
44 
46  : sym (vr.sym), type (vr.type), idx (vr.idx), nel (vr.nel)
47  { }
48 
50  {
51  if (this != &vr)
52  {
53  sym = vr.sym;
54  type = vr.type;
55  idx = vr.idx;
56  nel = vr.nel;
57  }
58 
59  return *this;
60  }
61 
62  ~octave_lvalue (void) { }
63 
64  bool is_black_hole (void) const { return sym.is_black_hole (); }
65 
66  bool is_defined (void) const
67  {
68  return ! is_black_hole () && sym->is_defined ();
69  }
70 
71  bool is_undefined (void) const
72  {
73  return is_black_hole () || sym->is_undefined ();
74  }
75 
76  bool is_map (void) const
77  {
78  return value().is_map ();
79  }
80 
81  void define (const octave_value& v) { sym->assign (v); }
82 
83  void assign (octave_value::assign_op, const octave_value&);
84 
85  void numel (octave_idx_type n) { nel = n; }
86 
87  octave_idx_type numel (void) const { return nel; }
88 
89  void set_index (const std::string& t, const std::list<octave_value_list>& i);
90 
91  void clear_index (void) { type = std::string (); idx.clear (); }
92 
94 
95  octave_value value (void) const;
96 
97 private:
98 
100 
101  std::string type;
102 
103  std::list<octave_value_list> idx;
104 
106 };
107 
108 #endif