Mercurial > hg > octave-shane
changeset 10729:172253d75d94
implement cellstr extractors for char matrices
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 24 Jun 2010 14:39:32 +0200 |
parents | e3cc3ff9405f |
children | 390d93e20531 |
files | src/ov-str-mat.cc src/ov-str-mat.h |
diffstat | 2 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -242,6 +242,25 @@ return retval; } +Array<std::string> +octave_char_matrix_str::cellstr_value (void) const +{ + Array<std::string> retval; + + if (matrix.ndims () == 2) + { + const charMatrix chm = matrix.matrix_value (); + octave_idx_type nr = chm.rows (); + retval.clear (nr, 1); + for (octave_idx_type i = 0; i < nr; i++) + retval.xelem(i) = chm.row_as_string (i); + } + else + error ("cellstr: cannot convert multidimensional arrays"); + + return retval; +} + void octave_char_matrix_str::print_raw (std::ostream& os, bool pr_as_read_syntax) const {