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