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_value_list;
00043
00044 class tree_walker;
00045
00046
00047
00048
00049 class
00050 OCTINTERP_API
00051 octave_char_matrix_str : public octave_char_matrix
00052 {
00053 public:
00054
00055 octave_char_matrix_str (void)
00056 : octave_char_matrix () { }
00057
00058 octave_char_matrix_str (const charMatrix& chm)
00059 : octave_char_matrix (chm) { }
00060
00061 octave_char_matrix_str (const charNDArray& chm)
00062 : octave_char_matrix (chm) { }
00063
00064 octave_char_matrix_str (const Array<char>& chm)
00065 : octave_char_matrix (chm) { }
00066
00067 octave_char_matrix_str (char c)
00068 : octave_char_matrix (c) { }
00069
00070 octave_char_matrix_str (const char *s)
00071 : octave_char_matrix (s) { }
00072
00073 octave_char_matrix_str (const std::string& s)
00074 : octave_char_matrix (s) { }
00075
00076 octave_char_matrix_str (const string_vector& s)
00077 : octave_char_matrix (s) { }
00078
00079 octave_char_matrix_str (const octave_char_matrix& chm)
00080 : octave_char_matrix (chm) { }
00081
00082 octave_char_matrix_str (const octave_char_matrix_str& chms)
00083 : octave_char_matrix (chms) { }
00084
00085 ~octave_char_matrix_str (void) { }
00086
00087 octave_base_value *clone (void) const { return new octave_char_matrix_str (*this); }
00088 octave_base_value *empty_clone (void) const { return new octave_char_matrix_str (); }
00089
00090 type_conv_info numeric_conversion_function (void) const;
00091
00092 octave_value do_index_op (const octave_value_list& idx,
00093 bool resize_ok = false)
00094 { return do_index_op_internal (idx, resize_ok); }
00095
00096 octave_value squeeze (void) const
00097 { return octave_value (charNDArray (matrix.squeeze ())); }
00098
00099 octave_value reshape (const dim_vector& new_dims) const
00100 { return octave_value (charNDArray (matrix.reshape (new_dims))); }
00101
00102 octave_value permute (const Array<int>& vec, bool inv = false) const
00103 { return octave_value (charNDArray (matrix.permute (vec, inv))); }
00104
00105 octave_value resize (const dim_vector& dv, bool fill = false) const;
00106
00107 octave_value diag (octave_idx_type k = 0) const
00108 { return octave_value (matrix.diag (k)); }
00109
00110 bool is_string (void) const { return true; }
00111
00112 bool is_numeric_type (void) const { return false; }
00113
00114 double double_value (bool = false) const;
00115
00116 Matrix matrix_value (bool = false) const;
00117
00118 NDArray array_value (bool = false) const;
00119
00120 Complex complex_value (bool = false) const;
00121
00122 ComplexMatrix complex_matrix_value (bool = false) const;
00123
00124 ComplexNDArray complex_array_value (bool = false) const;
00125
00126 string_vector all_strings (bool pad = false) const;
00127
00128 std::string string_value (bool force = false) const;
00129
00130 Array<std::string> cellstr_value (void) 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);
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 (const Array<char>& chm)
00192 : octave_char_matrix_str (chm) { }
00193
00194 octave_char_matrix_sq_str (char c)
00195 : octave_char_matrix_str (c) { }
00196
00197 octave_char_matrix_sq_str (const char *s)
00198 : octave_char_matrix_str (s) { }
00199
00200 octave_char_matrix_sq_str (const std::string& s)
00201 : octave_char_matrix_str (s) { }
00202
00203 octave_char_matrix_sq_str (const string_vector& s)
00204 : octave_char_matrix_str (s) { }
00205
00206 octave_char_matrix_sq_str (const octave_char_matrix_str& chm)
00207 : octave_char_matrix_str (chm) { }
00208
00209 octave_char_matrix_sq_str (const octave_char_matrix_sq_str& chms)
00210 : octave_char_matrix_str (chms) { }
00211
00212 ~octave_char_matrix_sq_str (void) { }
00213
00214 octave_base_value *clone (void) const { return new octave_char_matrix_sq_str (*this); }
00215 octave_base_value *empty_clone (void) const { return new octave_char_matrix_sq_str (); }
00216
00217 octave_value squeeze (void) const
00218 { return octave_value (charNDArray (matrix.squeeze ()), '\''); }
00219
00220 octave_value reshape (const dim_vector& new_dims) const
00221 { return octave_value (charNDArray (matrix.reshape (new_dims)), '\''); }
00222
00223 octave_value permute (const Array<int>& vec, bool inv = false) const
00224 { return octave_value (charNDArray (matrix.permute (vec, inv)), '\''); }
00225
00226 octave_value resize (const dim_vector& dv, bool = false) const
00227 {
00228 charNDArray retval (matrix);
00229 retval.resize (dv);
00230 return octave_value (retval, '\'');
00231 }
00232
00233 octave_value diag (octave_idx_type k = 0) const
00234 { return octave_value (matrix.diag (k), '\''); }
00235
00236 bool is_sq_string (void) const { return true; }
00237
00238 octave_value do_index_op (const octave_value_list& idx,
00239 bool resize_ok = false)
00240 { return do_index_op_internal (idx, resize_ok, '\''); }
00241
00242
00243 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
00244 { return octave_value (matrix.sort (dim, mode), '\''); }
00245
00246 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
00247 sortmode mode = ASCENDING) const
00248 { return octave_value (matrix.sort (sidx, dim, mode), '\''); }
00249
00250 private:
00251
00252 DECLARE_OCTAVE_ALLOCATOR
00253
00254 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00255 };
00256
00257 #endif