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