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_struct_h) |
|
24 #define octave_struct_h 1 |
|
25 |
|
26 #include <cstdlib> |
|
27 |
3503
|
28 #include <iostream> |
2376
|
29 #include <string> |
|
30 |
|
31 #include "mx-base.h" |
|
32 #include "str-vec.h" |
|
33 |
|
34 #include "error.h" |
2477
|
35 #include "oct-alloc.h" |
2376
|
36 #include "oct-map.h" |
|
37 #include "ov-base.h" |
|
38 #include "ov-typeinfo.h" |
|
39 |
|
40 class Octave_map; |
|
41 class octave_value_list; |
|
42 |
|
43 class tree_walker; |
|
44 |
2477
|
45 // Data structures. |
2376
|
46 |
|
47 class |
|
48 octave_struct : public octave_base_value |
|
49 { |
|
50 public: |
|
51 |
|
52 octave_struct (void) |
|
53 : octave_base_value () { } |
|
54 |
|
55 octave_struct (const Octave_map& m) |
|
56 : octave_base_value (), map (m) { } |
|
57 |
|
58 octave_struct (const octave_struct& s) |
|
59 : octave_base_value (), map (s.map) { } |
|
60 |
|
61 ~octave_struct (void) { } |
|
62 |
3933
|
63 octave_value *clone (void) const { return new octave_struct (*this); } |
|
64 octave_value *empty_clone (void) const { return new octave_struct (); } |
|
65 |
4513
|
66 Cell dotref (const octave_value_list& idx); |
2376
|
67 |
4994
|
68 octave_value subsref (const std::string&, |
|
69 const std::list<octave_value_list>&) |
4271
|
70 { |
|
71 panic_impossible (); |
|
72 return octave_value_list (); |
|
73 } |
|
74 |
4994
|
75 octave_value_list subsref (const std::string& type, |
|
76 const std::list<octave_value_list>& idx, |
|
77 int nargout); |
|
78 |
4513
|
79 static octave_value numeric_conv (const Cell& val, |
3933
|
80 const std::string& type); |
2376
|
81 |
4247
|
82 octave_value subsasgn (const std::string& type, |
4219
|
83 const std::list<octave_value_list>& idx, |
3933
|
84 const octave_value& rhs); |
2376
|
85 |
4563
|
86 dim_vector dims (void) const { return map.dims (); } |
4200
|
87 |
4791
|
88 size_t byte_size (void) const; |
|
89 |
4567
|
90 octave_value reshape (const dim_vector& new_dims) const |
|
91 { return map.reshape (new_dims); } |
|
92 |
4936
|
93 octave_value resize (const dim_vector& dv) const |
|
94 { return map.resize (dv); } |
|
95 |
2376
|
96 bool is_defined (void) const { return true; } |
|
97 |
|
98 bool is_map (void) const { return true; } |
|
99 |
|
100 Octave_map map_value (void) const { return map; } |
|
101 |
3933
|
102 string_vector map_keys (void) const { return map.keys (); } |
|
103 |
3523
|
104 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
105 |
3523
|
106 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
107 |
3523
|
108 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2376
|
109 |
4687
|
110 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
111 bool strip_nan_and_inf); |
|
112 |
|
113 bool load_ascii (std::istream& is); |
|
114 |
|
115 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
116 |
|
117 bool load_binary (std::istream& is, bool swap, |
|
118 oct_mach_info::float_format fmt); |
|
119 |
|
120 #if defined (HAVE_HDF5) |
|
121 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
122 |
|
123 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
124 #endif |
|
125 |
2376
|
126 private: |
|
127 |
2477
|
128 // The associative array used to manage the structure data. |
2376
|
129 Octave_map map; |
|
130 |
3219
|
131 DECLARE_OCTAVE_ALLOCATOR |
2477
|
132 |
3219
|
133 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
134 }; |
|
135 |
|
136 #endif |
|
137 |
|
138 /* |
|
139 ;;; Local Variables: *** |
|
140 ;;; mode: C++ *** |
|
141 ;;; End: *** |
|
142 */ |