50826
|
1 |
/*
|
|
2 |
* Copyright © 2018 Google, Inc.
|
|
3 |
*
|
|
4 |
* This is part of HarfBuzz, a text shaping library.
|
|
5 |
*
|
|
6 |
* Permission is hereby granted, without written agreement and without
|
|
7 |
* license or royalty fees, to use, copy, modify, and distribute this
|
|
8 |
* software and its documentation for any purpose, provided that the
|
|
9 |
* above copyright notice and the following two paragraphs appear in
|
|
10 |
* all copies of this software.
|
|
11 |
*
|
|
12 |
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
13 |
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
14 |
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
15 |
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
16 |
* DAMAGE.
|
|
17 |
*
|
|
18 |
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
19 |
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
20 |
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
21 |
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
22 |
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
23 |
*
|
|
24 |
* Google Author(s): Behdad Esfahbod
|
|
25 |
*/
|
|
26 |
|
|
27 |
#include "hb-map-private.hh"
|
|
28 |
|
|
29 |
|
|
30 |
/* Public API */
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* hb_map_create: (Xconstructor)
|
|
35 |
*
|
|
36 |
* Return value: (transfer full):
|
|
37 |
*
|
|
38 |
* Since: 1.7.7
|
|
39 |
**/
|
|
40 |
hb_map_t *
|
|
41 |
hb_map_create (void)
|
|
42 |
{
|
|
43 |
hb_map_t *map;
|
|
44 |
|
|
45 |
if (!(map = hb_object_create<hb_map_t> ()))
|
|
46 |
return hb_map_get_empty ();
|
|
47 |
|
|
48 |
map->init_shallow ();
|
|
49 |
|
|
50 |
return map;
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
* hb_map_get_empty:
|
|
55 |
*
|
|
56 |
* Return value: (transfer full):
|
|
57 |
*
|
|
58 |
* Since: 1.7.7
|
|
59 |
**/
|
|
60 |
hb_map_t *
|
|
61 |
hb_map_get_empty (void)
|
|
62 |
{
|
|
63 |
return const_cast<hb_map_t *> (&Null(hb_map_t));
|
|
64 |
}
|
|
65 |
|
|
66 |
/**
|
|
67 |
* hb_map_reference: (skip)
|
|
68 |
* @map: a map.
|
|
69 |
*
|
|
70 |
* Return value: (transfer full):
|
|
71 |
*
|
|
72 |
* Since: 1.7.7
|
|
73 |
**/
|
|
74 |
hb_map_t *
|
|
75 |
hb_map_reference (hb_map_t *map)
|
|
76 |
{
|
|
77 |
return hb_object_reference (map);
|
|
78 |
}
|
|
79 |
|
|
80 |
/**
|
|
81 |
* hb_map_destroy: (skip)
|
|
82 |
* @map: a map.
|
|
83 |
*
|
|
84 |
* Since: 1.7.7
|
|
85 |
**/
|
|
86 |
void
|
|
87 |
hb_map_destroy (hb_map_t *map)
|
|
88 |
{
|
|
89 |
if (!hb_object_destroy (map)) return;
|
|
90 |
|
|
91 |
map->fini_shallow ();
|
|
92 |
|
|
93 |
free (map);
|
|
94 |
}
|
|
95 |
|
|
96 |
/**
|
|
97 |
* hb_map_set_user_data: (skip)
|
|
98 |
* @map: a map.
|
|
99 |
* @key:
|
|
100 |
* @data:
|
|
101 |
* @destroy:
|
|
102 |
* @replace:
|
|
103 |
*
|
|
104 |
* Return value:
|
|
105 |
*
|
|
106 |
* Since: 1.7.7
|
|
107 |
**/
|
|
108 |
hb_bool_t
|
|
109 |
hb_map_set_user_data (hb_map_t *map,
|
|
110 |
hb_user_data_key_t *key,
|
|
111 |
void * data,
|
|
112 |
hb_destroy_func_t destroy,
|
|
113 |
hb_bool_t replace)
|
|
114 |
{
|
|
115 |
return hb_object_set_user_data (map, key, data, destroy, replace);
|
|
116 |
}
|
|
117 |
|
|
118 |
/**
|
|
119 |
* hb_map_get_user_data: (skip)
|
|
120 |
* @map: a map.
|
|
121 |
* @key:
|
|
122 |
*
|
|
123 |
* Return value: (transfer none):
|
|
124 |
*
|
|
125 |
* Since: 1.7.7
|
|
126 |
**/
|
|
127 |
void *
|
|
128 |
hb_map_get_user_data (hb_map_t *map,
|
|
129 |
hb_user_data_key_t *key)
|
|
130 |
{
|
|
131 |
return hb_object_get_user_data (map, key);
|
|
132 |
}
|
|
133 |
|
|
134 |
|
|
135 |
/**
|
|
136 |
* hb_map_allocation_successful:
|
|
137 |
* @map: a map.
|
|
138 |
*
|
|
139 |
*
|
|
140 |
*
|
|
141 |
* Return value:
|
|
142 |
*
|
|
143 |
* Since: 1.7.7
|
|
144 |
**/
|
|
145 |
hb_bool_t
|
|
146 |
hb_map_allocation_successful (const hb_map_t *map)
|
|
147 |
{
|
|
148 |
return map->successful;
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
/**
|
|
153 |
* hb_map_set:
|
|
154 |
* @map: a map.
|
|
155 |
* @key:
|
|
156 |
* @value:
|
|
157 |
*
|
|
158 |
*
|
|
159 |
*
|
|
160 |
* Return value:
|
|
161 |
*
|
|
162 |
* Since: 1.7.7
|
|
163 |
**/
|
|
164 |
void
|
|
165 |
hb_map_set (hb_map_t *map,
|
|
166 |
hb_codepoint_t key,
|
|
167 |
hb_codepoint_t value)
|
|
168 |
{
|
|
169 |
map->set (key, value);
|
|
170 |
}
|
|
171 |
|
|
172 |
/**
|
|
173 |
* hb_map_get:
|
|
174 |
* @map: a map.
|
|
175 |
* @key:
|
|
176 |
*
|
|
177 |
*
|
|
178 |
*
|
|
179 |
* Since: 1.7.7
|
|
180 |
**/
|
|
181 |
hb_codepoint_t
|
|
182 |
hb_map_get (const hb_map_t *map,
|
|
183 |
hb_codepoint_t key)
|
|
184 |
{
|
|
185 |
return map->get (key);
|
|
186 |
}
|
|
187 |
|
|
188 |
/**
|
|
189 |
* hb_map_del:
|
|
190 |
* @map: a map.
|
|
191 |
* @codepoint:
|
|
192 |
*
|
|
193 |
*
|
|
194 |
*
|
|
195 |
* Since: 1.7.7
|
|
196 |
**/
|
|
197 |
void
|
|
198 |
hb_map_del (hb_map_t *map,
|
|
199 |
hb_codepoint_t key)
|
|
200 |
{
|
|
201 |
map->del (key);
|
|
202 |
}
|
|
203 |
|
|
204 |
/**
|
|
205 |
* hb_map_has:
|
|
206 |
* @map: a map.
|
|
207 |
* @codepoint:
|
|
208 |
*
|
|
209 |
*
|
|
210 |
*
|
|
211 |
* Since: 1.7.7
|
|
212 |
**/
|
|
213 |
hb_bool_t
|
|
214 |
hb_map_has (const hb_map_t *map,
|
|
215 |
hb_codepoint_t key)
|
|
216 |
{
|
|
217 |
return map->has (key);
|
|
218 |
}
|
|
219 |
|
|
220 |
|
|
221 |
/**
|
|
222 |
* hb_map_clear:
|
|
223 |
* @map: a map.
|
|
224 |
*
|
|
225 |
*
|
|
226 |
*
|
|
227 |
* Since: 1.7.7
|
|
228 |
**/
|
|
229 |
void
|
|
230 |
hb_map_clear (hb_map_t *map)
|
|
231 |
{
|
|
232 |
return map->clear ();
|
|
233 |
}
|
|
234 |
|
|
235 |
/**
|
|
236 |
* hb_map_is_empty:
|
|
237 |
* @map: a map.
|
|
238 |
*
|
|
239 |
*
|
|
240 |
*
|
|
241 |
* Since: 1.7.7
|
|
242 |
**/
|
|
243 |
hb_bool_t
|
|
244 |
hb_map_is_empty (const hb_map_t *map)
|
|
245 |
{
|
|
246 |
return map->is_empty ();
|
|
247 |
}
|
|
248 |
|
|
249 |
/**
|
|
250 |
* hb_map_get_population:
|
|
251 |
* @map: a map.
|
|
252 |
*
|
|
253 |
*
|
|
254 |
*
|
|
255 |
* Since: 1.7.7
|
|
256 |
**/
|
|
257 |
unsigned int
|
|
258 |
hb_map_get_population (const hb_map_t *map)
|
|
259 |
{
|
|
260 |
return map->get_population ();
|
|
261 |
}
|