GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-base-int.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2013 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://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 <cstdlib>
27 
28 #include <iosfwd>
29 #include <string>
30 
31 #include "mx-base.h"
32 #include "oct-alloc.h"
33 #include "str-vec.h"
34 
35 #include "error.h"
36 #include "ov-base.h"
37 #include "ov-base-mat.h"
38 #include "ov-base-scalar.h"
39 #include "ov-typeinfo.h"
40 
41 // base int matrix values.
42 
43 template <class T>
44 class
46 {
47 public:
48 
50 
51  octave_base_int_matrix (const T& nda) : octave_base_matrix<T> (nda) { }
52 
54 
55  octave_base_value *clone (void) const
56  { return new octave_base_int_matrix (*this); }
57 
58  octave_base_value *empty_clone (void) const
59  { return new octave_base_int_matrix (); }
60 
61  octave_base_value *try_narrowing_conversion (void);
62 
63  bool is_real_type (void) const { return true; }
64 
65  // void increment (void) { matrix += 1; }
66 
67  // void decrement (void) { matrix -= 1; }
68 
69  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
70 
71  octave_value convert_to_str_internal (bool, bool, char type) const;
72 
73  bool save_ascii (std::ostream& os);
74 
75  bool load_ascii (std::istream& is);
76 
77  bool save_binary (std::ostream& os, bool& );
78 
79  bool load_binary (std::istream& is, bool swap,
81 
82 #if defined (HAVE_HDF5)
83  bool save_hdf5 (hid_t loc_id, const char *name, bool);
84 
85  bool load_hdf5 (hid_t loc_id, const char *name);
86 #endif
87 };
88 
89 // base int scalar values.
90 
91 template <class T>
92 class
94 {
95 public:
96 
98 
99  octave_base_int_scalar (const T& s) : octave_base_scalar<T> (s) { }
100 
102 
103  octave_base_value *clone (void) const
104  { return new octave_base_int_scalar (*this); }
105  octave_base_value *empty_clone (void) const
106  { return new octave_base_int_scalar (); }
107 
109 
110  bool is_real_type (void) const { return true; }
111 
112  // void increment (void) { scalar += 1; }
113 
114  // void decrement (void) { scalar -= 1; }
115 
116  octave_value convert_to_str_internal (bool, bool, char type) const;
117 
118  bool save_ascii (std::ostream& os);
119 
120  bool load_ascii (std::istream& is);
121 
122  bool save_binary (std::ostream& os, bool& );
123 
124  bool load_binary (std::istream& is, bool swap,
126 
127 #if defined (HAVE_HDF5)
128  bool save_hdf5 (hid_t loc_id, const char *name, bool );
129 
130  bool load_hdf5 (hid_t loc_id, const char *name);
131 #endif
132 };
133 
134 #endif