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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "gripes.h" |
|
28 #include "oct-obj.h" |
|
29 #include "ov.h" |
|
30 #include "ov-re-mat.h" |
|
31 #include "ov-str-mat.h" |
|
32 #include "ov-typeinfo.h" |
|
33 #include "ops.h" |
|
34 |
|
35 DEFASSIGNOP (assign, char_matrix_str, octave_matrix) |
|
36 { |
|
37 CAST_BINOP_ARGS (octave_char_matrix_str&, const octave_matrix&); |
|
38 |
5279
|
39 octave_value tmp |
|
40 = v2.convert_to_str_internal (false, false, |
|
41 a1.is_sq_string () ? '\'' : '"'); |
4488
|
42 |
|
43 if (! error_state) |
|
44 v1.assign (idx, tmp.char_matrix_value ()); |
|
45 |
|
46 return octave_value (); |
|
47 } |
|
48 |
4915
|
49 DEFCATOP (str_m, char_matrix_str, matrix) |
|
50 { |
5073
|
51 CAST_BINOP_ARGS (octave_char_matrix_str&, const octave_matrix&); |
4915
|
52 |
|
53 if (Vwarn_num_to_str) |
|
54 gripe_implicit_conversion (v2.type_name (), v1.type_name ()); |
|
55 |
5073
|
56 return octave_value (v1.char_array_value (). concat (v2.array_value (), |
5279
|
57 ra_idx), |
|
58 true, a1.is_sq_string () ? '\'' : '"'); |
4915
|
59 } |
|
60 |
|
61 DEFCATOP (m_str, matrix, char_matrix_str) |
|
62 { |
5073
|
63 CAST_BINOP_ARGS (octave_matrix&, const octave_char_matrix_str&); |
4915
|
64 |
|
65 if (Vwarn_num_to_str) |
|
66 gripe_implicit_conversion (v1.type_name (), v2.type_name ()); |
|
67 |
5073
|
68 return octave_value (v1.array_value (). concat (v2.char_array_value (), |
5279
|
69 ra_idx), |
|
70 true, a2.is_sq_string () ? '\'' : '"'); |
4915
|
71 } |
|
72 |
4488
|
73 void |
|
74 install_str_m_ops (void) |
|
75 { |
|
76 INSTALL_ASSIGNOP (op_asn_eq, octave_char_matrix_str, octave_matrix, assign); |
5279
|
77 INSTALL_ASSIGNOP (op_asn_eq, octave_char_matrix_sq_str, octave_matrix, assign); |
4915
|
78 |
|
79 INSTALL_CATOP (octave_char_matrix_str, octave_matrix, str_m); |
5279
|
80 INSTALL_CATOP (octave_char_matrix_sq_str, octave_matrix, str_m); |
|
81 |
4915
|
82 INSTALL_CATOP (octave_matrix, octave_char_matrix_str, m_str); |
5279
|
83 INSTALL_CATOP (octave_matrix, octave_char_matrix_sq_str, m_str); |
4488
|
84 } |
|
85 |
|
86 /* |
|
87 ;;; Local Variables: *** |
|
88 ;;; mode: C++ *** |
|
89 ;;; End: *** |
|
90 */ |