1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/* MIT License
*
* Copyright (c) 2021 Tyge Løvset, NORCE, www.norceresearch.no
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef i_template
#define i_template
#ifndef STC_TEMPLATE_H_INCLUDED
#define STC_TEMPLATE_H_INCLUDED
#define cx_memb(name) c_PASTE(Self, name)
#define cx_deftypes(macro, SELF, ...) c_EXPAND(macro(SELF, __VA_ARGS__))
#define cx_value_t cx_memb(_value_t)
#define cx_key_t cx_memb(_key_t)
#define cx_mapped_t cx_memb(_mapped_t)
#define cx_rawvalue_t cx_memb(_rawvalue_t)
#define cx_rawkey_t cx_memb(_rawkey_t)
#define cx_rawmapped_t cx_memb(_rawmapped_t)
#define cx_iter_t cx_memb(_iter_t)
#define cx_result_t cx_memb(_result_t)
#define cx_node_t cx_memb(_node_t)
#define cx_size_t cx_memb(_size_t)
#endif
#define Self c_PASTE(i_prefix, i_tag)
#if defined i_valraw && !(defined i_valto && defined i_valfrom)
#error if i_valraw or i_valto defined, i_valfrom must be defined
#endif
#if defined i_keyraw && !(defined i_keyto && defined i_keyfrom)
#error if i_keyraw or i_keyto defined, i_keyfrom a must be defined
#endif
#ifdef F_tag
#define i_tag F_tag
#define i_fwd
#endif
#ifndef i_prefix_csptr
#define i_prefix_csptr csptr_
#endif
#ifdef i_key_csptr
#ifndef i_tag
#define i_tag i_key_csptr
#endif
#define i_key c_PASTE(i_prefix_csptr, i_key_csptr)
#define i_cmp c_PASTE3(i_prefix_csptr, i_key_csptr, _compare)
#define i_keydel c_PASTE3(i_prefix_csptr, i_key_csptr, _del)
#define i_keyfrom c_PASTE3(i_prefix_csptr, i_key_csptr, _clone)
#endif
#ifdef i_val_csptr
#if !defined i_tag && !defined i_key
#define i_tag i_val_csptr
#endif
#define i_val c_PASTE(i_prefix_csptr, i_val_csptr)
#ifndef i_key
#define i_cmp c_PASTE3(i_prefix_csptr, i_val_csptr, _compare)
#endif
#define i_valdel c_PASTE3(i_prefix_csptr, i_val_csptr, _del)
#define i_valfrom c_PASTE3(i_prefix_csptr, i_val_csptr, _clone)
#endif
#ifdef i_key_str
#define i_key cstr
#ifndef i_tag
#define i_tag str
#endif
#define i_cmp c_rawstr_compare
#define i_hash c_rawstr_hash
#define i_keydel cstr_del
#define i_keyfrom cstr_from
#define i_keyto cstr_str
#define i_keyraw const char*
#endif
#ifdef i_val_str
#define i_val cstr
#if !defined i_tag && !defined i_key
#define i_tag str
#endif
#ifndef i_key
#define i_cmp c_rawstr_compare
#endif
#define i_valdel cstr_del
#define i_valfrom cstr_from
#define i_valto cstr_str
#define i_valraw const char*
#endif
#if defined i_del && defined i_isset
#define i_keydel i_del
#elif defined i_del && !defined i_key
#define i_valdel i_del
#elif defined i_del
#error i_del not supported for maps, define i_keydel / i_valdel instead.
#endif
#ifdef i_key
#ifdef i_isset
#define i_val i_key
#endif
#ifndef i_tag
#define i_tag i_key
#endif
#if !defined i_keyfrom && defined i_keydel
#define i_keyfrom c_no_clone
#elif !defined i_keyfrom
#define i_keyfrom c_default_fromraw
#endif
#ifndef i_keyraw
#define i_keyraw i_key
#define i_keyto c_default_toraw
#endif
#if !defined i_equ && defined i_cmp
#define i_equ !i_cmp
#elif !defined i_equ
#define i_equ c_default_equals
#endif
#ifndef i_hash
#define i_hash c_default_hash
#endif
#ifndef i_keydel
#define i_keydel c_default_del
#endif
#elif defined i_isset || defined i_hash || defined i_equ
#error i_key define is missing.
#endif
#ifndef i_tag
#define i_tag i_val
#endif
#if !defined i_valfrom && defined i_valdel
#define i_valfrom c_no_clone
#elif !defined i_valfrom
#define i_valfrom c_default_fromraw
#endif
#ifndef i_valraw
#define i_valraw i_val
#define i_valto c_default_toraw
#endif
#ifndef i_valdel
#define i_valdel c_default_del
#endif
#ifndef i_cmp
#define i_cmp c_default_compare
#endif
#else // -------------------------------------------------------
#undef i_prefix
#undef i_tag
#undef F_tag
#undef i_imp
#undef i_fwd
#undef i_cmp
#undef i_del
#undef i_equ
#undef i_hash
#undef i_val
#undef i_val_str
#undef i_valdel
#undef i_valfrom
#undef i_valto
#undef i_valraw
#undef i_key
#undef i_key_str
#undef i_keydel
#undef i_keyfrom
#undef i_keyto
#undef i_keyraw
#undef i_key_csptr
#undef i_val_csptr
#undef i_prefix_csptr
#undef Self
#undef i_template
#endif
|