Mercurial > octave-nkf
annotate libinterp/octave-value/ov-ch-mat.cc @ 20595:c1a6c31ac29a
eliminate more simple uses of error_state
* ov-classdef.cc: Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Oct 2015 00:20:02 -0400 |
parents | 7fa170cc14fe |
children |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18129
diff
changeset
|
3 Copyright (C) 1996-2015 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 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
9941
1369f13ae6b2
several fixes by M. Goffioul
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
28 #include <cctype> |
3503 | 29 #include <iostream> |
2901 | 30 |
2376 | 31 #include "lo-ieee.h" |
32 #include "mx-base.h" | |
33 | |
15149
62a35ae7d6a2
use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents:
15057
diff
changeset
|
34 #include "mxarray.h" |
3219 | 35 #include "ov-base.h" |
36 #include "ov-base-mat.h" | |
37 #include "ov-base-mat.cc" | |
2376 | 38 #include "ov-ch-mat.h" |
39 #include "gripes.h" | |
40 #include "pr-output.h" | |
41 | |
4513 | 42 template class octave_base_matrix<charNDArray>; |
2376 | 43 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
44 idx_vector |
18129
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
45 octave_char_matrix::index_vector (bool /* require_integers */) const |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
46 { |
6720 | 47 const char *p = matrix.data (); |
48 if (numel () == 1 && *p == ':') | |
49 return idx_vector (':'); | |
50 else | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 return idx_vector (array_value (true)); |
6720 | 52 } |
53 | |
2376 | 54 double |
55 octave_char_matrix::double_value (bool) const | |
56 { | |
4102 | 57 double retval = lo_ieee_nan_value (); |
2376 | 58 |
4455 | 59 if (rows () > 0 && columns () > 0) |
60 { | |
14469
29aabe9b37a2
Rename array-as-vector, array-as-scalar warning IDs to match documentation (bug #35838)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
61 gripe_implicit_conversion ("Octave:array-to-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
62 "character matrix", "real scalar"); |
4455 | 63 |
8956
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
64 retval = static_cast<unsigned char> (matrix (0, 0)); |
4455 | 65 } |
2376 | 66 else |
67 gripe_invalid_conversion ("character matrix", "real scalar"); | |
68 | |
69 return retval; | |
70 } | |
71 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
72 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
73 octave_char_matrix::float_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
74 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
75 float retval = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
76 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
77 if (rows () > 0 && columns () > 0) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
78 { |
14469
29aabe9b37a2
Rename array-as-vector, array-as-scalar warning IDs to match documentation (bug #35838)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
79 gripe_implicit_conversion ("Octave:array-to-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
80 "character matrix", "real scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
81 |
8956
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
82 retval = static_cast<unsigned char> (matrix (0, 0)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
83 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
84 else |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
85 gripe_invalid_conversion ("character matrix", "real scalar"); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
86 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
87 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
88 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
89 |
20287
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
90 octave_int64 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
91 octave_char_matrix::int64_scalar_value () const |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
92 { |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
93 octave_int64 retval = 0; |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
94 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
95 if (rows () > 0 && columns () > 0) |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
96 { |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
97 gripe_implicit_conversion ("Octave:array-to-scalar", |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
98 "character matrix", "int64 scalar"); |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
99 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
100 retval = octave_int64 (matrix (0, 0)); |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
101 } |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
102 else |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
103 gripe_invalid_conversion ("character matrix", "int64 scalar"); |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
104 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
105 return retval; |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
106 } |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
107 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
108 octave_uint64 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
109 octave_char_matrix::uint64_scalar_value () const |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
110 { |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
111 octave_uint64 retval = 0; |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
112 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
113 if (rows () > 0 && columns () > 0) |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
114 { |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
115 gripe_implicit_conversion ("Octave:array-to-scalar", |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
116 "character matrix", "uint64 scalar"); |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
117 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
118 retval = octave_uint64 (matrix (0, 0)); |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
119 } |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
120 else |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
121 gripe_invalid_conversion ("character matrix", "uint64 scalar"); |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
122 |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
123 return retval; |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
124 } |
7fa170cc14fe
Return correct hex value for printf when used with string inputs (bug #45263).
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
125 |
2376 | 126 Complex |
127 octave_char_matrix::complex_value (bool) const | |
128 { | |
4102 | 129 double tmp = lo_ieee_nan_value (); |
130 | |
131 Complex retval (tmp, tmp); | |
2376 | 132 |
4455 | 133 if (rows () > 0 && columns () > 0) |
134 { | |
14469
29aabe9b37a2
Rename array-as-vector, array-as-scalar warning IDs to match documentation (bug #35838)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
135 gripe_implicit_conversion ("Octave:array-to-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
136 "character matrix", "complex scalar"); |
4455 | 137 |
8956
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
138 retval = static_cast<unsigned char> (matrix (0, 0)); |
4455 | 139 } |
2376 | 140 else |
141 gripe_invalid_conversion ("character matrix", "complex scalar"); | |
142 | |
143 return retval; | |
144 } | |
145 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
146 FloatComplex |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
147 octave_char_matrix::float_complex_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
148 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
149 float tmp = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
150 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
151 FloatComplex retval (tmp, tmp); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
152 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
153 if (rows () > 0 && columns () > 0) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
154 { |
14469
29aabe9b37a2
Rename array-as-vector, array-as-scalar warning IDs to match documentation (bug #35838)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
155 gripe_implicit_conversion ("Octave:array-to-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
156 "character matrix", "complex scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
157 |
8956
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
158 retval = static_cast<unsigned char> (matrix (0, 0)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
159 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
160 else |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
161 gripe_invalid_conversion ("character matrix", "complex scalar"); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
162 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
163 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
164 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
165 |
4643 | 166 void |
167 octave_char_matrix::print_raw (std::ostream& os, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
168 bool pr_as_read_syntax) const |
4643 | 169 { |
170 octave_print_internal (os, matrix, pr_as_read_syntax, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
171 current_print_indent_level ()); |
4643 | 172 } |
173 | |
5900 | 174 mxArray * |
175 octave_char_matrix::as_mxArray (void) const | |
176 { | |
177 mxArray *retval = new mxArray (mxCHAR_CLASS, dims (), mxREAL); | |
178 | |
179 mxChar *pr = static_cast<mxChar *> (retval->get_data ()); | |
180 | |
6686 | 181 mwSize nel = numel (); |
5900 | 182 |
183 const char *p = matrix.data (); | |
184 | |
6686 | 185 for (mwIndex i = 0; i < nel; i++) |
5900 | 186 pr[i] = p[i]; |
187 | |
188 return retval; | |
189 } | |
190 | |
15491
c9844b82945f
reformat interesting comment
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15452
diff
changeset
|
191 // The C++ standard guarantees cctype defines functions, not macros (and |
c9844b82945f
reformat interesting comment
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15452
diff
changeset
|
192 // hence macros *CAN'T* be defined if only cctype is included) so |
15850
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
193 // there's no need to fuck around. The exceptions are isascii and |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
194 // toascii, which are not C++. Oddly enough, all those character |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
195 // functions are int (*) (int), even in C++. Wicked! |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
196 static inline int xisascii (int c) |
15850
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
197 { |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
198 #ifdef HAVE_ISASCII |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
199 return isascii (c); |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
200 #else |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
201 return (c >= 0x00 && c <= 0x7f); |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
202 #endif |
ffd1a99733bd
build: Check for isascii() before using it.
Rik <rik@octave.org>
parents:
15501
diff
changeset
|
203 } |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
8956
diff
changeset
|
204 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
205 static inline int xtoascii (int c) |
15452
4d960b078272
build: Remove unnecessary AC_CHECK_FUNCS calls.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
206 { |
4d960b078272
build: Remove unnecessary AC_CHECK_FUNCS calls.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
207 #ifdef HAVE_TOASCII |
4d960b078272
build: Remove unnecessary AC_CHECK_FUNCS calls.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
208 return toascii (c); |
4d960b078272
build: Remove unnecessary AC_CHECK_FUNCS calls.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
209 #else |
4d960b078272
build: Remove unnecessary AC_CHECK_FUNCS calls.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
210 return (c & 0x7F); |
4d960b078272
build: Remove unnecessary AC_CHECK_FUNCS calls.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
211 #endif |
4d960b078272
build: Remove unnecessary AC_CHECK_FUNCS calls.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
212 } |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
213 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
214 octave_value |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
215 octave_char_matrix::map (unary_mapper_t umap) const |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
216 { |
15501
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
217 octave_value retval; |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
218 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
219 switch (umap) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
220 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
221 #define STRING_MAPPER(UMAP,FCN,TYPE) \ |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
222 case umap_ ## UMAP: \ |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
223 return octave_value (matrix.map<TYPE, int (&) (int)> (FCN)) |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
8956
diff
changeset
|
224 |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
225 STRING_MAPPER (xisalnum, std::isalnum, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
226 STRING_MAPPER (xisalpha, std::isalpha, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
227 STRING_MAPPER (xisascii, xisascii, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
228 STRING_MAPPER (xiscntrl, std::iscntrl, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
229 STRING_MAPPER (xisdigit, std::isdigit, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
230 STRING_MAPPER (xisgraph, std::isgraph, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
231 STRING_MAPPER (xislower, std::islower, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
232 STRING_MAPPER (xisprint, std::isprint, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
233 STRING_MAPPER (xispunct, std::ispunct, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
234 STRING_MAPPER (xisspace, std::isspace, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
235 STRING_MAPPER (xisupper, std::isupper, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
236 STRING_MAPPER (xisxdigit, std::isxdigit, bool); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
237 STRING_MAPPER (xtoascii, xtoascii, double); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
238 STRING_MAPPER (xtolower, std::tolower, char); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
239 STRING_MAPPER (xtoupper, std::toupper, char); |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
8956
diff
changeset
|
240 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
241 // For Matlab compatibility, these should work on ASCII values |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
242 // without error or warning. |
15501
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
243 case umap_abs: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
244 case umap_ceil: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
245 case umap_fix: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
246 case umap_floor: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
247 case umap_imag: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
248 case umap_isinf: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
249 case umap_isnan: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
250 case umap_real: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
251 case umap_round: |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
252 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
253 octave_matrix m (array_value (true)); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
254 return m.map (umap); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
255 } |
15501
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
256 |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
257 default: |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
258 error ("%s: expecting numeric argument", get_umap_name (umap)); |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
259 break; |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
260 } |
15501
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
261 |
814c4b0d5c49
make numeric mapper functions throw error for char args (bug #37535)
John W. Eaton <jwe@octave.org>
parents:
15491
diff
changeset
|
262 return retval; |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
263 } |