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)
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
39 #ifndef LIB_SYMBOL_TABLE_H
40 #define LIB_SYMBOL_TABLE_H
41 
42 #include "lib/sync.hpp"
43 #include "lib/symbol.hpp"
44 #include "lib/nocopy.hpp"
45 
46 #include <unordered_set>
47 #include <utility>
48 #include <string>
49 
50 
51 namespace lib {
52 
53  using std::string;
54  using std::move;
55 
56 
65  : public Sync<>
67  {
68  std::unordered_set<string> table_;
69 
70  public:
71  Literal
72  internedString (string && symbolString)
73  {
74  Lock sync{this};
75  auto res = table_.insert (move (symbolString));
76  return res.first->c_str();
77  }
78  };
79 
80 
81 
82 } // namespace lib
83 #endif /*LIB_SYMBOL_TABLE_H*/
Facility for monitor object based locking.
Definition: sync.hpp:209
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:76
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.