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