Mercurial > octave
annotate libinterp/corefcn/Cell.h @ 27023:fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
* Cell.h, CDiagMatrix.h, CMatrix.h, PermMatrix.h, Range.h,
boolMatrix.h, chMatrix.h, dDiagMatrix.h, dMatrix.h, fCDiagMatrix.h,
fCMatrix.h, fDiagMatrix.h, fMatrix.h, intNDArray.h:
Explicitly declare default constructor, copy constructor, assignment
operator, and destructor as "default".
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 03 Apr 2019 16:03:16 +0000 |
parents | 00f796120a6d |
children | b442ec6dda5c |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
3 Copyright (C) 1999-2019 John W. Eaton |
11523 | 4 Copyright (C) 2009-2010 VZLU Prague |
3353 | 5 |
6 This file is part of Octave. | |
7 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23677
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23677
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
11 (at your option) any later version. |
3353 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 GNU General Public License for more details. |
3353 | 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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23677
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
3353 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
24 #if ! defined (octave_Cell_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
25 #define octave_Cell_h 1 |
3353 | 26 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
28 |
3353 | 29 #include <string> |
30 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
31 #include "Array.h" |
3353 | 32 #include "str-vec.h" |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
33 #include "ov.h" |
3353 | 34 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
35 class octave_value_list; |
3353 | 36 |
37 class | |
6169 | 38 OCTINTERP_API |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
39 Cell : public Array<octave_value> |
3353 | 40 { |
41 public: | |
42 | |
27023
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
43 Cell (void) = default; |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
44 |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
45 Cell (const Cell& c) = default; |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
46 |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
47 Cell& operator = (const Cell& c) = default; |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
48 |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
49 ~Cell (void) = default; |
3928 | 50 |
51 Cell (const octave_value& val) | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
52 : Array<octave_value> (dim_vector (1, 1), val) { } |
4513 | 53 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
54 Cell (const octave_value_list& ovl); |
3353 | 55 |
7209 | 56 Cell (octave_idx_type n, octave_idx_type m, |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
57 const octave_value& val = Matrix ()) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
58 : Array<octave_value> (dim_vector (n, m), val) { } |
3353 | 59 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
60 Cell (const dim_vector& dv, const octave_value& val = Matrix ()) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
61 : Array<octave_value> (dv, val) { } |
3354 | 62 |
4567 | 63 Cell (const Array<octave_value>& c) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
64 : Array<octave_value> (c) { } |
4567 | 65 |
5275 | 66 Cell (const Array<octave_value>& c, octave_idx_type nr, octave_idx_type nc) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
67 : Array<octave_value> (c, dim_vector (nr, nc)) { } |
3933 | 68 |
5805 | 69 Cell (const string_vector& sv, bool trim = false); |
4216 | 70 |
23677
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
71 // Constructor for standard containers. V must be convertible to an |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
72 // octave_value object. |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
73 template <typename V, template <typename...> class C> |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
74 explicit |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
75 Cell (const C<V>& container) |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
76 : Array<octave_value> () |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
77 { |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
78 size_t n = container.size (); |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
79 |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
80 if (n > 0) |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
81 { |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
82 resize (dim_vector (n, 1)); |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
83 |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
84 octave_idx_type i = 0; |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
85 |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
86 for (const auto& val : container) |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
87 elem(i++,0) = val; |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
88 } |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
89 } |
11037
e7864673c31f
new Cell (std::list<std::string>&) constructor
John W. Eaton <jwe@octave.org>
parents:
10757
diff
changeset
|
90 |
8732 | 91 Cell (const Array<std::string>& sa); |
92 | |
6116 | 93 Cell (const dim_vector& dv, const string_vector& sv, bool trim = false); |
94 | |
23575
e95738a119da
maint: Deprecate is_cellstr and replace with iscellstr.
Rik <rik@octave.org>
parents:
23355
diff
changeset
|
95 bool iscellstr (void) const; |
6116 | 96 |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
97 Array<std::string> cellstr_value (void) const; |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
98 |
23355
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
99 string_vector string_vector_value (void) const; |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
100 |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
101 using Array<octave_value>::index; |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
102 |
4513 | 103 Cell index (const octave_value_list& idx, bool resize_ok = false) const; |
104 | |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
105 using Array<octave_value>::delete_elements; |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
106 |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
107 void delete_elements (const octave_value_list& idx); |
8175
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
108 |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
109 using Array<octave_value>::assign; |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
110 |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
111 void assign (const octave_value_list& idx, const Cell& rhs, |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
112 const octave_value& fill_val = Matrix ()); |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
113 |
4901 | 114 Cell 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
|
115 { return Array<octave_value>::reshape (new_dims); } |
4901 | 116 |
5602 | 117 octave_idx_type nnz (void) const; |
118 | |
5570 | 119 Cell column (octave_idx_type i) const; |
120 | |
5775 | 121 // FIXME |
4932 | 122 boolMatrix all (int /* dim */ = 0) const { return boolMatrix (); } |
3933 | 123 |
5775 | 124 // FIXME |
4932 | 125 boolMatrix any (int /* dim */ = 0) const { return boolMatrix (); } |
3933 | 126 |
5275 | 127 Cell concat (const Cell& rb, const Array<octave_idx_type>& ra_idx); |
4915 | 128 |
5275 | 129 Cell& insert (const Cell& a, octave_idx_type r, octave_idx_type c); |
130 Cell& insert (const Cell& a, const Array<octave_idx_type>& ra_idx); | |
4806 | 131 |
5775 | 132 // FIXME |
8626
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8579
diff
changeset
|
133 bool any_element_is_nan (void) const { return false; } |
3933 | 134 bool is_true (void) const { return false; } |
135 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
136 octave_value resize_fill_value (void) const; |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
137 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7618
diff
changeset
|
138 Cell diag (octave_idx_type k = 0) const; |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7530
diff
changeset
|
139 |
14557
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
140 Cell diag (octave_idx_type m, octave_idx_type n) const; |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
141 |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
142 Cell xisalnum (void) const { return map (&octave_value::xisalnum); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
143 Cell xisalpha (void) const { return map (&octave_value::xisalpha); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
144 Cell xisascii (void) const { return map (&octave_value::xisascii); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
145 Cell xiscntrl (void) const { return map (&octave_value::xiscntrl); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
146 Cell xisdigit (void) const { return map (&octave_value::xisdigit); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
147 Cell xisgraph (void) const { return map (&octave_value::xisgraph); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
148 Cell xislower (void) const { return map (&octave_value::xislower); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
149 Cell xisprint (void) const { return map (&octave_value::xisprint); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
150 Cell xispunct (void) const { return map (&octave_value::xispunct); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
151 Cell xisspace (void) const { return map (&octave_value::xisspace); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
152 Cell xisupper (void) const { return map (&octave_value::xisupper); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
153 Cell xisxdigit (void) const { return map (&octave_value::xisxdigit); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
154 Cell xtolower (void) const { return map (&octave_value::xtolower); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
155 Cell xtoupper (void) const { return map (&octave_value::xtoupper); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
156 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
157 private: |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
158 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
159 typedef octave_value (octave_value::*ctype_mapper) (void) const; |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
160 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
161 Cell map (ctype_mapper) const; |
3353 | 162 }; |
163 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
164 template <> |
10757
1cc44f3ec814
templated extractors for maps and cells
Jaroslav Hajek <highegg@gmail.com>
parents:
10649
diff
changeset
|
165 inline Cell octave_value_extract<Cell> (const octave_value& v) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 { return v.cell_value (); } |
10757
1cc44f3ec814
templated extractors for maps and cells
Jaroslav Hajek <highegg@gmail.com>
parents:
10649
diff
changeset
|
167 |
3353 | 168 #endif |