GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-base-int.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2004-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_ov_base_int_h)
27 #define octave_ov_base_int_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cstdlib>
32 
33 #include <iosfwd>
34 #include <string>
35 
36 #include "mx-base.h"
37 #include "str-vec.h"
38 
39 #include "error.h"
40 #include "ov-base.h"
41 #include "ov-base-mat.h"
42 #include "ov-base-scalar.h"
43 #include "ov-typeinfo.h"
44 
45 // base int matrix values.
46 
47 template <typename T>
48 class
50 {
51 public:
52 
54 
55  octave_base_int_matrix (const T& nda) : octave_base_matrix<T> (nda) { }
56 
57  ~octave_base_int_matrix (void) = default;
58 
59  octave_base_value * clone (void) const
60  { return new octave_base_int_matrix (*this); }
61 
63  { return new octave_base_int_matrix (); }
64 
65  octave_base_value * try_narrowing_conversion (void);
66 
67  bool isreal (void) const { return true; }
68 
69  // void increment (void) { matrix += 1; }
70 
71  // void decrement (void) { matrix -= 1; }
72 
73  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
74 
75  octave_value convert_to_str_internal (bool, bool, char type) const;
76 
77  octave_value as_double (void) const;
78  octave_value as_single (void) const;
79 
80  octave_value as_int8 (void) const;
81  octave_value as_int16 (void) const;
82  octave_value as_int32 (void) const;
83  octave_value as_int64 (void) const;
84 
85  octave_value as_uint8 (void) const;
86  octave_value as_uint16 (void) const;
87  octave_value as_uint32 (void) const;
88  octave_value as_uint64 (void) const;
89 
90  std::string edit_display (const float_display_format& fmt,
91  octave_idx_type i, octave_idx_type j) const;
92 
93  bool save_ascii (std::ostream& os);
94 
95  bool load_ascii (std::istream& is);
96 
97  bool save_binary (std::ostream& os, bool);
98 
99  bool load_binary (std::istream& is, bool swap,
101 
102 protected:
103 
104  bool save_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type,
105  const char *name, bool);
106 
107  bool load_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type,
108  const char *name);
109 };
110 
111 // base int scalar values.
112 
113 template <typename T>
114 class
116 {
117 public:
118 
120 
121  octave_base_int_scalar (const T& s) : octave_base_scalar<T> (s) { }
122 
123  ~octave_base_int_scalar (void) = default;
124 
125  octave_base_value * clone (void) const
126  { return new octave_base_int_scalar (*this); }
128  { return new octave_base_int_scalar (); }
129 
130  octave_base_value * try_narrowing_conversion (void) { return nullptr; }
131 
132  bool isreal (void) const { return true; }
133 
134  bool is_real_scalar (void) const { return true; }
135 
136  // void increment (void) { scalar += 1; }
137 
138  // void decrement (void) { scalar -= 1; }
139 
140  octave_value convert_to_str_internal (bool, bool, char type) const;
141 
142  octave_value as_double (void) const;
143  octave_value as_single (void) const;
144 
145  octave_value as_int8 (void) const;
146  octave_value as_int16 (void) const;
147  octave_value as_int32 (void) const;
148  octave_value as_int64 (void) const;
149 
150  octave_value as_uint8 (void) const;
151  octave_value as_uint16 (void) const;
152  octave_value as_uint32 (void) const;
153  octave_value as_uint64 (void) const;
154 
155  std::string edit_display (const float_display_format& fmt,
156  octave_idx_type i, octave_idx_type j) const;
157 
158  bool save_ascii (std::ostream& os);
159 
160  bool load_ascii (std::istream& is);
161 
162  bool save_binary (std::ostream& os, bool);
163 
164  bool load_binary (std::istream& is, bool swap,
166 protected:
167 
168  bool save_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type,
169  const char *name, bool);
170 
171  bool load_hdf5_internal (octave_hdf5_id loc_id, octave_hdf5_id save_type,
172  const char *name);
173 };
174 
175 #endif
octave_base_int_matrix(const T &nda)
Definition: ov-base-int.h:55
bool isreal(void) const
Definition: ov-base-int.h:67
~octave_base_int_matrix(void)=default
octave_base_value * clone(void) const
Definition: ov-base-int.h:59
octave_base_value * empty_clone(void) const
Definition: ov-base-int.h:62
~octave_base_int_scalar(void)=default
bool isreal(void) const
Definition: ov-base-int.h:132
octave_base_value * clone(void) const
Definition: ov-base-int.h:125
bool is_real_scalar(void) const
Definition: ov-base-int.h:134
octave_base_int_scalar(const T &s)
Definition: ov-base-int.h:121
octave_base_value * empty_clone(void) const
Definition: ov-base-int.h:127
octave_base_value * try_narrowing_conversion(void)
Definition: ov-base-int.h:130
save_type
Definition: data-conv.h:87
QString name
int64_t octave_hdf5_id
static double as_double(time_t sec, long usec)
Definition: oct-time.h:37