Mercurial > octave
annotate libinterp/octave-value/ov-base-int.h @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
4903 | 1 /* |
2 | |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 Copyright (C) 2004-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26399
diff
changeset
|
4 |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26399
diff
changeset
|
5 See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26399
diff
changeset
|
6 or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26399
diff
changeset
|
7 |
4903 | 8 |
9 This file is part of Octave. | |
10 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24224
diff
changeset
|
11 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
|
12 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:
24224
diff
changeset
|
13 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
|
14 (at your option) any later version. |
4903 | 15 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 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
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
19 GNU General Public License for more details. |
4903 | 20 |
21 You should have received a copy of the GNU General Public License | |
7016 | 22 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:
24224
diff
changeset
|
23 <https://www.gnu.org/licenses/>. |
4903 | 24 |
25 */ | |
26 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20126
diff
changeset
|
27 #if ! defined (octave_ov_base_int_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
28 #define octave_ov_base_int_h 1 |
4903 | 29 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
30 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
31 |
4903 | 32 #include <cstdlib> |
33 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
34 #include <iosfwd> |
4903 | 35 #include <string> |
36 | |
37 #include "mx-base.h" | |
38 #include "str-vec.h" | |
39 | |
40 #include "error.h" | |
41 #include "ov-base.h" | |
42 #include "ov-base-mat.h" | |
43 #include "ov-base-scalar.h" | |
44 #include "ov-typeinfo.h" | |
45 | |
46 // base int matrix values. | |
47 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
48 template <typename T> |
4903 | 49 class |
50 octave_base_int_matrix : public octave_base_matrix<T> | |
51 { | |
52 public: | |
53 | |
54 octave_base_int_matrix (void) : octave_base_matrix<T> () { } | |
55 | |
56 octave_base_int_matrix (const T& nda) : octave_base_matrix<T> (nda) { } | |
57 | |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
58 ~octave_base_int_matrix (void) = default; |
4903 | 59 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
60 octave_base_value * clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
61 { return new octave_base_int_matrix (*this); } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
62 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
63 octave_base_value * empty_clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
64 { return new octave_base_int_matrix (); } |
4903 | 65 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
66 octave_base_value * try_narrowing_conversion (void); |
4903 | 67 |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
68 bool isreal (void) const { return true; } |
4903 | 69 |
70 // void increment (void) { matrix += 1; } | |
71 | |
72 // void decrement (void) { matrix -= 1; } | |
73 | |
74 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; | |
75 | |
5992 | 76 octave_value convert_to_str_internal (bool, bool, char type) const; |
77 | |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
78 octave_value as_double (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
79 octave_value as_single (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
80 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
81 octave_value as_int8 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
82 octave_value as_int16 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
83 octave_value as_int32 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
84 octave_value as_int64 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
85 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
86 octave_value as_uint8 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
87 octave_value as_uint16 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
88 octave_value as_uint32 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
89 octave_value as_uint64 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
90 |
24745
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
91 std::string edit_display (const float_display_format& fmt, |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
92 octave_idx_type i, octave_idx_type j) const; |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
93 |
6974 | 94 bool save_ascii (std::ostream& os); |
4903 | 95 |
96 bool load_ascii (std::istream& is); | |
97 | |
26399
586413770c7f
pass save_as_floats by value in octave_value save_binary functions
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
98 bool save_binary (std::ostream& os, bool); |
4903 | 99 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
100 bool load_binary (std::istream& is, bool swap, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
101 octave::mach_info::float_format); |
4903 | 102 |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
103 protected: |
4903 | 104 |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
105 bool save_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type, |
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
106 const char *name, bool); |
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
107 |
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
108 bool load_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type, |
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
109 const char *name); |
4903 | 110 }; |
111 | |
112 // base int scalar values. | |
113 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
114 template <typename T> |
4903 | 115 class |
116 octave_base_int_scalar : public octave_base_scalar<T> | |
117 { | |
118 public: | |
119 | |
120 octave_base_int_scalar (void) : octave_base_scalar<T> () { } | |
121 | |
122 octave_base_int_scalar (const T& s) : octave_base_scalar<T> (s) { } | |
123 | |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
124 ~octave_base_int_scalar (void) = default; |
4903 | 125 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
126 octave_base_value * clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 { return new octave_base_int_scalar (*this); } |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
128 octave_base_value * empty_clone (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 { return new octave_base_int_scalar (); } |
4903 | 130 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
131 octave_base_value * try_narrowing_conversion (void) { return nullptr; } |
4903 | 132 |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
133 bool isreal (void) const { return true; } |
4903 | 134 |
20126
d34e31b07966
Return true for is_real_scalar() for integer scalar types (bug #44917).
Rik <rik@octave.org>
parents:
19863
diff
changeset
|
135 bool is_real_scalar (void) const { return true; } |
d34e31b07966
Return true for is_real_scalar() for integer scalar types (bug #44917).
Rik <rik@octave.org>
parents:
19863
diff
changeset
|
136 |
4903 | 137 // void increment (void) { scalar += 1; } |
138 | |
139 // void decrement (void) { scalar -= 1; } | |
140 | |
5992 | 141 octave_value convert_to_str_internal (bool, bool, char type) const; |
142 | |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
143 octave_value as_double (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
144 octave_value as_single (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
145 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
146 octave_value as_int8 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
147 octave_value as_int16 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
148 octave_value as_int32 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
149 octave_value as_int64 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
150 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
151 octave_value as_uint8 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
152 octave_value as_uint16 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
153 octave_value as_uint32 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
154 octave_value as_uint64 (void) const; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
155 |
24745
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 std::string edit_display (const float_display_format& fmt, |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
157 octave_idx_type i, octave_idx_type j) const; |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
158 |
6974 | 159 bool save_ascii (std::ostream& os); |
4903 | 160 |
161 bool load_ascii (std::istream& is); | |
162 | |
26399
586413770c7f
pass save_as_floats by value in octave_value save_binary functions
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
163 bool save_binary (std::ostream& os, bool); |
4903 | 164 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
165 bool load_binary (std::istream& is, bool swap, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
166 octave::mach_info::float_format); |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
167 protected: |
4903 | 168 |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
169 bool save_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type, |
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
170 const char *name, bool); |
4903 | 171 |
24224
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
172 bool load_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type, |
ff81c6772664
avoid issue with link-time optimization
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
173 const char *name); |
4903 | 174 }; |
175 | |
176 #endif |