4488
|
1 /* |
|
2 |
|
3 Copyright (C) 2003 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
4488
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include "gripes.h" |
|
29 #include "oct-obj.h" |
|
30 #include "ov.h" |
|
31 #include "ov-re-mat.h" |
|
32 #include "ov-str-mat.h" |
|
33 #include "ov-typeinfo.h" |
|
34 #include "ops.h" |
|
35 |
|
36 DEFASSIGNOP (assign, char_matrix_str, octave_matrix) |
|
37 { |
|
38 CAST_BINOP_ARGS (octave_char_matrix_str&, const octave_matrix&); |
|
39 |
5279
|
40 octave_value tmp |
|
41 = v2.convert_to_str_internal (false, false, |
|
42 a1.is_sq_string () ? '\'' : '"'); |
4488
|
43 |
|
44 if (! error_state) |
|
45 v1.assign (idx, tmp.char_matrix_value ()); |
|
46 |
|
47 return octave_value (); |
|
48 } |
|
49 |
4915
|
50 DEFCATOP (str_m, char_matrix_str, matrix) |
|
51 { |
5073
|
52 CAST_BINOP_ARGS (octave_char_matrix_str&, const octave_matrix&); |
4915
|
53 |
|
54 if (Vwarn_num_to_str) |
|
55 gripe_implicit_conversion (v2.type_name (), v1.type_name ()); |
|
56 |
5073
|
57 return octave_value (v1.char_array_value (). concat (v2.array_value (), |
5279
|
58 ra_idx), |
|
59 true, a1.is_sq_string () ? '\'' : '"'); |
4915
|
60 } |
|
61 |
|
62 DEFCATOP (m_str, matrix, char_matrix_str) |
|
63 { |
5073
|
64 CAST_BINOP_ARGS (octave_matrix&, const octave_char_matrix_str&); |
4915
|
65 |
|
66 if (Vwarn_num_to_str) |
|
67 gripe_implicit_conversion (v1.type_name (), v2.type_name ()); |
|
68 |
5073
|
69 return octave_value (v1.array_value (). concat (v2.char_array_value (), |
5279
|
70 ra_idx), |
|
71 true, a2.is_sq_string () ? '\'' : '"'); |
4915
|
72 } |
|
73 |
4488
|
74 void |
|
75 install_str_m_ops (void) |
|
76 { |
|
77 INSTALL_ASSIGNOP (op_asn_eq, octave_char_matrix_str, octave_matrix, assign); |
5279
|
78 INSTALL_ASSIGNOP (op_asn_eq, octave_char_matrix_sq_str, octave_matrix, assign); |
4915
|
79 |
|
80 INSTALL_CATOP (octave_char_matrix_str, octave_matrix, str_m); |
5279
|
81 INSTALL_CATOP (octave_char_matrix_sq_str, octave_matrix, str_m); |
|
82 |
4915
|
83 INSTALL_CATOP (octave_matrix, octave_char_matrix_str, m_str); |
5279
|
84 INSTALL_CATOP (octave_matrix, octave_char_matrix_sq_str, m_str); |
4488
|
85 } |
|
86 |
|
87 /* |
|
88 ;;; Local Variables: *** |
|
89 ;;; mode: C++ *** |
|
90 ;;; End: *** |
|
91 */ |