Mercurial > hg > octave-nkf
annotate libinterp/octave-value/ov-str-mat.h @ 19795:76478d2da117
unconditionally disable the octave_allocator class
* configure.ac: Delete the --enable-octave-allocator option.
* oct-alloc.h: Delete octave_allocator class. Warn if file is
included. Unconditionally define macros to be empty.
* NEWS: Make note of these changes.
* oct-alloc.cc: Delete.
* liboctave/util/module.mk (UTIL_SRC): Remove it from the list.
* make_int.cc, Cell.h, oct-obj.cc, oct-obj.h, audiodevinfo.cc,
ov-base-int.h, ov-base-scalar.h, ov-bool-mat.cc, ov-bool-mat.h,
ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h,
ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.h,
ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc,
ov-complex.h, ov-cs-list.cc, ov-cs-list.h, ov-cx-diag.cc,
ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc,
ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc,
ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc,
ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc,
ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h,
ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc,
ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-java.cc,
ov-java.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-perm.cc, ov-perm.h,
ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc,
ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc,
ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h,
ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc,
ov-usr-fcn.h, ov.cc, ov.h, pt-const.cc, pt-const.h, idx-vector.cc,
idx-vector.h: Delete uses of oct-alloc.h and OCTAVE_ALLOCATOR macros.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 13:43:29 -0500 |
parents | 1d2e709bbbda |
children | 4197fc428c7d |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
11523 | 4 Copyright (C) 2009-2010 VZLU Prague |
2376 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2376 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2376 | 21 |
22 */ | |
23 | |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
24 #if !defined (octave_ov_str_mat_h) |
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
25 #define octave_ov_str_mat_h 1 |
2376 | 26 |
27 #include <cstdlib> | |
28 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
29 #include <iosfwd> |
2376 | 30 #include <string> |
31 | |
32 #include "mx-base.h" | |
33 #include "str-vec.h" | |
34 | |
35 #include "error.h" | |
4944 | 36 #include "oct-stream.h" |
3202 | 37 #include "ov.h" |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9688
diff
changeset
|
38 #include "ov-ch-mat.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
39 #include "ov-re-mat.h" |
2376 | 40 #include "ov-typeinfo.h" |
41 | |
42 class octave_value_list; | |
43 | |
44 class tree_walker; | |
45 | |
2477 | 46 // Character matrix values with special properties for use as |
47 // strings. | |
2376 | 48 |
49 class | |
6109 | 50 OCTINTERP_API |
2376 | 51 octave_char_matrix_str : public octave_char_matrix |
52 { | |
53 public: | |
54 | |
55 octave_char_matrix_str (void) | |
56 : octave_char_matrix () { } | |
57 | |
58 octave_char_matrix_str (const charMatrix& chm) | |
59 : octave_char_matrix (chm) { } | |
60 | |
4513 | 61 octave_char_matrix_str (const charNDArray& chm) |
62 : octave_char_matrix (chm) { } | |
63 | |
10351
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
64 octave_char_matrix_str (const Array<char>& chm) |
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
65 : octave_char_matrix (chm) { } |
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
66 |
3189 | 67 octave_char_matrix_str (char c) |
68 : octave_char_matrix (c) { } | |
69 | |
2376 | 70 octave_char_matrix_str (const char *s) |
71 : octave_char_matrix (s) { } | |
72 | |
3523 | 73 octave_char_matrix_str (const std::string& s) |
2376 | 74 : octave_char_matrix (s) { } |
75 | |
76 octave_char_matrix_str (const string_vector& s) | |
77 : octave_char_matrix (s) { } | |
78 | |
79 octave_char_matrix_str (const octave_char_matrix& chm) | |
80 : octave_char_matrix (chm) { } | |
81 | |
82 octave_char_matrix_str (const octave_char_matrix_str& chms) | |
83 : octave_char_matrix (chms) { } | |
84 | |
85 ~octave_char_matrix_str (void) { } | |
86 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
87 octave_base_value *clone (void) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
88 { return new octave_char_matrix_str (*this); } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 octave_base_value *empty_clone (void) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
90 { return new octave_char_matrix_str (); } |
2376 | 91 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8168
diff
changeset
|
92 type_conv_info numeric_conversion_function (void) const; |
2376 | 93 |
5885 | 94 octave_value do_index_op (const octave_value_list& idx, |
10313 | 95 bool resize_ok = false) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 { return do_index_op_internal (idx, resize_ok); } |
2407 | 97 |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
98 octave_value squeeze (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 { return octave_value (charNDArray (matrix.squeeze ())); } |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
100 |
4569 | 101 octave_value reshape (const dim_vector& new_dims) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 { return octave_value (charNDArray (matrix.reshape (new_dims))); } |
4569 | 103 |
5533 | 104 octave_value permute (const Array<int>& vec, bool inv = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
105 { return octave_value (charNDArray (matrix.permute (vec, inv))); } |
5533 | 106 |
5731 | 107 octave_value resize (const dim_vector& dv, bool fill = false) const; |
5533 | 108 |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
109 octave_value diag (octave_idx_type k = 0) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 { return octave_value (matrix.diag (k)); } |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
111 |
2376 | 112 bool is_string (void) const { return true; } |
113 | |
4323 | 114 bool is_numeric_type (void) const { return false; } |
3221 | 115 |
4643 | 116 double double_value (bool = false) const; |
117 | |
2376 | 118 Matrix matrix_value (bool = false) const; |
119 | |
4668 | 120 NDArray array_value (bool = false) const; |
121 | |
122 Complex complex_value (bool = false) const; | |
123 | |
124 ComplexMatrix complex_matrix_value (bool = false) const; | |
125 | |
126 ComplexNDArray complex_array_value (bool = false) const; | |
127 | |
5715 | 128 string_vector all_strings (bool pad = false) const; |
2376 | 129 |
4457 | 130 std::string string_value (bool force = false) const; |
2376 | 131 |
10729
172253d75d94
implement cellstr extractors for char matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
132 Array<std::string> cellstr_value (void) const; |
172253d75d94
implement cellstr extractors for char matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
133 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
134 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 { return octave_value (matrix.sort (dim, mode)); } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
136 |
7433 | 137 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, |
10313 | 138 sortmode mode = ASCENDING) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
139 { return octave_value (matrix.sort (sidx, dim, mode)); } |
7433 | 140 |
3219 | 141 bool print_as_scalar (void) const { return (rows () <= 1); } |
2901 | 142 |
3523 | 143 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901 | 144 |
17870 | 145 void short_disp (std::ostream& os) const; |
17825
53f433bae63b
display (possibly truncated) values of strings in workspace view
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
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 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
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:
9689
diff
changeset
|
159 bool load_hdf5 (hid_t loc_id, const char *name); |
4687 | 160 #endif |
161 | |
4944 | 162 int write (octave_stream& os, int block_size, |
10313 | 163 oct_data_conv::data_type output_type, int skip, |
164 oct_mach_info::float_format flt_fmt) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
165 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
4944 | 166 |
5400 | 167 protected: |
168 | |
169 octave_value do_index_op_internal (const octave_value_list& idx, | |
10313 | 170 bool resize_ok, char type = '"'); |
5400 | 171 |
2376 | 172 private: |
173 | |
174 | |
3219 | 175 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376 | 176 }; |
177 | |
5279 | 178 typedef octave_char_matrix_str octave_char_matrix_dq_str; |
179 | |
180 class | |
181 octave_char_matrix_sq_str : public octave_char_matrix_str | |
182 { | |
183 public: | |
184 | |
185 octave_char_matrix_sq_str (void) | |
186 : octave_char_matrix_str () { } | |
187 | |
188 octave_char_matrix_sq_str (const charMatrix& chm) | |
189 : octave_char_matrix_str (chm) { } | |
190 | |
191 octave_char_matrix_sq_str (const charNDArray& chm) | |
192 : octave_char_matrix_str (chm) { } | |
193 | |
10351
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
194 octave_char_matrix_sq_str (const Array<char>& chm) |
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
195 : octave_char_matrix_str (chm) { } |
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
196 |
5279 | 197 octave_char_matrix_sq_str (char c) |
198 : octave_char_matrix_str (c) { } | |
199 | |
200 octave_char_matrix_sq_str (const char *s) | |
201 : octave_char_matrix_str (s) { } | |
202 | |
203 octave_char_matrix_sq_str (const std::string& s) | |
204 : octave_char_matrix_str (s) { } | |
205 | |
206 octave_char_matrix_sq_str (const string_vector& s) | |
207 : octave_char_matrix_str (s) { } | |
208 | |
209 octave_char_matrix_sq_str (const octave_char_matrix_str& chm) | |
210 : octave_char_matrix_str (chm) { } | |
211 | |
212 octave_char_matrix_sq_str (const octave_char_matrix_sq_str& chms) | |
213 : octave_char_matrix_str (chms) { } | |
214 | |
215 ~octave_char_matrix_sq_str (void) { } | |
216 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 octave_base_value *clone (void) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 { return new octave_char_matrix_sq_str (*this); } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
219 octave_base_value *empty_clone (void) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
220 { return new octave_char_matrix_sq_str (); } |
5279 | 221 |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
222 octave_value squeeze (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
223 { return octave_value (charNDArray (matrix.squeeze ()), '\''); } |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
224 |
5533 | 225 octave_value reshape (const dim_vector& new_dims) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
226 { return octave_value (charNDArray (matrix.reshape (new_dims)), '\''); } |
5533 | 227 |
228 octave_value permute (const Array<int>& vec, bool inv = false) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 { return octave_value (charNDArray (matrix.permute (vec, inv)), '\''); } |
5533 | 230 |
5890 | 231 octave_value resize (const dim_vector& dv, bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
232 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
233 charNDArray retval (matrix); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
234 retval.resize (dv); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
235 return octave_value (retval, '\''); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
236 } |
5533 | 237 |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
238 octave_value diag (octave_idx_type k = 0) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
239 { return octave_value (matrix.diag (k), '\''); } |
9688
90abfd8a2895
make squeeze and diag return char for char argument
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
240 |
5279 | 241 bool is_sq_string (void) const { return true; } |
242 | |
5885 | 243 octave_value do_index_op (const octave_value_list& idx, |
10313 | 244 bool resize_ok = false) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
245 { return do_index_op_internal (idx, resize_ok, '\''); } |
5400 | 246 |
7433 | 247 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
248 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
249 { return octave_value (matrix.sort (dim, mode), '\''); } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
250 |
7433 | 251 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, |
10313 | 252 sortmode mode = ASCENDING) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
253 { return octave_value (matrix.sort (sidx, dim, mode), '\''); } |
7433 | 254 |
5279 | 255 private: |
256 | |
257 | |
258 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
259 }; | |
260 | |
2376 | 261 #endif |