Mercurial > hg > octave-lyh
annotate src/ov-str-mat.h @ 8950:d865363208d6
include <iosfwd> instead of <iostream> in header files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 10 Mar 2009 13:55:52 -0400 |
parents | eb63fbe60fab |
children | 90abfd8a2895 |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
8920 | 4 2006, 2007, 2008 John W. Eaton |
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 | |
24 #if !defined (octave_char_matrix_str_h) | |
25 #define octave_char_matrix_str_h 1 | |
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" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
38 #include "ov-re-mat.h" |
2376 | 39 #include "ov-ch-mat.h" |
40 #include "ov-typeinfo.h" | |
41 | |
42 class Octave_map; | |
43 class octave_value_list; | |
44 | |
45 class tree_walker; | |
46 | |
2477 | 47 // Character matrix values with special properties for use as |
48 // strings. | |
2376 | 49 |
50 class | |
6109 | 51 OCTINTERP_API |
2376 | 52 octave_char_matrix_str : public octave_char_matrix |
53 { | |
54 public: | |
55 | |
56 octave_char_matrix_str (void) | |
57 : octave_char_matrix () { } | |
58 | |
59 octave_char_matrix_str (const charMatrix& chm) | |
60 : octave_char_matrix (chm) { } | |
61 | |
4513 | 62 octave_char_matrix_str (const charNDArray& chm) |
63 : octave_char_matrix (chm) { } | |
64 | |
3189 | 65 octave_char_matrix_str (char c) |
66 : octave_char_matrix (c) { } | |
67 | |
2376 | 68 octave_char_matrix_str (const char *s) |
69 : octave_char_matrix (s) { } | |
70 | |
3523 | 71 octave_char_matrix_str (const std::string& s) |
2376 | 72 : octave_char_matrix (s) { } |
73 | |
74 octave_char_matrix_str (const string_vector& s) | |
75 : octave_char_matrix (s) { } | |
76 | |
77 octave_char_matrix_str (const octave_char_matrix& chm) | |
78 : octave_char_matrix (chm) { } | |
79 | |
80 octave_char_matrix_str (const octave_char_matrix_str& chms) | |
81 : octave_char_matrix (chms) { } | |
82 | |
83 ~octave_char_matrix_str (void) { } | |
84 | |
5759 | 85 octave_base_value *clone (void) const { return new octave_char_matrix_str (*this); } |
86 octave_base_value *empty_clone (void) const { return new octave_char_matrix_str (); } | |
2376 | 87 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8168
diff
changeset
|
88 type_conv_info numeric_conversion_function (void) const; |
2376 | 89 |
5885 | 90 octave_value do_index_op (const octave_value_list& idx, |
91 bool resize_ok = false) | |
5400 | 92 { return do_index_op_internal (idx, resize_ok); } |
2407 | 93 |
4569 | 94 octave_value reshape (const dim_vector& new_dims) const |
95 { return octave_value (charNDArray (matrix.reshape (new_dims)), true); } | |
96 | |
5533 | 97 octave_value permute (const Array<int>& vec, bool inv = false) const |
98 { return octave_value (charNDArray (matrix.permute (vec, inv)), true); } | |
99 | |
5731 | 100 octave_value resize (const dim_vector& dv, bool fill = false) const; |
5533 | 101 |
2376 | 102 bool is_string (void) const { return true; } |
103 | |
4323 | 104 bool is_real_type (void) const { return false; } |
2376 | 105 |
4323 | 106 bool is_matrix_type (void) const { return false; } |
3202 | 107 |
4323 | 108 bool is_numeric_type (void) const { return false; } |
3221 | 109 |
4643 | 110 double double_value (bool = false) const; |
111 | |
2376 | 112 Matrix matrix_value (bool = false) const; |
113 | |
4668 | 114 NDArray array_value (bool = false) const; |
115 | |
116 Complex complex_value (bool = false) const; | |
117 | |
118 ComplexMatrix complex_matrix_value (bool = false) const; | |
119 | |
120 ComplexNDArray complex_array_value (bool = false) const; | |
121 | |
5715 | 122 string_vector all_strings (bool pad = false) const; |
2376 | 123 |
4457 | 124 std::string string_value (bool force = false) const; |
2376 | 125 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
126 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
127 { return octave_value (matrix.sort (dim, mode), true); } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
128 |
7433 | 129 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
130 sortmode mode = ASCENDING) const |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
131 { return octave_value (matrix.sort (sidx, dim, mode), true); } |
7433 | 132 |
3219 | 133 bool print_as_scalar (void) const { return (rows () <= 1); } |
2901 | 134 |
3523 | 135 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901 | 136 |
6974 | 137 bool save_ascii (std::ostream& os); |
4687 | 138 |
139 bool load_ascii (std::istream& is); | |
140 | |
141 bool save_binary (std::ostream& os, bool& save_as_floats); | |
142 | |
143 bool load_binary (std::istream& is, bool swap, | |
144 oct_mach_info::float_format fmt); | |
145 | |
146 #if defined (HAVE_HDF5) | |
147 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); | |
148 | |
149 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); | |
150 #endif | |
151 | |
4944 | 152 int write (octave_stream& os, int block_size, |
153 oct_data_conv::data_type output_type, int skip, | |
154 oct_mach_info::float_format flt_fmt) const | |
155 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } | |
156 | |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
157 octave_value xisalnum (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
158 octave_value xisalpha (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
159 octave_value xisascii (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
160 octave_value xiscntrl (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
161 octave_value xisdigit (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
162 octave_value xisgraph (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
163 octave_value xislower (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
164 octave_value xisprint (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
165 octave_value xispunct (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
166 octave_value xisspace (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
167 octave_value xisupper (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
168 octave_value xisxdigit (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
169 octave_value xtoascii (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
170 octave_value xtolower (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
171 octave_value xtoupper (void) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
172 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
173 #define MAT_MAPPER(MAP) \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
174 octave_value MAP (void) const \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
175 { \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
176 octave_matrix m (array_value (true)); \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
177 return m.MAP (); \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
178 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
179 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
180 MAT_MAPPER (abs) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
181 MAT_MAPPER (angle) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
182 MAT_MAPPER (arg) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
183 MAT_MAPPER (ceil) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
184 MAT_MAPPER (conj) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
185 MAT_MAPPER (fix) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
186 MAT_MAPPER (floor) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
187 MAT_MAPPER (imag) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
188 MAT_MAPPER (real) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
189 MAT_MAPPER (round) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
190 MAT_MAPPER (signum) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
191 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
192 #undef MAT_MAPPER |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
193 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
194 #define BOOL_MAT_MAPPER(MAP, VAL) \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
195 octave_value MAP (void) const \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
196 { \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
197 return boolNDArray (matrix.dims (), VAL); \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
198 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
199 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
200 BOOL_MAT_MAPPER (finite, true) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
201 BOOL_MAT_MAPPER (isinf, false) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
202 BOOL_MAT_MAPPER (isna, false) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
203 BOOL_MAT_MAPPER (isnan, false) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
204 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
205 #undef BOOL_MAT_MAPPER |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
206 |
5400 | 207 protected: |
208 | |
209 octave_value do_index_op_internal (const octave_value_list& idx, | |
5885 | 210 bool resize_ok, char type = '"'); |
5400 | 211 |
2376 | 212 private: |
213 | |
3219 | 214 DECLARE_OCTAVE_ALLOCATOR |
2376 | 215 |
3219 | 216 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376 | 217 }; |
218 | |
5279 | 219 typedef octave_char_matrix_str octave_char_matrix_dq_str; |
220 | |
221 class | |
222 octave_char_matrix_sq_str : public octave_char_matrix_str | |
223 { | |
224 public: | |
225 | |
226 octave_char_matrix_sq_str (void) | |
227 : octave_char_matrix_str () { } | |
228 | |
229 octave_char_matrix_sq_str (const charMatrix& chm) | |
230 : octave_char_matrix_str (chm) { } | |
231 | |
232 octave_char_matrix_sq_str (const charNDArray& chm) | |
233 : octave_char_matrix_str (chm) { } | |
234 | |
235 octave_char_matrix_sq_str (char c) | |
236 : octave_char_matrix_str (c) { } | |
237 | |
238 octave_char_matrix_sq_str (const char *s) | |
239 : octave_char_matrix_str (s) { } | |
240 | |
241 octave_char_matrix_sq_str (const std::string& s) | |
242 : octave_char_matrix_str (s) { } | |
243 | |
244 octave_char_matrix_sq_str (const string_vector& s) | |
245 : octave_char_matrix_str (s) { } | |
246 | |
247 octave_char_matrix_sq_str (const octave_char_matrix_str& chm) | |
248 : octave_char_matrix_str (chm) { } | |
249 | |
250 octave_char_matrix_sq_str (const octave_char_matrix_sq_str& chms) | |
251 : octave_char_matrix_str (chms) { } | |
252 | |
253 ~octave_char_matrix_sq_str (void) { } | |
254 | |
5759 | 255 octave_base_value *clone (void) const { return new octave_char_matrix_sq_str (*this); } |
256 octave_base_value *empty_clone (void) const { return new octave_char_matrix_sq_str (); } | |
5279 | 257 |
5533 | 258 octave_value reshape (const dim_vector& new_dims) const |
259 { return octave_value (charNDArray (matrix.reshape (new_dims)), true, '\''); } | |
260 | |
261 octave_value permute (const Array<int>& vec, bool inv = false) const | |
262 { return octave_value (charNDArray (matrix.permute (vec, inv)), true, '\''); } | |
263 | |
5890 | 264 octave_value resize (const dim_vector& dv, bool = false) const |
5533 | 265 { |
266 charNDArray retval (matrix); | |
267 retval.resize (dv); | |
268 return octave_value (retval, true, '\''); | |
269 } | |
270 | |
5279 | 271 bool is_sq_string (void) const { return true; } |
272 | |
5885 | 273 octave_value do_index_op (const octave_value_list& idx, |
274 bool resize_ok = false) | |
5400 | 275 { return do_index_op_internal (idx, resize_ok, '\''); } |
276 | |
7433 | 277 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
278 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
279 { return octave_value (matrix.sort (dim, mode), true, '\''); } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
280 |
7433 | 281 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
282 sortmode mode = ASCENDING) const |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
283 { return octave_value (matrix.sort (sidx, dim, mode), true, '\''); } |
7433 | 284 |
5279 | 285 private: |
286 | |
287 DECLARE_OCTAVE_ALLOCATOR | |
288 | |
289 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
290 }; | |
291 | |
2376 | 292 #endif |
293 | |
294 /* | |
295 ;;; Local Variables: *** | |
296 ;;; mode: C++ *** | |
297 ;;; End: *** | |
298 */ |