2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
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 #if !defined (octave_char_matrix_str_h) |
|
24 #define octave_char_matrix_str_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2376
|
33 #include <string> |
|
34 |
|
35 #include "mx-base.h" |
|
36 #include "str-vec.h" |
|
37 |
|
38 #include "error.h" |
3202
|
39 #include "ov.h" |
2376
|
40 #include "ov-ch-mat.h" |
|
41 #include "ov-typeinfo.h" |
|
42 |
|
43 class Octave_map; |
|
44 class octave_value_list; |
|
45 |
|
46 class tree_walker; |
|
47 |
2477
|
48 // Character matrix values with special properties for use as |
|
49 // strings. |
2376
|
50 |
|
51 class |
|
52 octave_char_matrix_str : public octave_char_matrix |
|
53 { |
|
54 public: |
|
55 |
|
56 octave_char_matrix_str (void) |
|
57 : octave_char_matrix () { } |
|
58 |
|
59 octave_char_matrix_str (const charMatrix& chm) |
|
60 : octave_char_matrix (chm) { } |
|
61 |
4513
|
62 octave_char_matrix_str (const charNDArray& chm) |
|
63 : octave_char_matrix (chm) { } |
|
64 |
3189
|
65 octave_char_matrix_str (char c) |
|
66 : octave_char_matrix (c) { } |
|
67 |
2376
|
68 octave_char_matrix_str (const char *s) |
|
69 : octave_char_matrix (s) { } |
|
70 |
3523
|
71 octave_char_matrix_str (const std::string& s) |
2376
|
72 : octave_char_matrix (s) { } |
|
73 |
|
74 octave_char_matrix_str (const string_vector& s) |
|
75 : octave_char_matrix (s) { } |
|
76 |
|
77 octave_char_matrix_str (const octave_char_matrix& chm) |
|
78 : octave_char_matrix (chm) { } |
|
79 |
|
80 octave_char_matrix_str (const octave_char_matrix_str& chms) |
|
81 : octave_char_matrix (chms) { } |
|
82 |
|
83 ~octave_char_matrix_str (void) { } |
|
84 |
3933
|
85 octave_value *clone (void) const { return new octave_char_matrix_str (*this); } |
|
86 octave_value *empty_clone (void) const { return new octave_char_matrix_str (); } |
2376
|
87 |
2412
|
88 type_conv_fcn numeric_conversion_function (void) const; |
2376
|
89 |
3933
|
90 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
2407
|
91 |
|
92 void assign (const octave_value_list& idx, const charMatrix& rhs); |
|
93 |
2376
|
94 bool is_string (void) const { return true; } |
|
95 |
4323
|
96 bool is_real_type (void) const { return false; } |
2376
|
97 |
4323
|
98 bool is_matrix_type (void) const { return false; } |
3202
|
99 |
4323
|
100 bool is_numeric_type (void) const { return false; } |
3221
|
101 |
2376
|
102 bool valid_as_scalar_index (void) const; |
|
103 |
|
104 Matrix matrix_value (bool = false) const; |
|
105 |
4457
|
106 string_vector all_strings (bool pad = false, bool force = false) const; |
2376
|
107 |
4457
|
108 std::string string_value (bool force = false) const; |
2376
|
109 |
3219
|
110 bool print_as_scalar (void) const { return (rows () <= 1); } |
2901
|
111 |
3523
|
112 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
113 |
2376
|
114 private: |
|
115 |
3219
|
116 DECLARE_OCTAVE_ALLOCATOR |
2376
|
117 |
3219
|
118 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
119 }; |
|
120 |
|
121 #endif |
|
122 |
|
123 /* |
|
124 ;;; Local Variables: *** |
|
125 ;;; mode: C++ *** |
|
126 ;;; End: *** |
|
127 */ |