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 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "mx-base.h" |
|
37 #include "str-vec.h" |
|
38 |
|
39 #include "error.h" |
2477
|
40 #include "oct-alloc.h" |
2376
|
41 #include "oct-map.h" |
|
42 #include "ov-base.h" |
|
43 #include "ov-typeinfo.h" |
|
44 |
|
45 class Octave_map; |
|
46 class octave_value_list; |
|
47 |
|
48 class tree_walker; |
|
49 |
2477
|
50 // Data structures. |
2376
|
51 |
|
52 class |
|
53 octave_struct : public octave_base_value |
|
54 { |
|
55 public: |
|
56 |
|
57 octave_struct (void) |
|
58 : octave_base_value () { } |
|
59 |
|
60 octave_struct (const Octave_map& m) |
|
61 : octave_base_value (), map (m) { } |
|
62 |
|
63 octave_struct (const octave_struct& s) |
|
64 : octave_base_value (), map (s.map) { } |
|
65 |
|
66 ~octave_struct (void) { } |
|
67 |
|
68 octave_value *clone (void) { return new octave_struct (*this); } |
|
69 |
2962
|
70 octave_value |
|
71 do_struct_elt_index_op (const string& nm, const octave_value_list& idx, |
|
72 bool silent); |
|
73 |
|
74 octave_value do_struct_elt_index_op (const string& nm, bool silent); |
2376
|
75 |
2979
|
76 octave_lvalue struct_elt_ref (octave_value *parent, const string& nm); |
2376
|
77 |
|
78 bool is_defined (void) const { return true; } |
|
79 |
2974
|
80 bool is_constant (void) const { return false; } |
|
81 |
2376
|
82 bool is_map (void) const { return true; } |
|
83 |
|
84 Octave_map map_value (void) const { return map; } |
|
85 |
2901
|
86 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
87 |
|
88 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
89 |
|
90 bool print_name_tag (ostream& os, const string& name) const; |
2376
|
91 |
|
92 private: |
|
93 |
2477
|
94 // The associative array used to manage the structure data. |
2376
|
95 Octave_map map; |
|
96 |
3219
|
97 DECLARE_OCTAVE_ALLOCATOR |
2477
|
98 |
3219
|
99 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
100 }; |
|
101 |
|
102 #endif |
|
103 |
|
104 /* |
|
105 ;;; Local Variables: *** |
|
106 ;;; mode: C++ *** |
|
107 ;;; End: *** |
|
108 */ |