2871
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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 2, or (at your option) any |
|
10 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, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_bool_h) |
|
24 #define octave_bool_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2871
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2871
|
33 #include <string> |
|
34 |
|
35 #include "lo-utils.h" |
|
36 #include "mx-base.h" |
|
37 #include "oct-alloc.h" |
|
38 #include "str-vec.h" |
|
39 |
|
40 #include "ov-base.h" |
3223
|
41 #include "ov-base-scalar.h" |
2871
|
42 #include "ov-typeinfo.h" |
|
43 |
|
44 class Octave_map; |
|
45 class octave_value_list; |
|
46 |
|
47 class tree_walker; |
|
48 |
|
49 // Real scalar values. |
|
50 |
|
51 class |
3223
|
52 octave_bool : public octave_base_scalar<bool> |
2871
|
53 { |
|
54 public: |
|
55 |
|
56 octave_bool (void) |
3223
|
57 : octave_base_scalar<bool> (false) { } |
2871
|
58 |
|
59 octave_bool (bool b) |
3223
|
60 : octave_base_scalar<bool> (b) { } |
2871
|
61 |
|
62 octave_bool (const octave_bool& s) |
3223
|
63 : octave_base_scalar<bool> (s) { } |
2871
|
64 |
|
65 ~octave_bool (void) { } |
|
66 |
3933
|
67 octave_value *clone (void) const { return new octave_bool (*this); } |
|
68 octave_value *empty_clone (void) const { return new octave_bool (); } |
2871
|
69 |
|
70 type_conv_fcn numeric_conversion_function (void) const; |
|
71 |
3933
|
72 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
2871
|
73 |
|
74 idx_vector index_vector (void) const { return idx_vector (scalar); } |
|
75 |
|
76 bool is_real_scalar (void) const { return true; } |
|
77 |
3209
|
78 bool is_bool_type (void) const { return true; } |
|
79 |
2871
|
80 bool is_real_type (void) const { return true; } |
3209
|
81 |
2871
|
82 bool valid_as_scalar_index (void) const { return scalar; } |
|
83 |
|
84 bool valid_as_zero_index (void) const { return ! scalar; } |
|
85 |
|
86 bool is_true (void) const { return scalar; } |
|
87 |
|
88 double double_value (bool = false) const { return scalar; } |
|
89 |
2916
|
90 double scalar_value (bool = false) const { return scalar; } |
|
91 |
3145
|
92 Matrix matrix_value (bool = false) const |
|
93 { return Matrix (1, 1, scalar); } |
2871
|
94 |
4630
|
95 NDArray array_value (bool = false) const |
|
96 { return NDArray (dim_vector (1, 1), scalar); } |
|
97 |
2871
|
98 Complex complex_value (bool = false) const { return scalar; } |
|
99 |
|
100 ComplexMatrix complex_matrix_value (bool = false) const |
|
101 { return ComplexMatrix (1, 1, Complex (scalar)); } |
|
102 |
4630
|
103 ComplexNDArray complex_array_value (bool = false) const |
|
104 { return ComplexNDArray (dim_vector (1, 1), Complex (scalar)); } |
|
105 |
2871
|
106 bool bool_value (void) const { return scalar; } |
|
107 |
|
108 boolMatrix bool_matrix_value (void) const |
|
109 { return boolMatrix (1, 1, scalar); } |
|
110 |
4457
|
111 octave_value convert_to_str_internal (bool pad, bool force) const; |
2871
|
112 |
4687
|
113 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
114 bool strip_nan_and_inf); |
|
115 |
|
116 bool load_ascii (std::istream& is); |
|
117 |
|
118 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
119 |
|
120 bool load_binary (std::istream& is, bool swap, |
|
121 oct_mach_info::float_format fmt); |
|
122 |
|
123 #if defined (HAVE_HDF5) |
|
124 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
125 |
|
126 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
127 #endif |
|
128 |
2871
|
129 private: |
|
130 |
4612
|
131 DECLARE_OCTAVE_ALLOCATOR |
2871
|
132 |
4612
|
133 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2871
|
134 }; |
|
135 |
|
136 #endif |
|
137 |
|
138 /* |
|
139 ;;; Local Variables: *** |
|
140 ;;; mode: C++ *** |
|
141 ;;; End: *** |
|
142 */ |