annotate src/oct-map.h @ 3931:311981a9726d

[project @ 2002-05-07 04:49:53 by jwe]
author jwe
date Tue, 07 May 2002 04:49:53 +0000
parents b80bbb43a1a9
children 2e2e32198722
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
1 /*
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
2
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2369
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
4
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
6
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
10 later version.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
11
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
15 for more details.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
16
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
1315
611d403c7f3d [project @ 1995-06-25 19:56:32 by jwe]
jwe
parents: 1297
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
20
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
21 */
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
22
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_oct_map_h)
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
24 #define octave_oct_map_h 1
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
25
1297
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1279
diff changeset
26 #if defined (__GNUG__)
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1279
diff changeset
27 #pragma interface
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1279
diff changeset
28 #endif
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1279
diff changeset
29
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
30 #include "Map.h"
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
31
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
32 #include "oct-obj.h"
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
33
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1737
diff changeset
34 class string_vector;
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1737
diff changeset
35
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
36 class
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
37 Octave_map
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
38 {
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
39 public:
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
40 Octave_map (void) : map (octave_value_list ()) { }
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
41
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 2847
diff changeset
42 Octave_map (const std::string& key, const octave_value& value)
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
43 : map (octave_value_list ())
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
44 {
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
45 map[key] = octave_value_list (value);
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
46 }
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
47
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
48 Octave_map (const Octave_map& m) : map (m.map) { }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
49
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
50 Octave_map& operator = (const Octave_map& m)
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
51 {
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
52 if (this != &m)
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
53 map = m.map;
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
54
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
55 return *this;
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
56 }
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
57
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
58 ~Octave_map (void) { }
1279
f146197d9d37 [project @ 1995-04-26 17:41:20 by jwe]
jwe
parents: 1009
diff changeset
59
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
60 int length (void) const { return map.length (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
61
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
62 int empty (void) const { return map.empty (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
63
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
64 octave_value& operator [] (const std::string& key) { return map[key](0); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
65
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
66 void del (const std::string& key) { map.del (key); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
67
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
68 Pix first (void) const { return map.first (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
69 void next (Pix& i) const { map.next (i); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
70
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
71 std::string key (Pix p) const { return map.key (p); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
72
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
73 octave_value& contents (Pix p) const { return map.contents (p)(0); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
74
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
75 Pix seek (const std::string& key) const { return map.seek (key); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
76
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
77 int contains (const std::string& key) const { return map.contains (key); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
78
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
79 void clear (void) { map.clear (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
80
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1737
diff changeset
81 string_vector make_name_list (void);
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
82
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
83 private:
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
84
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
85 // The map of names to values.
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
86 CHMap<octave_value_list> map;
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
87 };
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
88
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
89 #endif
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
90
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
91 /*
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
92 ;;; Local Variables: ***
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
93 ;;; mode: C++ ***
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
94 ;;; End: ***
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
95 */