Mercurial > octave-nkf
annotate src/ov-cell.h @ 10594:4b421123fd17
__errplot__.m: Fix bug parsing errorbar style.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 30 Apr 2010 18:28:21 -0400 |
parents | 4d1fc073fbb7 |
children | 604e13a89c7f |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
7017 | 4 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
5 Copyright (C) 2009, 2010 VZLU Prague |
3353 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
3353 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
3353 | 22 |
23 */ | |
24 | |
25 #if !defined (octave_cell_h) | |
26 #define octave_cell_h 1 | |
27 | |
28 #include <cstdlib> | |
29 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
30 #include <iosfwd> |
3353 | 31 #include <string> |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
32 #include <memory> |
3353 | 33 |
34 #include "mx-base.h" | |
35 #include "oct-alloc.h" | |
36 #include "str-vec.h" | |
37 | |
38 #include "Cell.h" | |
39 #include "error.h" | |
3928 | 40 #include "ov-base-mat.h" |
3353 | 41 #include "ov-typeinfo.h" |
42 | |
43 class Octave_map; | |
44 class octave_value_list; | |
45 | |
46 class tree_walker; | |
47 | |
48 // Cells. | |
49 | |
50 class | |
3928 | 51 octave_cell : public octave_base_matrix<Cell> |
3353 | 52 { |
53 public: | |
54 | |
55 octave_cell (void) | |
3928 | 56 : octave_base_matrix<Cell> () { } |
3353 | 57 |
58 octave_cell (const Cell& c) | |
3928 | 59 : octave_base_matrix<Cell> (c) { } |
3353 | 60 |
8825
c3445f1c8cb4
reuse cellstr cache in strcmp
Jaroslav Hajek <highegg@gmail.com>
parents:
8823
diff
changeset
|
61 octave_cell (const Array<std::string>& str) |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
62 : octave_base_matrix<Cell> (Cell (str)), cellstr_cache (new Array<std::string> (str)) { } |
8825
c3445f1c8cb4
reuse cellstr cache in strcmp
Jaroslav Hajek <highegg@gmail.com>
parents:
8823
diff
changeset
|
63 |
3353 | 64 octave_cell (const octave_cell& c) |
3928 | 65 : octave_base_matrix<Cell> (c) { } |
3353 | 66 |
67 ~octave_cell (void) { } | |
68 | |
5759 | 69 octave_base_value *clone (void) const { return new octave_cell (*this); } |
70 octave_base_value *empty_clone (void) const { return new octave_cell (); } | |
3353 | 71 |
3928 | 72 #if 0 |
5759 | 73 octave_base_value *try_narrowing_conversion (void); |
3928 | 74 #endif |
75 | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
76 octave_value subsref (const std::string& type, |
10313 | 77 const std::list<octave_value_list>& idx) |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
78 { |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
79 octave_value_list tmp = subsref (type, idx, 1); |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
80 return tmp.length () > 0 ? tmp(0) : octave_value (); |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
81 } |
7622
c195bd0a5c64
treat structs and cells as "constants"
John W. Eaton <jwe@octave.org>
parents:
7530
diff
changeset
|
82 |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
83 octave_value_list subsref (const std::string& type, |
10313 | 84 const std::list<octave_value_list>& idx, int); |
4271 | 85 |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
7651
diff
changeset
|
86 octave_value subsref (const std::string& type, |
10313 | 87 const std::list<octave_value_list>& idx, |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
7651
diff
changeset
|
88 bool auto_add); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
7651
diff
changeset
|
89 |
4247 | 90 octave_value subsasgn (const std::string& type, |
10313 | 91 const std::list<octave_value_list>& idx, |
92 const octave_value& rhs); | |
3933 | 93 |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
94 void assign (const octave_value_list& idx, const Cell& rhs); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
95 |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
96 void assign (const octave_value_list& idx, const octave_value& rhs); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
97 |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
98 void delete_elements (const octave_value_list& idx); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
99 |
4791 | 100 size_t byte_size (void) const; |
101 | |
8732 | 102 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const; |
103 | |
104 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, | |
10313 | 105 sortmode mode = ASCENDING) const; |
8732 | 106 |
8823
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
107 sortmode is_sorted (sortmode mode = UNSORTED) const; |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
108 |
8733
3ef774603887
rename all uses of sortrows_idx to sort_rows_idx
John W. Eaton <jwe@octave.org>
parents:
8732
diff
changeset
|
109 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const; |
8732 | 110 |
8823
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
111 sortmode is_sorted_rows (sortmode mode = UNSORTED) const; |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
112 |
4645 | 113 bool is_matrix_type (void) const { return false; } |
114 | |
4370 | 115 bool is_numeric_type (void) const { return false; } |
116 | |
3928 | 117 bool is_defined (void) const { return true; } |
3353 | 118 |
7622
c195bd0a5c64
treat structs and cells as "constants"
John W. Eaton <jwe@octave.org>
parents:
7530
diff
changeset
|
119 bool is_constant (void) const { return true; } |
4994 | 120 |
3724 | 121 bool is_cell (void) const { return true; } |
122 | |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10065
diff
changeset
|
123 builtin_type_t builtin_type (void) const { return btyp_cell; } |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10065
diff
changeset
|
124 |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
125 bool is_cellstr (void) const; |
6116 | 126 |
8626
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8551
diff
changeset
|
127 bool is_true (void) const; |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8551
diff
changeset
|
128 |
3928 | 129 Cell cell_value (void) const { return matrix; } |
3353 | 130 |
3933 | 131 octave_value_list list_value (void) const; |
132 | |
5715 | 133 octave_value convert_to_str_internal (bool pad, bool, char type) const |
134 { return octave_value (all_strings (pad), type); } | |
4358 | 135 |
5715 | 136 string_vector all_strings (bool pad = false) const; |
4243 | 137 |
8732 | 138 Array<std::string> cellstr_value (void) const; |
139 | |
4604 | 140 bool print_as_scalar (void) const; |
141 | |
3933 | 142 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
143 | |
144 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; | |
145 | |
4687 | 146 |
6974 | 147 bool save_ascii (std::ostream& os); |
4687 | 148 |
149 bool load_ascii (std::istream& is); | |
150 | |
151 bool save_binary (std::ostream& os, bool& save_as_floats); | |
152 | |
153 bool load_binary (std::istream& is, bool swap, | |
10313 | 154 oct_mach_info::float_format fmt); |
4687 | 155 |
156 #if defined (HAVE_HDF5) | |
157 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); | |
158 | |
9881
b3089dba88bf
Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents:
9813
diff
changeset
|
159 bool load_hdf5 (hid_t loc_id, const char *name); |
4687 | 160 #endif |
161 | |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
162 octave_value map (unary_mapper_t umap) const; |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
163 |
5900 | 164 mxArray *as_mxArray (void) const; |
165 | |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
166 // Unsafe. This function exists to support the MEX interface. |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
167 // You should not use it anywhere else. |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
168 void *mex_get_data (void) const; |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
169 |
3353 | 170 private: |
4612 | 171 |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
172 void clear_cellstr_cache (void) const |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
173 { cellstr_cache.reset (); } |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
174 |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
175 mutable std::auto_ptr<Array<std::string> > cellstr_cache; |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
176 |
3353 | 177 DECLARE_OCTAVE_ALLOCATOR |
178 | |
179 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
180 }; | |
181 | |
182 #endif |