Mercurial > hg > octave-lyh
changeset 16890:830f27544bb7
Accept char array inputs for linestyleorder property (bug #34906).
* libinterp/interpfcn/graphics.in.h(string_array_property::do_set):
Add input block to check for multi-row char matrix and appropriately
set string_vector value.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 02 Jul 2013 14:56:31 -0700 |
parents | 76bd90f6ba65 |
children | 486c3e2731ff |
files | libinterp/interpfcn/graphics.in.h |
diffstat | 1 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interpfcn/graphics.in.h +++ b/libinterp/interpfcn/graphics.in.h @@ -577,8 +577,8 @@ enum desired_enum { string_t, cell_t }; string_array_property (const std::string& s, const graphics_handle& h, - const std::string& val = "", const char& sep = '|', - const desired_enum& typ = string_t) + const std::string& val = "", const char& sep = '|', + const desired_enum& typ = string_t) : base_property (s, h), desired_type (typ), separator (sep), str () { size_t pos = 0; @@ -600,8 +600,8 @@ } string_array_property (const std::string& s, const graphics_handle& h, - const Cell& c, const char& sep = '|', - const desired_enum& typ = string_t) + const Cell& c, const char& sep = '|', + const desired_enum& typ = string_t) : base_property (s, h), desired_type (typ), separator (sep), str () { if (c.is_cellstr ()) @@ -659,13 +659,14 @@ protected: bool do_set (const octave_value& val) { - if (val.is_string ()) + if (val.is_string () && val.rows () == 1) { bool replace = false; std::string new_str = val.string_value (); string_vector strings; size_t pos = 0; + // Split single string on delimiter (usually '|') while (pos != std::string::npos) { size_t new_pos = new_str.find_first_of (separator, pos); @@ -701,6 +702,30 @@ return true; } } + else if (val.is_string ()) // multi-row character matrix + { + bool replace = false; + charMatrix chm = val.char_matrix_value (); + octave_idx_type nel = chm.rows (); + string_vector strings (nel); + + if (nel != str.numel ()) + replace = true; + for (octave_idx_type i = 0; i < nel; i++) + { + strings[i] = chm.row_as_string (i); + if (!replace && strings[i] != str[i]) + replace = true; + } + + desired_type = string_t; + + if (replace) + { + str = strings; + return true; + } + } else if (val.is_cellstr ()) { bool replace = false;