oct-lvalue.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_lvalue_h)
00024 #define octave_lvalue_h 1
00025 
00026 class octave_value;
00027 class octave_value_list;
00028 
00029 #include <string>
00030 
00031 #include "oct-obj.h"
00032 #include "pt-idx.h"
00033 
00034 class
00035 octave_lvalue
00036 {
00037 public:
00038 
00039   octave_lvalue (octave_value *v = 0)
00040     : val (v), type (), idx (), nel (1)
00041     { }
00042 
00043   octave_lvalue (const octave_lvalue& vr)
00044     : val (vr.val), type (vr.type), idx (vr.idx), nel (vr.nel)
00045     {
00046     }
00047 
00048   octave_lvalue& operator = (const octave_lvalue& vr)
00049     {
00050       if (this != &vr)
00051         {
00052           val = vr.val;
00053           type = vr.type;
00054           idx = vr.idx;
00055           nel = vr.nel;
00056         }
00057 
00058       return *this;
00059     }
00060 
00061   ~octave_lvalue (void) { }
00062 
00063   bool is_black_hole (void) const { return val == 0; }
00064 
00065   bool is_defined (void) const { return val && val->is_defined (); }
00066 
00067   bool is_undefined (void) const { return ! val || val->is_undefined (); }
00068 
00069   bool is_map (void) const { return val && val->is_map (); }
00070 
00071   void define (const octave_value& v)
00072     {
00073       if (val)
00074         *val = v;
00075     }
00076 
00077   void assign (octave_value::assign_op, const octave_value&);
00078 
00079   void numel (octave_idx_type n) { nel = n; }
00080 
00081   octave_idx_type numel (void) const { return nel; }
00082 
00083   void set_index (const std::string& t, const std::list<octave_value_list>& i);
00084 
00085   void clear_index (void) { type = std::string (); idx.clear (); }
00086 
00087   void do_unary_op (octave_value::unary_op op);
00088 
00089   octave_value value (void);
00090 
00091   const octave_value *object (void) const { return val; }
00092 
00093 private:
00094 
00095   octave_value *val;
00096 
00097   std::string type;
00098 
00099   std::list<octave_value_list> idx;
00100 
00101   octave_idx_type nel;
00102 };
00103 
00104 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines