Cell.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1999-2012 John W. Eaton
00004 Copyright (C) 2009-2010 VZLU Prague
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (Cell_h)
00025 #define Cell_h 1
00026 
00027 #include <string>
00028 
00029 #include "Array.h"
00030 #include "oct-alloc.h"
00031 #include "str-vec.h"
00032 #include "ov.h"
00033 
00034 class octave_value_list;
00035 
00036 class
00037 OCTINTERP_API
00038 Cell : public Array<octave_value>
00039 {
00040 public:
00041 
00042   Cell (void)
00043     : Array<octave_value> (dim_vector (0, 0)) { }
00044 
00045   Cell (const octave_value& val)
00046     : Array<octave_value> (dim_vector (1, 1), val) { }
00047 
00048   Cell (const octave_value_list& ovl);
00049 
00050   Cell (octave_idx_type n, octave_idx_type m,
00051         const octave_value& val = resize_fill_value ())
00052     : Array<octave_value> (dim_vector (n, m), val) { }
00053 
00054   Cell (const dim_vector& dv, const octave_value& val = resize_fill_value ())
00055     : Array<octave_value> (dv, val) { }
00056 
00057   Cell (const Array<octave_value>& c)
00058     : Array<octave_value> (c) { }
00059 
00060   Cell (const Array<octave_value>& c, octave_idx_type nr, octave_idx_type nc)
00061     : Array<octave_value> (c, dim_vector (nr, nc)) { }
00062 
00063   Cell (const string_vector& sv, bool trim = false);
00064 
00065   Cell (const std::list<std::string>& lst);
00066 
00067   Cell (const Array<std::string>& sa);
00068 
00069   Cell (const dim_vector& dv, const string_vector& sv, bool trim = false);
00070 
00071   Cell (const Cell& c)
00072     : Array<octave_value> (c) { }
00073 
00074   bool is_cellstr (void) const;
00075 
00076   Array<std::string> cellstr_value (void) const;
00077 
00078   using Array<octave_value>::index;
00079 
00080   Cell index (const octave_value_list& idx, bool resize_ok = false) const;
00081 
00082   using Array<octave_value>::delete_elements;
00083 
00084   void delete_elements (const octave_value_list& idx);
00085 
00086   using Array<octave_value>::assign;
00087 
00088   void assign (const octave_value_list& idx, const Cell& rhs,
00089                const octave_value& fill_val = resize_fill_value ());
00090 
00091   Cell reshape (const dim_vector& new_dims) const
00092     { return Array<octave_value>::reshape (new_dims); }
00093 
00094   octave_idx_type nnz (void) const;
00095 
00096   Cell column (octave_idx_type i) const;
00097 
00098   // FIXME
00099   boolMatrix all (int /* dim */ = 0) const { return boolMatrix (); }
00100 
00101   // FIXME
00102   boolMatrix any (int /* dim */ = 0) const { return boolMatrix (); }
00103 
00104   Cell concat (const Cell& rb, const Array<octave_idx_type>& ra_idx);
00105 
00106   Cell& insert (const Cell& a, octave_idx_type r, octave_idx_type c);
00107   Cell& insert (const Cell& a, const Array<octave_idx_type>& ra_idx);
00108 
00109   // FIXME
00110   bool any_element_is_nan (void) const { return false; }
00111   bool is_true (void) const { return false; }
00112 
00113   static octave_value resize_fill_value (void) { return Matrix (); }
00114 
00115   Cell diag (octave_idx_type k = 0) const;
00116 
00117   Cell xisalnum (void) const { return map (&octave_value::xisalnum); }
00118   Cell xisalpha (void) const { return map (&octave_value::xisalpha); }
00119   Cell xisascii (void) const { return map (&octave_value::xisascii); }
00120   Cell xiscntrl (void) const { return map (&octave_value::xiscntrl); }
00121   Cell xisdigit (void) const { return map (&octave_value::xisdigit); }
00122   Cell xisgraph (void) const { return map (&octave_value::xisgraph); }
00123   Cell xislower (void) const { return map (&octave_value::xislower); }
00124   Cell xisprint (void) const { return map (&octave_value::xisprint); }
00125   Cell xispunct (void) const { return map (&octave_value::xispunct); }
00126   Cell xisspace (void) const { return map (&octave_value::xisspace); }
00127   Cell xisupper (void) const { return map (&octave_value::xisupper); }
00128   Cell xisxdigit (void) const { return map (&octave_value::xisxdigit); }
00129   Cell xtoascii (void) const { return map (&octave_value::xtoascii); }
00130   Cell xtolower (void) const { return map (&octave_value::xtolower); }
00131   Cell xtoupper (void) const { return map (&octave_value::xtoupper); }
00132 
00133 private:
00134 
00135   typedef octave_value (octave_value::*ctype_mapper) (void) const;
00136 
00137   Cell map (ctype_mapper) const;
00138 };
00139 
00140 template<>
00141 inline Cell octave_value_extract<Cell> (const octave_value& v)
00142   { return v.cell_value (); }
00143 
00144 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines