]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/scm-hash.hh
Run `make grand-replace'.
[lilypond.git] / lily / include / scm-hash.hh
1 /*
2   scm-hash.hh -- declare Scheme hasher.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef SCM_HASH_HH
10 #define SCM_HASH_HH
11
12 #include "smobs.hh"
13
14 /*
15   hash table.
16
17   1. ALWAYS USE THIS AS VIA A POINTER, i.e.
18
19   class Foo {
20   Scheme_hash_table * tab;
21   };
22
23   and NOT
24
25   class Foo {
26   Scheme_hash_table tab;
27   }
28
29
30   2. UPON DESTRUCTION, DO
31
32   scm_gc_unprotect_object (tab->self_scm_);
33 */
34
35 class Scheme_hash_table
36 {
37 public:
38   bool try_retrieve (SCM key, SCM *val);
39   bool contains (SCM key) const;
40   void set (SCM k, SCM v);
41   SCM get (SCM k) const;
42   void remove (SCM k);
43   Scheme_hash_table ();
44   void operator = (Scheme_hash_table const &);
45   Scheme_hash_table (Scheme_hash_table const &);
46   SCM to_alist () const;
47
48 private:
49   SCM hash_tab_;
50   void copy (Scheme_hash_table const &src);
51   DECLARE_SMOBS (Scheme_hash_table);
52 };
53
54 #endif /* SCM_HASH_HH */
55