1 /* 2 * Copyright © 2012 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-set-private.hh" 28 29 30 /* Public API */ 31 32 33 /** 34 * hb_set_create: (Xconstructor) 35 * 36 * Return value: (transfer full): 37 * 38 * Since: 0.9.2 39 **/ 40 hb_set_t * 41 hb_set_create (void) 42 { 43 hb_set_t *set; 44 45 if (!(set = hb_object_create<hb_set_t> ())) 46 return hb_set_get_empty (); 47 48 set->page_map.init (); 49 set->pages.init (); 50 51 return set; 52 } 53 54 /** 55 * hb_set_get_empty: 56 * 57 * Return value: (transfer full): 58 * 59 * Since: 0.9.2 60 **/ 61 hb_set_t * 62 hb_set_get_empty (void) 63 { 64 static const hb_set_t _hb_set_nil = { 65 HB_OBJECT_HEADER_STATIC, 66 true, /* in_error */ 67 68 {0} /* elts */ 69 }; 70 71 return const_cast<hb_set_t *> (&_hb_set_nil); 72 } 73 74 /** 75 * hb_set_reference: (skip) 76 * @set: a set. 77 * 78 * Return value: (transfer full): 79 * 80 * Since: 0.9.2 81 **/ 82 hb_set_t * 83 hb_set_reference (hb_set_t *set) 84 { 85 return hb_object_reference (set); 86 } 87 88 /** 89 * hb_set_destroy: (skip) 90 * @set: a set. 91 * 92 * Since: 0.9.2 93 **/ 94 void 95 hb_set_destroy (hb_set_t *set) 96 { 97 if (!hb_object_destroy (set)) return; 98 99 set->page_map.finish (); 100 set->pages.finish (); 101 102 free (set); 103 } 104 105 /** 106 * hb_set_set_user_data: (skip) 107 * @set: a set. 108 * @key: 109 * @data: 110 * @destroy: 111 * @replace: 112 * 113 * Return value: 114 * 115 * Since: 0.9.2 116 **/ 117 hb_bool_t 118 hb_set_set_user_data (hb_set_t *set, 119 hb_user_data_key_t *key, 120 void * data, 121 hb_destroy_func_t destroy, 122 hb_bool_t replace) 123 { 124 return hb_object_set_user_data (set, key, data, destroy, replace); 125 } 126 127 /** 128 * hb_set_get_user_data: (skip) 129 * @set: a set. 130 * @key: 131 * 132 * Return value: (transfer none): 133 * 134 * Since: 0.9.2 135 **/ 136 void * 137 hb_set_get_user_data (hb_set_t *set, 138 hb_user_data_key_t *key) 139 { 140 return hb_object_get_user_data (set, key); 141 } 142 143 144 /** 145 * hb_set_allocation_successful: 146 * @set: a set. 147 * 148 * 149 * 150 * Return value: 151 * 152 * Since: 0.9.2 153 **/ 154 hb_bool_t 155 hb_set_allocation_successful (const hb_set_t *set HB_UNUSED) 156 { 157 return !set->in_error; 158 } 159 160 /** 161 * hb_set_clear: 162 * @set: a set. 163 * 164 * 165 * 166 * Since: 0.9.2 167 **/ 168 void 169 hb_set_clear (hb_set_t *set) 170 { 171 set->clear (); 172 } 173 174 /** 175 * hb_set_is_empty: 176 * @set: a set. 177 * 178 * 179 * 180 * Return value: 181 * 182 * Since: 0.9.7 183 **/ 184 hb_bool_t 185 hb_set_is_empty (const hb_set_t *set) 186 { 187 return set->is_empty (); 188 } 189 190 /** 191 * hb_set_has: 192 * @set: a set. 193 * @codepoint: 194 * 195 * 196 * 197 * Return value: 198 * 199 * Since: 0.9.2 200 **/ 201 hb_bool_t 202 hb_set_has (const hb_set_t *set, 203 hb_codepoint_t codepoint) 204 { 205 return set->has (codepoint); 206 } 207 208 /** 209 * hb_set_add: 210 * @set: a set. 211 * @codepoint: 212 * 213 * 214 * 215 * Since: 0.9.2 216 **/ 217 void 218 hb_set_add (hb_set_t *set, 219 hb_codepoint_t codepoint) 220 { 221 set->add (codepoint); 222 } 223 224 /** 225 * hb_set_add_range: 226 * @set: a set. 227 * @first: 228 * @last: 229 * 230 * 231 * 232 * Since: 0.9.7 233 **/ 234 void 235 hb_set_add_range (hb_set_t *set, 236 hb_codepoint_t first, 237 hb_codepoint_t last) 238 { 239 set->add_range (first, last); 240 } 241 242 /** 243 * hb_set_del: 244 * @set: a set. 245 * @codepoint: 246 * 247 * 248 * 249 * Since: 0.9.2 250 **/ 251 void 252 hb_set_del (hb_set_t *set, 253 hb_codepoint_t codepoint) 254 { 255 set->del (codepoint); 256 } 257 258 /** 259 * hb_set_del_range: 260 * @set: a set. 261 * @first: 262 * @last: 263 * 264 * 265 * 266 * Since: 0.9.7 267 **/ 268 void 269 hb_set_del_range (hb_set_t *set, 270 hb_codepoint_t first, 271 hb_codepoint_t last) 272 { 273 set->del_range (first, last); 274 } 275 276 /** 277 * hb_set_is_equal: 278 * @set: a set. 279 * @other: 280 * 281 * 282 * 283 * Return value: 284 * 285 * Since: 0.9.7 286 **/ 287 hb_bool_t 288 hb_set_is_equal (const hb_set_t *set, 289 const hb_set_t *other) 290 { 291 return set->is_equal (other); 292 } 293 294 /** 295 * hb_set_set: 296 * @set: a set. 297 * @other: 298 * 299 * 300 * 301 * Since: 0.9.2 302 **/ 303 void 304 hb_set_set (hb_set_t *set, 305 const hb_set_t *other) 306 { 307 set->set (other); 308 } 309 310 /** 311 * hb_set_union: 312 * @set: a set. 313 * @other: 314 * 315 * 316 * 317 * Since: 0.9.2 318 **/ 319 void 320 hb_set_union (hb_set_t *set, 321 const hb_set_t *other) 322 { 323 set->union_ (other); 324 } 325 326 /** 327 * hb_set_intersect: 328 * @set: a set. 329 * @other: 330 * 331 * 332 * 333 * Since: 0.9.2 334 **/ 335 void 336 hb_set_intersect (hb_set_t *set, 337 const hb_set_t *other) 338 { 339 set->intersect (other); 340 } 341 342 /** 343 * hb_set_subtract: 344 * @set: a set. 345 * @other: 346 * 347 * 348 * 349 * Since: 0.9.2 350 **/ 351 void 352 hb_set_subtract (hb_set_t *set, 353 const hb_set_t *other) 354 { 355 set->subtract (other); 356 } 357 358 /** 359 * hb_set_symmetric_difference: 360 * @set: a set. 361 * @other: 362 * 363 * 364 * 365 * Since: 0.9.2 366 **/ 367 void 368 hb_set_symmetric_difference (hb_set_t *set, 369 const hb_set_t *other) 370 { 371 set->symmetric_difference (other); 372 } 373 374 /** 375 * hb_set_invert: 376 * @set: a set. 377 * 378 * 379 * 380 * Since: 0.9.10 381 * 382 * Deprecated: 1.6.1 383 **/ 384 void 385 hb_set_invert (hb_set_t *set) 386 { 387 } 388 389 /** 390 * hb_set_get_population: 391 * @set: a set. 392 * 393 * Returns the number of numbers in the set. 394 * 395 * Return value: set population. 396 * 397 * Since: 0.9.7 398 **/ 399 unsigned int 400 hb_set_get_population (const hb_set_t *set) 401 { 402 return set->get_population (); 403 } 404 405 /** 406 * hb_set_get_min: 407 * @set: a set. 408 * 409 * Finds the minimum number in the set. 410 * 411 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty. 412 * 413 * Since: 0.9.7 414 **/ 415 hb_codepoint_t 416 hb_set_get_min (const hb_set_t *set) 417 { 418 return set->get_min (); 419 } 420 421 /** 422 * hb_set_get_max: 423 * @set: a set. 424 * 425 * Finds the maximum number in the set. 426 * 427 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty. 428 * 429 * Since: 0.9.7 430 **/ 431 hb_codepoint_t 432 hb_set_get_max (const hb_set_t *set) 433 { 434 return set->get_max (); 435 } 436 437 /** 438 * hb_set_next: 439 * @set: a set. 440 * @codepoint: (inout): 441 * 442 * 443 * 444 * Return value: whether there was a next value. 445 * 446 * Since: 0.9.2 447 **/ 448 hb_bool_t 449 hb_set_next (const hb_set_t *set, 450 hb_codepoint_t *codepoint) 451 { 452 return set->next (codepoint); 453 } 454 455 /** 456 * hb_set_next_range: 457 * @set: a set. 458 * @first: (out): output first codepoint in the range. 459 * @last: (inout): input current last and output last codepoint in the range. 460 * 461 * Gets the next consecutive range of numbers in @set that 462 * are greater than current value of @last. 463 * 464 * Return value: whether there was a next range. 465 * 466 * Since: 0.9.7 467 **/ 468 hb_bool_t 469 hb_set_next_range (const hb_set_t *set, 470 hb_codepoint_t *first, 471 hb_codepoint_t *last) 472 { 473 return set->next_range (first, last); 474 }