comparison libinterp/octave-value/ov-str-mat.h @ 15196:2fc554ffbc28

split libinterp from src * libinterp: New directory. Move all files from src directory here except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc, mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh. * libinterp/Makefile.am: New file, extracted from src/Makefile.am. * src/Makefile.am: Delete everything except targets and definitions needed to build and link main and utility programs. * Makefile.am (SUBDIRS): Include libinterp in the list. * autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not src/dldfcn directory. * configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not src/octave.cc. (DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src. (AC_CONFIG_FILES): Include libinterp/Makefile in the list. * find-docstring-files.sh: Look in libinterp, not src. * gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in libinterp, not src.
author John W. Eaton <jwe@octave.org>
date Sat, 18 Aug 2012 16:23:39 -0400
parents src/octave-value/ov-str-mat.h@46b19589b593
children
comparison
equal deleted inserted replaced
15195:0f0b795044c3 15196:2fc554ffbc28
1 /*
2
3 Copyright (C) 1996-2012 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague
5
6 This file is part of Octave.
7
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21
22 */
23
24 #if !defined (octave_char_matrix_str_h)
25 #define octave_char_matrix_str_h 1
26
27 #include <cstdlib>
28
29 #include <iosfwd>
30 #include <string>
31
32 #include "mx-base.h"
33 #include "str-vec.h"
34
35 #include "error.h"
36 #include "oct-stream.h"
37 #include "ov.h"
38 #include "ov-ch-mat.h"
39 #include "ov-re-mat.h"
40 #include "ov-typeinfo.h"
41
42 class octave_value_list;
43
44 class tree_walker;
45
46 // Character matrix values with special properties for use as
47 // strings.
48
49 class
50 OCTINTERP_API
51 octave_char_matrix_str : public octave_char_matrix
52 {
53 public:
54
55 octave_char_matrix_str (void)
56 : octave_char_matrix () { }
57
58 octave_char_matrix_str (const charMatrix& chm)
59 : octave_char_matrix (chm) { }
60
61 octave_char_matrix_str (const charNDArray& chm)
62 : octave_char_matrix (chm) { }
63
64 octave_char_matrix_str (const Array<char>& chm)
65 : octave_char_matrix (chm) { }
66
67 octave_char_matrix_str (char c)
68 : octave_char_matrix (c) { }
69
70 octave_char_matrix_str (const char *s)
71 : octave_char_matrix (s) { }
72
73 octave_char_matrix_str (const std::string& s)
74 : octave_char_matrix (s) { }
75
76 octave_char_matrix_str (const string_vector& s)
77 : octave_char_matrix (s) { }
78
79 octave_char_matrix_str (const octave_char_matrix& chm)
80 : octave_char_matrix (chm) { }
81
82 octave_char_matrix_str (const octave_char_matrix_str& chms)
83 : octave_char_matrix (chms) { }
84
85 ~octave_char_matrix_str (void) { }
86
87 octave_base_value *clone (void) const { return new octave_char_matrix_str (*this); }
88 octave_base_value *empty_clone (void) const { return new octave_char_matrix_str (); }
89
90 type_conv_info numeric_conversion_function (void) const;
91
92 octave_value do_index_op (const octave_value_list& idx,
93 bool resize_ok = false)
94 { return do_index_op_internal (idx, resize_ok); }
95
96 octave_value squeeze (void) const
97 { return octave_value (charNDArray (matrix.squeeze ())); }
98
99 octave_value reshape (const dim_vector& new_dims) const
100 { return octave_value (charNDArray (matrix.reshape (new_dims))); }
101
102 octave_value permute (const Array<int>& vec, bool inv = false) const
103 { return octave_value (charNDArray (matrix.permute (vec, inv))); }
104
105 octave_value resize (const dim_vector& dv, bool fill = false) const;
106
107 octave_value diag (octave_idx_type k = 0) const
108 { return octave_value (matrix.diag (k)); }
109
110 bool is_string (void) const { return true; }
111
112 bool is_numeric_type (void) const { return false; }
113
114 double double_value (bool = false) const;
115
116 Matrix matrix_value (bool = false) const;
117
118 NDArray array_value (bool = false) const;
119
120 Complex complex_value (bool = false) const;
121
122 ComplexMatrix complex_matrix_value (bool = false) const;
123
124 ComplexNDArray complex_array_value (bool = false) const;
125
126 string_vector all_strings (bool pad = false) const;
127
128 std::string string_value (bool force = false) const;
129
130 Array<std::string> cellstr_value (void) const;
131
132 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
133 { return octave_value (matrix.sort (dim, mode)); }
134
135 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
136 sortmode mode = ASCENDING) const
137 { return octave_value (matrix.sort (sidx, dim, mode)); }
138
139 bool print_as_scalar (void) const { return (rows () <= 1); }
140
141 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
142
143 bool save_ascii (std::ostream& os);
144
145 bool load_ascii (std::istream& is);
146
147 bool save_binary (std::ostream& os, bool& save_as_floats);
148
149 bool load_binary (std::istream& is, bool swap,
150 oct_mach_info::float_format fmt);
151
152 #if defined (HAVE_HDF5)
153 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
154
155 bool load_hdf5 (hid_t loc_id, const char *name);
156 #endif
157
158 int write (octave_stream& os, int block_size,
159 oct_data_conv::data_type output_type, int skip,
160 oct_mach_info::float_format flt_fmt) const
161 { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
162
163 protected:
164
165 octave_value do_index_op_internal (const octave_value_list& idx,
166 bool resize_ok, char type = '"');
167
168 private:
169
170 DECLARE_OCTAVE_ALLOCATOR
171
172 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
173 };
174
175 typedef octave_char_matrix_str octave_char_matrix_dq_str;
176
177 class
178 octave_char_matrix_sq_str : public octave_char_matrix_str
179 {
180 public:
181
182 octave_char_matrix_sq_str (void)
183 : octave_char_matrix_str () { }
184
185 octave_char_matrix_sq_str (const charMatrix& chm)
186 : octave_char_matrix_str (chm) { }
187
188 octave_char_matrix_sq_str (const charNDArray& chm)
189 : octave_char_matrix_str (chm) { }
190
191 octave_char_matrix_sq_str (const Array<char>& chm)
192 : octave_char_matrix_str (chm) { }
193
194 octave_char_matrix_sq_str (char c)
195 : octave_char_matrix_str (c) { }
196
197 octave_char_matrix_sq_str (const char *s)
198 : octave_char_matrix_str (s) { }
199
200 octave_char_matrix_sq_str (const std::string& s)
201 : octave_char_matrix_str (s) { }
202
203 octave_char_matrix_sq_str (const string_vector& s)
204 : octave_char_matrix_str (s) { }
205
206 octave_char_matrix_sq_str (const octave_char_matrix_str& chm)
207 : octave_char_matrix_str (chm) { }
208
209 octave_char_matrix_sq_str (const octave_char_matrix_sq_str& chms)
210 : octave_char_matrix_str (chms) { }
211
212 ~octave_char_matrix_sq_str (void) { }
213
214 octave_base_value *clone (void) const { return new octave_char_matrix_sq_str (*this); }
215 octave_base_value *empty_clone (void) const { return new octave_char_matrix_sq_str (); }
216
217 octave_value squeeze (void) const
218 { return octave_value (charNDArray (matrix.squeeze ()), '\''); }
219
220 octave_value reshape (const dim_vector& new_dims) const
221 { return octave_value (charNDArray (matrix.reshape (new_dims)), '\''); }
222
223 octave_value permute (const Array<int>& vec, bool inv = false) const
224 { return octave_value (charNDArray (matrix.permute (vec, inv)), '\''); }
225
226 octave_value resize (const dim_vector& dv, bool = false) const
227 {
228 charNDArray retval (matrix);
229 retval.resize (dv);
230 return octave_value (retval, '\'');
231 }
232
233 octave_value diag (octave_idx_type k = 0) const
234 { return octave_value (matrix.diag (k), '\''); }
235
236 bool is_sq_string (void) const { return true; }
237
238 octave_value do_index_op (const octave_value_list& idx,
239 bool resize_ok = false)
240 { return do_index_op_internal (idx, resize_ok, '\''); }
241
242
243 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
244 { return octave_value (matrix.sort (dim, mode), '\''); }
245
246 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
247 sortmode mode = ASCENDING) const
248 { return octave_value (matrix.sort (sidx, dim, mode), '\''); }
249
250 private:
251
252 DECLARE_OCTAVE_ALLOCATOR
253
254 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
255 };
256
257 #endif