Lumiera  0.pre.03
»edit your freedom«
symbol-table.hpp
Go to the documentation of this file.
1 /*
2  SYMBOL-TABLE.hpp - registry for automatically interned symbol string tokens
3 
4  Copyright (C) Lumiera.org
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
48 #ifndef LIB_SYMBOL_TABLE_H
49 #define LIB_SYMBOL_TABLE_H
50 
51 #include "lib/sync.hpp"
52 #include "lib/symbol.hpp"
53 #include "lib/nocopy.hpp"
54 
55 #include <unordered_set>
56 #include <utility>
57 #include <string>
58 
59 
60 namespace lib {
61 
62  using std::string;
63  using std::forward;
64 
65 
74  : public Sync<>
76  {
77  std::unordered_set<string> table_;
78 
79  public:
80  Literal
81  internedString (string && symbolString)
82  {
83  Lock sync{this};
84  auto res = table_.insert (forward<string> (symbolString));
85  return res.first->c_str();
86  }
87  };
88 
89 
90 
91 } // namespace lib
92 #endif /*LIB_SYMBOL_TABLE_H*/
Facility for monitor object based locking.
Definition: sync.hpp:217
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:85
Implementation namespace for support and library code.
Object Monitor based synchronisation.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Table for automatically interned strings.