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
Cell.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1999-2013 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague
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
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
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
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if !defined (octave_Cell_h)
25 #define octave_Cell_h 1
26 
27 #include <string>
28 
29 #include "Array.h"
30 #include "oct-alloc.h"
31 #include "str-vec.h"
32 #include "ov.h"
33 
34 class octave_value_list;
35 
36 class
39 {
40 public:
41 
42  Cell (void)
43  : Array<octave_value> (dim_vector (0, 0)) { }
44 
45  Cell (const octave_value& val)
46  : Array<octave_value> (dim_vector (1, 1), val) { }
47 
48  Cell (const octave_value_list& ovl);
49 
51  const octave_value& val = Matrix ())
52  : Array<octave_value> (dim_vector (n, m), val) { }
53 
54  Cell (const dim_vector& dv, const octave_value& val = Matrix ())
55  : Array<octave_value> (dv, val) { }
56 
58  : Array<octave_value> (c) { }
59 
61  : Array<octave_value> (c, dim_vector (nr, nc)) { }
62 
63  Cell (const string_vector& sv, bool trim = false);
64 
65  Cell (const std::list<std::string>& lst);
66 
67  Cell (const Array<std::string>& sa);
68 
69  Cell (const dim_vector& dv, const string_vector& sv, bool trim = false);
70 
71  Cell (const Cell& c)
72  : Array<octave_value> (c) { }
73 
74  bool is_cellstr (void) const;
75 
76  Array<std::string> cellstr_value (void) const;
77 
79 
80  Cell index (const octave_value_list& idx, bool resize_ok = false) const;
81 
83 
84  void delete_elements (const octave_value_list& idx);
85 
87 
88  void assign (const octave_value_list& idx, const Cell& rhs,
89  const octave_value& fill_val = Matrix ());
90 
91  Cell reshape (const dim_vector& new_dims) const
92  { return Array<octave_value>::reshape (new_dims); }
93 
94  octave_idx_type nnz (void) const;
95 
96  Cell column (octave_idx_type i) const;
97 
98  // FIXME
99  boolMatrix all (int /* dim */ = 0) const { return boolMatrix (); }
100 
101  // FIXME
102  boolMatrix any (int /* dim */ = 0) const { return boolMatrix (); }
103 
104  Cell concat (const Cell& rb, const Array<octave_idx_type>& ra_idx);
105 
106  Cell& insert (const Cell& a, octave_idx_type r, octave_idx_type c);
107  Cell& insert (const Cell& a, const Array<octave_idx_type>& ra_idx);
108 
109  // FIXME
110  bool any_element_is_nan (void) const { return false; }
111  bool is_true (void) const { return false; }
112 
113  octave_value resize_fill_value (void) const
114  {
115  static Matrix rfv;
116  return rfv;
117  }
118 
119  Cell diag (octave_idx_type k = 0) const;
120 
121  Cell diag (octave_idx_type m, octave_idx_type n) const;
122 
123  Cell xisalnum (void) const { return map (&octave_value::xisalnum); }
124  Cell xisalpha (void) const { return map (&octave_value::xisalpha); }
125  Cell xisascii (void) const { return map (&octave_value::xisascii); }
126  Cell xiscntrl (void) const { return map (&octave_value::xiscntrl); }
127  Cell xisdigit (void) const { return map (&octave_value::xisdigit); }
128  Cell xisgraph (void) const { return map (&octave_value::xisgraph); }
129  Cell xislower (void) const { return map (&octave_value::xislower); }
130  Cell xisprint (void) const { return map (&octave_value::xisprint); }
131  Cell xispunct (void) const { return map (&octave_value::xispunct); }
132  Cell xisspace (void) const { return map (&octave_value::xisspace); }
133  Cell xisupper (void) const { return map (&octave_value::xisupper); }
134  Cell xisxdigit (void) const { return map (&octave_value::xisxdigit); }
135  Cell xtoascii (void) const { return map (&octave_value::xtoascii); }
136  Cell xtolower (void) const { return map (&octave_value::xtolower); }
137  Cell xtoupper (void) const { return map (&octave_value::xtoupper); }
138 
139 private:
140 
141  typedef octave_value (octave_value::*ctype_mapper) (void) const;
142 
143  Cell map (ctype_mapper) const;
144 };
145 
146 template<>
148 { return v.cell_value (); }
149 
150 #endif