1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2003-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING.  If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 #  include "config.h"
28 #endif
29 
30 #include "errwarn.h"
31 #include "ovl.h"
32 #include "ov.h"
33 #include "ov-re-mat.h"
34 #include "ov-str-mat.h"
35 #include "ov-typeinfo.h"
36 #include "ops.h"
37 
DEFASSIGNOP(assign,char_matrix_str,octave_matrix)38 DEFASSIGNOP (assign, char_matrix_str, octave_matrix)
39 {
40   octave_char_matrix_str& v1 = dynamic_cast<octave_char_matrix_str&> (a1);
41   const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2);
42 
43   octave_value tmp
44     = v2.convert_to_str_internal (false, false,
45                                   a1.is_sq_string () ? '\'' : '"');
46 
47   v1.assign (idx, tmp.char_array_value ());
48 
49   return octave_value ();
50 }
51 
DEFNDCHARCATOP_FN(str_m,char_matrix_str,matrix,concat)52 DEFNDCHARCATOP_FN (str_m, char_matrix_str, matrix, concat)
53 
54 DEFNDCHARCATOP_FN (m_str, matrix, char_matrix_str, concat)
55 
56 void
57 install_str_m_ops (octave::type_info& ti)
58 {
59   INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_char_matrix_str, octave_matrix,
60                        assign);
61   INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_char_matrix_sq_str, octave_matrix,
62                        assign);
63 
64   INSTALL_CATOP_TI (ti, octave_char_matrix_str, octave_matrix, str_m);
65   INSTALL_CATOP_TI (ti, octave_char_matrix_sq_str, octave_matrix, str_m);
66 
67   INSTALL_CATOP_TI (ti, octave_matrix, octave_char_matrix_str, m_str);
68   INSTALL_CATOP_TI (ti, octave_matrix, octave_char_matrix_sq_str, m_str);
69 }
70