00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_char_matrix_str_h)
00025 #define octave_char_matrix_str_h 1
00026
00027 #include <cstdlib>
00028
00029 #include <iosfwd>
00030 #include <string>
00031
00032 #include "mx-base.h"
00033 #include "str-vec.h"
00034
00035 #include "error.h"
00036 #include "oct-stream.h"
00037 #include "ov.h"
00038 #include "ov-ch-mat.h"
00039 #include "ov-re-mat.h"
00040 #include "ov-typeinfo.h"
00041
00042 class Octave_map;
00043 class octave_value_list;
00044
00045 class tree_walker;
00046
00047
00048
00049
00050 class
00051 OCTINTERP_API
00052 octave_char_matrix_str : public octave_char_matrix
00053 {
00054 public:
00055
00056 octave_char_matrix_str (void)
00057 : octave_char_matrix () { }
00058
00059 octave_char_matrix_str (const charMatrix& chm)
00060 : octave_char_matrix (chm) { }
00061
00062 octave_char_matrix_str (const charNDArray& chm)
00063 : octave_char_matrix (chm) { }
00064
00065 octave_char_matrix_str (char c)
00066 : octave_char_matrix (c) { }
00067
00068 octave_char_matrix_str (const char *s)
00069 : octave_char_matrix (s) { }
00070
00071 octave_char_matrix_str (const std::string& s)
00072 : octave_char_matrix (s) { }
00073
00074 octave_char_matrix_str (const string_vector& s)
00075 : octave_char_matrix (s) { }
00076
00077 octave_char_matrix_str (const octave_char_matrix& chm)
00078 : octave_char_matrix (chm) { }
00079
00080 octave_char_matrix_str (const octave_char_matrix_str& chms)
00081 : octave_char_matrix (chms) { }
00082
00083 ~octave_char_matrix_str (void) { }
00084
00085 octave_base_value *clone (void) const { return new octave_char_matrix_str (*this); }
00086 octave_base_value *empty_clone (void) const { return new octave_char_matrix_str (); }
00087
00088 type_conv_info numeric_conversion_function (void) const;
00089
00090 octave_value do_index_op (const octave_value_list& idx,
00091 bool resize_ok = false)
00092 { return do_index_op_internal (idx, resize_ok); }
00093
00094 octave_value squeeze (void) const
00095 { return octave_value (charNDArray (matrix.squeeze ())); }
00096
00097 octave_value reshape (const dim_vector& new_dims) const
00098 { return octave_value (charNDArray (matrix.reshape (new_dims))); }
00099
00100 octave_value permute (const Array<int>& vec, bool inv = false) const
00101 { return octave_value (charNDArray (matrix.permute (vec, inv))); }
00102
00103 octave_value resize (const dim_vector& dv, bool fill = false) const;
00104
00105 octave_value diag (octave_idx_type k = 0) const
00106 { return octave_value (matrix.diag (k)); }
00107
00108 bool is_string (void) const { return true; }
00109
00110 bool is_real_type (void) const { return false; }
00111
00112 bool is_matrix_type (void) const { return false; }
00113
00114 bool is_numeric_type (void) const { return false; }
00115
00116 double double_value (bool = false) const;
00117
00118 Matrix matrix_value (bool = false) const;
00119
00120 NDArray array_value (bool = false) const;
00121
00122 Complex complex_value (bool = false) const;
00123
00124 ComplexMatrix complex_matrix_value (bool = false) const;
00125
00126 ComplexNDArray complex_array_value (bool = false) const;
00127
00128 string_vector all_strings (bool pad = false) const;
00129
00130 std::string string_value (bool force = false) const;
00131
00132 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
00133 { return octave_value (matrix.sort (dim, mode)); }
00134
00135 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
00136 sortmode mode = ASCENDING) const
00137 { return octave_value (matrix.sort (sidx, dim, mode)); }
00138
00139 bool print_as_scalar (void) const { return (rows () <= 1); }
00140
00141 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
00142
00143 bool save_ascii (std::ostream& os);
00144
00145 bool load_ascii (std::istream& is);
00146
00147 bool save_binary (std::ostream& os, bool& save_as_floats);
00148
00149 bool load_binary (std::istream& is, bool swap,
00150 oct_mach_info::float_format fmt);
00151
00152 #if defined (HAVE_HDF5)
00153 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
00154
00155 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug);
00156 #endif
00157
00158 int write (octave_stream& os, int block_size,
00159 oct_data_conv::data_type output_type, int skip,
00160 oct_mach_info::float_format flt_fmt) const
00161 { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
00162
00163 protected:
00164
00165 octave_value do_index_op_internal (const octave_value_list& idx,
00166 bool resize_ok, char type = '"');
00167
00168 private:
00169
00170 DECLARE_OCTAVE_ALLOCATOR
00171
00172 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00173 };
00174
00175 typedef octave_char_matrix_str octave_char_matrix_dq_str;
00176
00177 class
00178 octave_char_matrix_sq_str : public octave_char_matrix_str
00179 {
00180 public:
00181
00182 octave_char_matrix_sq_str (void)
00183 : octave_char_matrix_str () { }
00184
00185 octave_char_matrix_sq_str (const charMatrix& chm)
00186 : octave_char_matrix_str (chm) { }
00187
00188 octave_char_matrix_sq_str (const charNDArray& chm)
00189 : octave_char_matrix_str (chm) { }
00190
00191 octave_char_matrix_sq_str (char c)
00192 : octave_char_matrix_str (c) { }
00193
00194 octave_char_matrix_sq_str (const char *s)
00195 : octave_char_matrix_str (s) { }
00196
00197 octave_char_matrix_sq_str (const std::string& s)
00198 : octave_char_matrix_str (s) { }
00199
00200 octave_char_matrix_sq_str (const string_vector& s)
00201 : octave_char_matrix_str (s) { }
00202
00203 octave_char_matrix_sq_str (const octave_char_matrix_str& chm)
00204 : octave_char_matrix_str (chm) { }
00205
00206 octave_char_matrix_sq_str (const octave_char_matrix_sq_str& chms)
00207 : octave_char_matrix_str (chms) { }
00208
00209 ~octave_char_matrix_sq_str (void) { }
00210
00211 octave_base_value *clone (void) const { return new octave_char_matrix_sq_str (*this); }
00212 octave_base_value *empty_clone (void) const { return new octave_char_matrix_sq_str (); }
00213
00214 octave_value squeeze (void) const
00215 { return octave_value (charNDArray (matrix.squeeze ()), '\''); }
00216
00217 octave_value reshape (const dim_vector& new_dims) const
00218 { return octave_value (charNDArray (matrix.reshape (new_dims)), '\''); }
00219
00220 octave_value permute (const Array<int>& vec, bool inv = false) const
00221 { return octave_value (charNDArray (matrix.permute (vec, inv)), '\''); }
00222
00223 octave_value resize (const dim_vector& dv, bool = false) const
00224 {
00225 charNDArray retval (matrix);
00226 retval.resize (dv);
00227 return octave_value (retval, '\'');
00228 }
00229
00230 octave_value diag (octave_idx_type k = 0) const
00231 { return octave_value (matrix.diag (k), '\''); }
00232
00233 bool is_sq_string (void) const { return true; }
00234
00235 octave_value do_index_op (const octave_value_list& idx,
00236 bool resize_ok = false)
00237 { return do_index_op_internal (idx, resize_ok, '\''); }
00238
00239
00240 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
00241 { return octave_value (matrix.sort (dim, mode), '\''); }
00242
00243 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
00244 sortmode mode = ASCENDING) const
00245 { return octave_value (matrix.sort (sidx, dim, mode), '\''); }
00246
00247 private:
00248
00249 DECLARE_OCTAVE_ALLOCATOR
00250
00251 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00252 };
00253
00254 #endif
00255
00256
00257
00258
00259
00260