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 |
|
95 Complex complex_value (bool = false) const { return scalar; } |
|
96 |
|
97 ComplexMatrix complex_matrix_value (bool = false) const |
|
98 { return ComplexMatrix (1, 1, Complex (scalar)); } |
|
99 |
|
100 bool bool_value (void) const { return scalar; } |
|
101 |
|
102 boolMatrix bool_matrix_value (void) const |
|
103 { return boolMatrix (1, 1, scalar); } |
|
104 |
4452
|
105 octave_value convert_to_str_internal (bool pad = false) const; |
2871
|
106 |
|
107 private: |
|
108 |
3219
|
109 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2871
|
110 |
3219
|
111 DECLARE_OCTAVE_ALLOCATOR |
2871
|
112 }; |
|
113 |
|
114 #endif |
|
115 |
|
116 /* |
|
117 ;;; Local Variables: *** |
|
118 ;;; mode: C++ *** |
|
119 ;;; End: *** |
|
120 */ |