Mercurial > hg > octave-nkf
diff src/Cell.cc @ 6116:b64fb24bf4a0
[project @ 2006-10-27 18:04:49 by jwe]
author | jwe |
---|---|
date | Fri, 27 Oct 2006 18:04:50 +0000 |
parents | 67bf9b4f2ae2 |
children | 93c65f2a5668 |
line wrap: on
line diff
--- a/src/Cell.cc +++ b/src/Cell.cc @@ -56,6 +56,52 @@ } } +// Set size to DV, filling with []. Then fill with as many elements of +// SV as possible. +Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim) + : ArrayN<octave_value> (dv) +{ + octave_idx_type n = sv.length (); + + if (n > 0) + { + octave_idx_type m = numel (); + + octave_idx_type len = n > m ? m : n; + + for (octave_idx_type i = 0; i < len; i++) + { + std::string s = sv[i]; + + if (trim) + { + size_t pos = s.find_last_not_of (' '); + + s = (pos == NPOS) ? "" : s.substr (0, pos+1); + } + + elem(i) = s; + } + } +} + +bool +Cell::is_cellstr (void) const +{ + bool retval = true; + + for (int i = 0; i < numel (); i++) + { + if (! elem(i).is_string ()) + { + retval = false; + break; + } + } + + return retval; +} + Cell Cell::index (const octave_value_list& idx_arg, bool resize_ok) const {