]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/scm-hash.hh
Release: bump Welcome versions.
[lilypond.git] / lily / include / scm-hash.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2015 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 "small-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 : public Smob1<Scheme_hash_table>
47 {
48 public:
49   static const char * const type_p_name_; // = 0
50   int print_smob (SCM, scm_print_state *) const;
51   bool try_retrieve (SCM key, SCM *val);
52   bool contains (SCM key) const;
53   void set (SCM k, SCM v);
54   SCM get (SCM k) const;
55   void remove (SCM k);
56   void operator = (Scheme_hash_table const &);
57   SCM to_alist () const;
58   static SCM make_smob ();
59
60 private:
61   SCM &hash_tab () const { return scm1 (); }
62 };
63
64 #endif /* SCM_HASH_HH */