GNU Octave  4.2.1
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
ov-cell.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1999-2017 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_ov_cell_h)
25 #define octave_ov_cell_h 1
26 
27 #include "octave-config.h"
28 
29 #include <cstdlib>
30 
31 #include <iosfwd>
32 #include <string>
33 #include <memory>
34 
35 #include "mx-base.h"
36 #include "str-vec.h"
37 
38 #include "Cell.h"
39 #include "error.h"
40 #include "ov-base-mat.h"
41 #include "ov-typeinfo.h"
42 
43 class octave_value_list;
44 
45 class tree_walker;
46 
47 // Cells.
48 
49 class
51 {
52 public:
53 
54  octave_cell (void)
55  : octave_base_matrix<Cell> (), cellstr_cache () { }
56 
57  octave_cell (const Cell& c)
58  : octave_base_matrix<Cell> (c), cellstr_cache () { }
59 
61  : octave_base_matrix<Cell> (Cell (str)),
62  cellstr_cache (new Array<std::string> (str)) { }
63 
65  : octave_base_matrix<Cell> (c), cellstr_cache () { }
66 
67  ~octave_cell (void) { }
68 
69  octave_base_value *clone (void) const { return new octave_cell (*this); }
70  octave_base_value *empty_clone (void) const { return new octave_cell (); }
71 
72 #if 0
73  octave_base_value *try_narrowing_conversion (void);
74 #endif
75 
77  const std::list<octave_value_list>& idx)
78  {
79  octave_value_list tmp = subsref (type, idx, 1);
80  return tmp.length () > 0 ? tmp(0) : octave_value ();
81  }
82 
84  const std::list<octave_value_list>& idx,
85  int nargout)
86  {
87  return subsref (type, idx, nargout, 0);
88  }
89 
91  const std::list<octave_value_list>& idx,
92  int nargout,
93  const std::list<octave_lvalue> *lvalue_list);
94 
96  const std::list<octave_value_list>& idx,
97  bool auto_add);
98 
100  const std::list<octave_value_list>& idx,
101  const octave_value& rhs);
102 
103  void assign (const octave_value_list& idx, const Cell& rhs);
104 
105  void assign (const octave_value_list& idx, const octave_value& rhs);
106 
107  void delete_elements (const octave_value_list& idx);
108 
109  size_t byte_size (void) const;
110 
111  octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const;
112 
114  sortmode mode = ASCENDING) const;
115 
116  sortmode is_sorted (sortmode mode = UNSORTED) const;
117 
118  Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
119 
120  sortmode is_sorted_rows (sortmode mode = UNSORTED) const;
121 
122  bool is_matrix_type (void) const { return false; }
123 
124  bool is_numeric_type (void) const { return false; }
125 
126  bool is_defined (void) const { return true; }
127 
128  bool is_constant (void) const { return true; }
129 
130  bool is_cell (void) const { return true; }
131 
132  builtin_type_t builtin_type (void) const { return btyp_cell; }
133 
134  bool is_cellstr (void) const;
135 
136  bool is_true (void) const;
137 
138  Cell cell_value (void) const { return matrix; }
139 
140  octave_value_list list_value (void) const;
141 
142  octave_value convert_to_str_internal (bool pad, bool, char type) const
143  { return octave_value (string_vector_value (pad), type); }
144 
145  string_vector string_vector_value (bool pad = false) const;
146 
147  Array<std::string> cellstr_value (void) const;
148 
149  Array<std::string> cellstr_value (const char *fmt, ...) const;
150 
151  bool print_as_scalar (void) const;
152 
153  void print (std::ostream& os, bool pr_as_read_syntax = false);
154 
155  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
156 
157  void short_disp (std::ostream& os) const;
158 
159  bool save_ascii (std::ostream& os);
160 
161  bool load_ascii (std::istream& is);
162 
163  bool save_binary (std::ostream& os, bool& save_as_floats);
164 
165  bool load_binary (std::istream& is, bool swap,
167 
168  bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats);
169 
170  bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
171 
172  octave_value map (unary_mapper_t umap) const;
173 
174  mxArray *as_mxArray (void) const;
175 
176  // Unsafe. This function exists to support the MEX interface.
177  // You should not use it anywhere else.
178  void *mex_get_data (void) const;
179 
180 private:
181 
182  void clear_cellstr_cache (void) const
183  { cellstr_cache.reset (); }
184 
185  mutable std::unique_ptr<Array<std::string> > cellstr_cache;
186 
188 };
189 
190 #endif
octave_cell(const Array< std::string > &str)
Definition: ov-cell.h:60
bool is_true(const std::string &s)
Definition: mkoctfile.cc:398
~octave_cell(void)
Definition: ov-cell.h:67
Definition: Cell.h:37
bool is_numeric_type(void) const
Definition: ov-cell.h:124
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout)
Definition: ov-cell.h:83
sortmode
Definition: oct-sort.h:105
octave_idx_type length(void) const
Definition: ovl.h:96
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6386
idx subsref(val, idx) esult
Definition: ov.cc:3080
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the then the first element defines the pivoting tolerance for the unsymmetric the values defined such that for full matrix
Definition: lu.cc:138
Cell cell_value(void) const
Definition: ov-cell.h:138
STL namespace.
octave_cell(const Cell &c)
Definition: ov-cell.h:57
builtin_type_t
Definition: ov-base.h:61
octave_cell(const octave_cell &c)
Definition: ov-cell.h:64
bool is_constant(void) const
Definition: ov-cell.h:128
bool swap
Definition: load-save.cc:725
octave_value convert_to_str_internal(bool pad, bool, char type) const
Definition: ov-cell.h:142
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:148
bool is_cell(void) const
Definition: ov-cell.h:130
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:935
bool is_defined(void) const
Definition: ov-cell.h:126
std::string str
Definition: hash.cc:118
bool save_as_floats
Definition: load-save.cc:1581
double tmp
Definition: data.cc:6300
void clear_cellstr_cache(void) const
Definition: ov-cell.h:182
builtin_type_t builtin_type(void) const
Definition: ov-cell.h:132
int64_t octave_hdf5_id
idx type
Definition: ov.cc:3129
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
std::unique_ptr< Array< std::string > > cellstr_cache
Definition: ov-cell.h:185
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-cell.h:76
octave_cell(void)
Definition: ov-cell.h:54
octave_base_value * empty_clone(void) const
Definition: ov-cell.h:70
octave_map map(dims)
octave_base_value * clone(void) const
Definition: ov-cell.h:69
idx subsasgn(val, idx, 0) esult
Definition: ov.cc:3129
bool is_matrix_type(void) const
Definition: ov-cell.h:122
write the output to stdout if nargout is
Definition: load-save.cc:1576
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))