746
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
746
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
746
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_oct_map_h) |
|
24 #define octave_oct_map_h 1 |
|
25 |
1297
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
746
|
30 #include "Map.h" |
|
31 |
3931
|
32 #include "oct-obj.h" |
746
|
33 |
1755
|
34 class string_vector; |
|
35 |
746
|
36 class |
3931
|
37 Octave_map |
746
|
38 { |
|
39 public: |
3931
|
40 Octave_map (void) : map (octave_value_list ()) { } |
746
|
41 |
3523
|
42 Octave_map (const std::string& key, const octave_value& value) |
3931
|
43 : map (octave_value_list ()) |
746
|
44 { |
3931
|
45 map[key] = octave_value_list (value); |
746
|
46 } |
|
47 |
3931
|
48 Octave_map (const Octave_map& m) : map (m.map) { } |
|
49 |
|
50 Octave_map& operator = (const Octave_map& m) |
|
51 { |
|
52 if (this != &m) |
|
53 map = m.map; |
|
54 |
|
55 return *this; |
|
56 } |
746
|
57 |
|
58 ~Octave_map (void) { } |
1279
|
59 |
3931
|
60 int length (void) const { return map.length (); } |
|
61 |
|
62 int empty (void) const { return map.empty (); } |
|
63 |
|
64 octave_value& operator [] (const std::string& key) { return map[key](0); } |
|
65 |
|
66 void del (const std::string& key) { map.del (key); } |
|
67 |
|
68 Pix first (void) const { return map.first (); } |
|
69 void next (Pix& i) const { map.next (i); } |
|
70 |
|
71 std::string key (Pix p) const { return map.key (p); } |
|
72 |
|
73 octave_value& contents (Pix p) const { return map.contents (p)(0); } |
|
74 |
|
75 Pix seek (const std::string& key) const { return map.seek (key); } |
|
76 |
|
77 int contains (const std::string& key) const { return map.contains (key); } |
|
78 |
|
79 void clear (void) { map.clear (); } |
|
80 |
1755
|
81 string_vector make_name_list (void); |
3931
|
82 |
|
83 private: |
|
84 |
|
85 // The map of names to values. |
|
86 CHMap<octave_value_list> map; |
746
|
87 }; |
|
88 |
|
89 #endif |
|
90 |
|
91 /* |
|
92 ;;; Local Variables: *** |
|
93 ;;; mode: C++ *** |
|
94 ;;; End: *** |
|
95 */ |