michael@0: /* michael@0: * Copyright © 2012 Google, Inc. michael@0: * michael@0: * This is part of HarfBuzz, a text shaping library. michael@0: * michael@0: * Permission is hereby granted, without written agreement and without michael@0: * license or royalty fees, to use, copy, modify, and distribute this michael@0: * software and its documentation for any purpose, provided that the michael@0: * above copyright notice and the following two paragraphs appear in michael@0: * all copies of this software. michael@0: * michael@0: * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR michael@0: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES michael@0: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN michael@0: * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH michael@0: * DAMAGE. michael@0: * michael@0: * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, michael@0: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND michael@0: * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS michael@0: * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO michael@0: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. michael@0: * michael@0: * Google Author(s): Behdad Esfahbod michael@0: */ michael@0: michael@0: #include "hb-set-private.hh" michael@0: michael@0: michael@0: /* Public API */ michael@0: michael@0: michael@0: /** michael@0: * hb_set_create: (Xconstructor) michael@0: * michael@0: * Return value: (transfer full): michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_set_t * michael@0: hb_set_create (void) michael@0: { michael@0: hb_set_t *set; michael@0: michael@0: if (!(set = hb_object_create ())) michael@0: return hb_set_get_empty (); michael@0: michael@0: set->clear (); michael@0: michael@0: return set; michael@0: } michael@0: michael@0: /** michael@0: * hb_set_get_empty: michael@0: * michael@0: * Return value: (transfer full): michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_set_t * michael@0: hb_set_get_empty (void) michael@0: { michael@0: static const hb_set_t _hb_set_nil = { michael@0: HB_OBJECT_HEADER_STATIC, michael@0: true, /* in_error */ michael@0: michael@0: {0} /* elts */ michael@0: }; michael@0: michael@0: return const_cast (&_hb_set_nil); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_reference: (skip) michael@0: * @set: a set. michael@0: * michael@0: * Return value: (transfer full): michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_set_t * michael@0: hb_set_reference (hb_set_t *set) michael@0: { michael@0: return hb_object_reference (set); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_destroy: (skip) michael@0: * @set: a set. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_destroy (hb_set_t *set) michael@0: { michael@0: if (!hb_object_destroy (set)) return; michael@0: michael@0: set->fini (); michael@0: michael@0: free (set); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_set_user_data: (skip) michael@0: * @set: a set. michael@0: * @key: michael@0: * @data: michael@0: * @destroy (closure data): michael@0: * @replace: michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_set_set_user_data (hb_set_t *set, michael@0: hb_user_data_key_t *key, michael@0: void * data, michael@0: hb_destroy_func_t destroy, michael@0: hb_bool_t replace) michael@0: { michael@0: return hb_object_set_user_data (set, key, data, destroy, replace); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_get_user_data: (skip) michael@0: * @set: a set. michael@0: * @key: michael@0: * michael@0: * Return value: (transfer none): michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void * michael@0: hb_set_get_user_data (hb_set_t *set, michael@0: hb_user_data_key_t *key) michael@0: { michael@0: return hb_object_get_user_data (set, key); michael@0: } michael@0: michael@0: michael@0: /** michael@0: * hb_set_allocation_successful: michael@0: * @set: a set. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_set_allocation_successful (const hb_set_t *set HB_UNUSED) michael@0: { michael@0: return !set->in_error; michael@0: } michael@0: michael@0: /** michael@0: * hb_set_clear: michael@0: * @set: a set. michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_clear (hb_set_t *set) michael@0: { michael@0: set->clear (); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_is_empty: michael@0: * @set: a set. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_set_is_empty (const hb_set_t *set) michael@0: { michael@0: return set->is_empty (); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_has: michael@0: * @set: a set. michael@0: * @codepoint: michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_set_has (const hb_set_t *set, michael@0: hb_codepoint_t codepoint) michael@0: { michael@0: return set->has (codepoint); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_add: michael@0: * @set: a set. michael@0: * @codepoint: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_add (hb_set_t *set, michael@0: hb_codepoint_t codepoint) michael@0: { michael@0: set->add (codepoint); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_add_range: michael@0: * @set: a set. michael@0: * @first: michael@0: * @last: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_add_range (hb_set_t *set, michael@0: hb_codepoint_t first, michael@0: hb_codepoint_t last) michael@0: { michael@0: set->add_range (first, last); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_del: michael@0: * @set: a set. michael@0: * @codepoint: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_del (hb_set_t *set, michael@0: hb_codepoint_t codepoint) michael@0: { michael@0: set->del (codepoint); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_del_range: michael@0: * @set: a set. michael@0: * @first: michael@0: * @last: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_del_range (hb_set_t *set, michael@0: hb_codepoint_t first, michael@0: hb_codepoint_t last) michael@0: { michael@0: set->del_range (first, last); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_is_equal: michael@0: * @set: a set. michael@0: * @other: michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_set_is_equal (const hb_set_t *set, michael@0: const hb_set_t *other) michael@0: { michael@0: return set->is_equal (other); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_set: michael@0: * @set: a set. michael@0: * @other: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_set (hb_set_t *set, michael@0: const hb_set_t *other) michael@0: { michael@0: set->set (other); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_union: michael@0: * @set: a set. michael@0: * @other: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_union (hb_set_t *set, michael@0: const hb_set_t *other) michael@0: { michael@0: set->union_ (other); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_intersect: michael@0: * @set: a set. michael@0: * @other: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_intersect (hb_set_t *set, michael@0: const hb_set_t *other) michael@0: { michael@0: set->intersect (other); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_subtract: michael@0: * @set: a set. michael@0: * @other: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_subtract (hb_set_t *set, michael@0: const hb_set_t *other) michael@0: { michael@0: set->subtract (other); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_symmetric_difference: michael@0: * @set: a set. michael@0: * @other: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_symmetric_difference (hb_set_t *set, michael@0: const hb_set_t *other) michael@0: { michael@0: set->symmetric_difference (other); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_invert: michael@0: * @set: a set. michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_set_invert (hb_set_t *set) michael@0: { michael@0: set->invert (); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_get_population: michael@0: * @set: a set. michael@0: * michael@0: * Returns the number of numbers in the set. michael@0: * michael@0: * Return value: set population. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: unsigned int michael@0: hb_set_get_population (const hb_set_t *set) michael@0: { michael@0: return set->get_population (); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_get_min: michael@0: * @set: a set. michael@0: * michael@0: * Finds the minimum number in the set. michael@0: * michael@0: * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_codepoint_t michael@0: hb_set_get_min (const hb_set_t *set) michael@0: { michael@0: return set->get_min (); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_get_max: michael@0: * @set: a set. michael@0: * michael@0: * Finds the maximum number in the set. michael@0: * michael@0: * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_codepoint_t michael@0: hb_set_get_max (const hb_set_t *set) michael@0: { michael@0: return set->get_max (); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_next: michael@0: * @set: a set. michael@0: * @codepoint: (inout): michael@0: * michael@0: * michael@0: * michael@0: * Return value: whether there was a next value. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_set_next (const hb_set_t *set, michael@0: hb_codepoint_t *codepoint) michael@0: { michael@0: return set->next (codepoint); michael@0: } michael@0: michael@0: /** michael@0: * hb_set_next_range: michael@0: * @set: a set. michael@0: * @first: (out): output first codepoint in the range. michael@0: * @last: (inout): input current last and output last codepoint in the range. michael@0: * michael@0: * Gets the next consecutive range of numbers in @set that michael@0: * are greater than current value of @last. michael@0: * michael@0: * Return value: whether there was a next range. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_set_next_range (const hb_set_t *set, michael@0: hb_codepoint_t *first, michael@0: hb_codepoint_t *last) michael@0: { michael@0: return set->next_range (first, last); michael@0: }