Mercurial > octave-nkf
comparison libinterp/octave-value/ov-str-mat.cc @ 19350:6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
* chMatrix.h: both charMatrix and charNDArray are Array<char>, the first
being simply 2 dimensional. We change this so that charMatrix inherits from
charNDArray instead.
* chMatrix.cc: remove all constructors which are now inherited from
charNDArray.
* chNDArray.h, chNDArray.cc: implement all constructors here rather than
calling charMatrix. Remove matrix_value() since a charMatrix constructor is
now enough.
* pr-output.cc, octave-value/ov-ch-mat.h, octave-value/ov-str-mat.cc:
replace calls to charNDArray::matrix_value () with the charMatrix constructor.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Fri, 24 Oct 2014 01:31:53 +0100 |
parents | 6a71e5030df5 |
children | 76478d2da117 |
comparison
equal
deleted
inserted
replaced
19349:25f535b90e52 | 19350:6c9ea5be96bf |
---|---|
209 { | 209 { |
210 string_vector retval; | 210 string_vector retval; |
211 | 211 |
212 if (matrix.ndims () == 2) | 212 if (matrix.ndims () == 2) |
213 { | 213 { |
214 charMatrix chm = matrix.matrix_value (); | 214 charMatrix chm (matrix); |
215 | 215 |
216 octave_idx_type n = chm.rows (); | 216 octave_idx_type n = chm.rows (); |
217 | 217 |
218 retval.resize (n); | 218 retval.resize (n); |
219 | 219 |
231 { | 231 { |
232 std::string retval; | 232 std::string retval; |
233 | 233 |
234 if (matrix.ndims () == 2) | 234 if (matrix.ndims () == 2) |
235 { | 235 { |
236 charMatrix chm = matrix.matrix_value (); | 236 charMatrix chm (matrix); |
237 | 237 |
238 retval = chm.row_as_string (0); // FIXME? | 238 retval = chm.row_as_string (0); // FIXME? |
239 } | 239 } |
240 else | 240 else |
241 error ("invalid conversion of charNDArray to string"); | 241 error ("invalid conversion of charNDArray to string"); |
248 { | 248 { |
249 Array<std::string> retval; | 249 Array<std::string> retval; |
250 | 250 |
251 if (matrix.ndims () == 2) | 251 if (matrix.ndims () == 2) |
252 { | 252 { |
253 const charMatrix chm = matrix.matrix_value (); | 253 const charMatrix chm (matrix); |
254 octave_idx_type nr = chm.rows (); | 254 octave_idx_type nr = chm.rows (); |
255 retval.clear (nr, 1); | 255 retval.clear (nr, 1); |
256 for (octave_idx_type i = 0; i < nr; i++) | 256 for (octave_idx_type i = 0; i < nr; i++) |
257 retval.xelem (i) = chm.row_as_string (i); | 257 retval.xelem (i) = chm.row_as_string (i); |
258 } | 258 } |