comparison libinterp/octave-value/ov-cell.h @ 15195:2fc554ffbc28

split libinterp from src * libinterp: New directory. Move all files from src directory here except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc, mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh. * libinterp/Makefile.am: New file, extracted from src/Makefile.am. * src/Makefile.am: Delete everything except targets and definitions needed to build and link main and utility programs. * Makefile.am (SUBDIRS): Include libinterp in the list. * autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not src/dldfcn directory. * configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not src/octave.cc. (DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src. (AC_CONFIG_FILES): Include libinterp/Makefile in the list. * find-docstring-files.sh: Look in libinterp, not src. * gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in libinterp, not src.
author John W. Eaton <jwe@octave.org>
date Sat, 18 Aug 2012 16:23:39 -0400
parents src/octave-value/ov-cell.h@46b19589b593
children 1785493171ac
comparison
equal deleted inserted replaced
15194:0f0b795044c3 15195:2fc554ffbc28
1 /*
2
3 Copyright (C) 1999-2012 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague
5
6 This file is part of Octave.
7
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21
22 */
23
24 #if !defined (octave_cell_h)
25 #define octave_cell_h 1
26
27 #include <cstdlib>
28
29 #include <iosfwd>
30 #include <string>
31 #include <memory>
32
33 #include "mx-base.h"
34 #include "oct-alloc.h"
35 #include "str-vec.h"
36
37 #include "Cell.h"
38 #include "error.h"
39 #include "ov-base-mat.h"
40 #include "ov-typeinfo.h"
41
42 class octave_value_list;
43
44 class tree_walker;
45
46 // Cells.
47
48 class
49 octave_cell : public octave_base_matrix<Cell>
50 {
51 public:
52
53 octave_cell (void)
54 : octave_base_matrix<Cell> (), cellstr_cache () { }
55
56 octave_cell (const Cell& c)
57 : octave_base_matrix<Cell> (c), cellstr_cache () { }
58
59 octave_cell (const Array<std::string>& str)
60 : octave_base_matrix<Cell> (Cell (str)), cellstr_cache (new Array<std::string> (str)) { }
61
62 octave_cell (const octave_cell& c)
63 : octave_base_matrix<Cell> (c), cellstr_cache () { }
64
65 ~octave_cell (void) { }
66
67 octave_base_value *clone (void) const { return new octave_cell (*this); }
68 octave_base_value *empty_clone (void) const { return new octave_cell (); }
69
70 #if 0
71 octave_base_value *try_narrowing_conversion (void);
72 #endif
73
74 octave_value subsref (const std::string& type,
75 const std::list<octave_value_list>& idx)
76 {
77 octave_value_list tmp = subsref (type, idx, 1);
78 return tmp.length () > 0 ? tmp(0) : octave_value ();
79 }
80
81 octave_value_list subsref (const std::string& type,
82 const std::list<octave_value_list>& idx, int);
83
84 octave_value subsref (const std::string& type,
85 const std::list<octave_value_list>& idx,
86 bool auto_add);
87
88 octave_value subsasgn (const std::string& type,
89 const std::list<octave_value_list>& idx,
90 const octave_value& rhs);
91
92 void assign (const octave_value_list& idx, const Cell& rhs);
93
94 void assign (const octave_value_list& idx, const octave_value& rhs);
95
96 void delete_elements (const octave_value_list& idx);
97
98 size_t byte_size (void) const;
99
100 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const;
101
102 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
103 sortmode mode = ASCENDING) const;
104
105 sortmode is_sorted (sortmode mode = UNSORTED) const;
106
107 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
108
109 sortmode is_sorted_rows (sortmode mode = UNSORTED) const;
110
111 bool is_matrix_type (void) const { return false; }
112
113 bool is_numeric_type (void) const { return false; }
114
115 bool is_defined (void) const { return true; }
116
117 bool is_constant (void) const { return true; }
118
119 bool is_cell (void) const { return true; }
120
121 builtin_type_t builtin_type (void) const { return btyp_cell; }
122
123 bool is_cellstr (void) const;
124
125 bool is_true (void) const;
126
127 Cell cell_value (void) const { return matrix; }
128
129 octave_value_list list_value (void) const;
130
131 octave_value convert_to_str_internal (bool pad, bool, char type) const
132 { return octave_value (all_strings (pad), type); }
133
134 string_vector all_strings (bool pad = false) const;
135
136 Array<std::string> cellstr_value (void) const;
137
138 bool print_as_scalar (void) const;
139
140 void print (std::ostream& os, bool pr_as_read_syntax = false) const;
141
142 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
143
144
145 bool save_ascii (std::ostream& os);
146
147 bool load_ascii (std::istream& is);
148
149 bool save_binary (std::ostream& os, bool& save_as_floats);
150
151 bool load_binary (std::istream& is, bool swap,
152 oct_mach_info::float_format fmt);
153
154 #if defined (HAVE_HDF5)
155 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
156
157 bool load_hdf5 (hid_t loc_id, const char *name);
158 #endif
159
160 octave_value map (unary_mapper_t umap) const;
161
162 mxArray *as_mxArray (void) const;
163
164 // Unsafe. This function exists to support the MEX interface.
165 // You should not use it anywhere else.
166 void *mex_get_data (void) const;
167
168 private:
169
170 void clear_cellstr_cache (void) const
171 { cellstr_cache.reset (); }
172
173 mutable std::auto_ptr<Array<std::string> > cellstr_cache;
174
175 DECLARE_OCTAVE_ALLOCATOR
176
177 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
178 };
179
180 #endif