]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/scm-hash.hh
Run grand-replace (issue 3765)
[lilypond.git] / lily / include / scm-hash.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef SCM_HASH_HH
21 #define SCM_HASH_HH
22
23 #include "smobs.hh"
24
25 /*
26   hash table.
27
28   1. ALWAYS USE THIS AS VIA A POINTER, i.e.
29
30   class Foo {
31   Scheme_hash_table * tab;
32   };
33
34   and NOT
35
36   class Foo {
37   Scheme_hash_table tab;
38   }
39
40
41   2. UPON DESTRUCTION, DO
42
43   scm_gc_unprotect_object (tab->self_scm_);
44 */
45
46 class Scheme_hash_table
47 {
48 public:
49   bool try_retrieve (SCM key, SCM *val);
50   bool contains (SCM key) const;
51   void set (SCM k, SCM v);
52   SCM get (SCM k) const;
53   void remove (SCM k);
54   Scheme_hash_table ();
55   void operator = (Scheme_hash_table const &);
56   Scheme_hash_table (Scheme_hash_table const &);
57   SCM to_alist () const;
58
59 private:
60   SCM hash_tab_;
61   void copy (Scheme_hash_table const &src);
62   DECLARE_SMOBS (Scheme_hash_table);
63 };
64
65 #endif /* SCM_HASH_HH */
66