Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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
51namespace 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:
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*/
Inline string literal.
Definition symbol.hpp:78
Table for automatically interned strings.
Literal internedString(string &&symbolString)
std::unordered_set< string > table_
scoped guard to control the actual locking.
Definition sync.hpp:228
Facility for monitor object based locking.
Definition sync.hpp:210
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Implementation namespace for support and library code.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Object Monitor based synchronisation.