2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
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_char_matrix_str_h) |
|
24 #define octave_char_matrix_str_h 1 |
|
25 |
|
26 #include <cstdlib> |
|
27 |
3503
|
28 #include <iostream> |
2376
|
29 #include <string> |
|
30 |
|
31 #include "mx-base.h" |
|
32 #include "str-vec.h" |
|
33 |
|
34 #include "error.h" |
4944
|
35 #include "oct-stream.h" |
3202
|
36 #include "ov.h" |
2376
|
37 #include "ov-ch-mat.h" |
|
38 #include "ov-typeinfo.h" |
|
39 |
|
40 class Octave_map; |
|
41 class octave_value_list; |
|
42 |
|
43 class tree_walker; |
|
44 |
2477
|
45 // Character matrix values with special properties for use as |
|
46 // strings. |
2376
|
47 |
|
48 class |
|
49 octave_char_matrix_str : public octave_char_matrix |
|
50 { |
|
51 public: |
|
52 |
|
53 octave_char_matrix_str (void) |
|
54 : octave_char_matrix () { } |
|
55 |
|
56 octave_char_matrix_str (const charMatrix& chm) |
|
57 : octave_char_matrix (chm) { } |
|
58 |
4513
|
59 octave_char_matrix_str (const charNDArray& chm) |
|
60 : octave_char_matrix (chm) { } |
|
61 |
3189
|
62 octave_char_matrix_str (char c) |
|
63 : octave_char_matrix (c) { } |
|
64 |
2376
|
65 octave_char_matrix_str (const char *s) |
|
66 : octave_char_matrix (s) { } |
|
67 |
3523
|
68 octave_char_matrix_str (const std::string& s) |
2376
|
69 : octave_char_matrix (s) { } |
|
70 |
|
71 octave_char_matrix_str (const string_vector& s) |
|
72 : octave_char_matrix (s) { } |
|
73 |
|
74 octave_char_matrix_str (const octave_char_matrix& chm) |
|
75 : octave_char_matrix (chm) { } |
|
76 |
|
77 octave_char_matrix_str (const octave_char_matrix_str& chms) |
|
78 : octave_char_matrix (chms) { } |
|
79 |
|
80 ~octave_char_matrix_str (void) { } |
|
81 |
3933
|
82 octave_value *clone (void) const { return new octave_char_matrix_str (*this); } |
|
83 octave_value *empty_clone (void) const { return new octave_char_matrix_str (); } |
2376
|
84 |
2412
|
85 type_conv_fcn numeric_conversion_function (void) const; |
2376
|
86 |
3933
|
87 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
2407
|
88 |
|
89 void assign (const octave_value_list& idx, const charMatrix& rhs); |
|
90 |
4569
|
91 octave_value reshape (const dim_vector& new_dims) const |
|
92 { return octave_value (charNDArray (matrix.reshape (new_dims)), true); } |
|
93 |
2376
|
94 bool is_string (void) const { return true; } |
|
95 |
4323
|
96 bool is_real_type (void) const { return false; } |
2376
|
97 |
4323
|
98 bool is_matrix_type (void) const { return false; } |
3202
|
99 |
4323
|
100 bool is_numeric_type (void) const { return false; } |
3221
|
101 |
2376
|
102 bool valid_as_scalar_index (void) const; |
|
103 |
4643
|
104 double double_value (bool = false) const; |
|
105 |
2376
|
106 Matrix matrix_value (bool = false) const; |
|
107 |
4668
|
108 NDArray array_value (bool = false) const; |
|
109 |
|
110 Complex complex_value (bool = false) const; |
|
111 |
|
112 ComplexMatrix complex_matrix_value (bool = false) const; |
|
113 |
|
114 ComplexNDArray complex_array_value (bool = false) const; |
|
115 |
4457
|
116 string_vector all_strings (bool pad = false, bool force = false) const; |
2376
|
117 |
4457
|
118 std::string string_value (bool force = false) const; |
2376
|
119 |
3219
|
120 bool print_as_scalar (void) const { return (rows () <= 1); } |
2901
|
121 |
3523
|
122 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
123 |
4687
|
124 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
125 bool strip_nan_and_inf); |
|
126 |
|
127 bool load_ascii (std::istream& is); |
|
128 |
|
129 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
130 |
|
131 bool load_binary (std::istream& is, bool swap, |
|
132 oct_mach_info::float_format fmt); |
|
133 |
|
134 #if defined (HAVE_HDF5) |
|
135 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
136 |
|
137 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
138 #endif |
|
139 |
4944
|
140 int write (octave_stream& os, int block_size, |
|
141 oct_data_conv::data_type output_type, int skip, |
|
142 oct_mach_info::float_format flt_fmt) const |
|
143 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
144 |
2376
|
145 private: |
|
146 |
3219
|
147 DECLARE_OCTAVE_ALLOCATOR |
2376
|
148 |
3219
|
149 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
150 }; |
|
151 |
5279
|
152 typedef octave_char_matrix_str octave_char_matrix_dq_str; |
|
153 |
|
154 class |
|
155 octave_char_matrix_sq_str : public octave_char_matrix_str |
|
156 { |
|
157 public: |
|
158 |
|
159 octave_char_matrix_sq_str (void) |
|
160 : octave_char_matrix_str () { } |
|
161 |
|
162 octave_char_matrix_sq_str (const charMatrix& chm) |
|
163 : octave_char_matrix_str (chm) { } |
|
164 |
|
165 octave_char_matrix_sq_str (const charNDArray& chm) |
|
166 : octave_char_matrix_str (chm) { } |
|
167 |
|
168 octave_char_matrix_sq_str (char c) |
|
169 : octave_char_matrix_str (c) { } |
|
170 |
|
171 octave_char_matrix_sq_str (const char *s) |
|
172 : octave_char_matrix_str (s) { } |
|
173 |
|
174 octave_char_matrix_sq_str (const std::string& s) |
|
175 : octave_char_matrix_str (s) { } |
|
176 |
|
177 octave_char_matrix_sq_str (const string_vector& s) |
|
178 : octave_char_matrix_str (s) { } |
|
179 |
|
180 octave_char_matrix_sq_str (const octave_char_matrix_str& chm) |
|
181 : octave_char_matrix_str (chm) { } |
|
182 |
|
183 octave_char_matrix_sq_str (const octave_char_matrix_sq_str& chms) |
|
184 : octave_char_matrix_str (chms) { } |
|
185 |
|
186 ~octave_char_matrix_sq_str (void) { } |
|
187 |
|
188 octave_value *clone (void) const { return new octave_char_matrix_sq_str (*this); } |
|
189 octave_value *empty_clone (void) const { return new octave_char_matrix_sq_str (); } |
|
190 |
|
191 bool is_sq_string (void) const { return true; } |
|
192 |
|
193 private: |
|
194 |
|
195 DECLARE_OCTAVE_ALLOCATOR |
|
196 |
|
197 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
|
198 }; |
|
199 |
2376
|
200 #endif |
|
201 |
|
202 /* |
|
203 ;;; Local Variables: *** |
|
204 ;;; mode: C++ *** |
|
205 ;;; End: *** |
|
206 */ |