glr2.cc: require C++11
[bison.git] / src / uniqstr.h
blob0a1c506fb9f93a550fff7c361fb9a490c9602d79
1 /* Keeping a unique copy of strings.
3 Copyright (C) 2002-2003, 2008-2015, 2018-2021 Free Software
4 Foundation, Inc.
6 This file is part of Bison, the GNU Compiler Compiler.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
21 #ifndef UNIQSTR_H_
22 # define UNIQSTR_H_
24 # include <stdio.h>
26 /*-----------------------------------------.
27 | Pointers to unique copies of C strings. |
28 `-----------------------------------------*/
30 typedef char const *uniqstr;
32 /* Return the uniqstr for STR. */
33 uniqstr uniqstr_new (char const *str);
35 /* Two uniqstr values have the same value iff they are the same. */
36 # define UNIQSTR_EQ(Ustr1, Ustr2) (!!((Ustr1) == (Ustr2)))
38 /* Compare two uniqstr a la strcmp: negative for <, nul for =, and
39 positive for >. Undefined order, relies on addresses. */
40 int uniqstr_cmp (uniqstr u1, uniqstr u2);
42 /* Die if STR is not a uniqstr. */
43 void uniqstr_assert (char const *str);
45 /*----------------.
46 | Concatenation. |
47 `----------------*/
49 /* Concatenate strings and return a uniqstr. The goal of
50 this macro is to make the caller's code a little more succinct. */
51 # define UNIQSTR_CONCAT(...) \
52 uniqstr_concat (ARRAY_CARDINALITY (((char const *[]) {__VA_ARGS__})), \
53 __VA_ARGS__)
54 uniqstr uniqstr_concat (int nargs, ...);
56 /*--------------------.
57 | Table of uniqstrs. |
58 `--------------------*/
60 /* Create the string table. */
61 void uniqstrs_new (void);
63 /* Free all the memory allocated for symbols. */
64 void uniqstrs_free (void);
66 /* Report them all. */
67 void uniqstrs_print (void);
69 #endif /* ! defined UNIQSTR_H_ */