gfx/harfbuzz/src/hb-set.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/harfbuzz/src/hb-set.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,471 @@
     1.4 +/*
     1.5 + * Copyright © 2012  Google, Inc.
     1.6 + *
     1.7 + *  This is part of HarfBuzz, a text shaping library.
     1.8 + *
     1.9 + * Permission is hereby granted, without written agreement and without
    1.10 + * license or royalty fees, to use, copy, modify, and distribute this
    1.11 + * software and its documentation for any purpose, provided that the
    1.12 + * above copyright notice and the following two paragraphs appear in
    1.13 + * all copies of this software.
    1.14 + *
    1.15 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
    1.16 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
    1.17 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
    1.18 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
    1.19 + * DAMAGE.
    1.20 + *
    1.21 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
    1.22 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    1.23 + * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
    1.24 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
    1.25 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
    1.26 + *
    1.27 + * Google Author(s): Behdad Esfahbod
    1.28 + */
    1.29 +
    1.30 +#include "hb-set-private.hh"
    1.31 +
    1.32 +
    1.33 +/* Public API */
    1.34 +
    1.35 +
    1.36 +/**
    1.37 + * hb_set_create: (Xconstructor)
    1.38 + *
    1.39 + * Return value: (transfer full):
    1.40 + *
    1.41 + * Since: 1.0
    1.42 + **/
    1.43 +hb_set_t *
    1.44 +hb_set_create (void)
    1.45 +{
    1.46 +  hb_set_t *set;
    1.47 +
    1.48 +  if (!(set = hb_object_create<hb_set_t> ()))
    1.49 +    return hb_set_get_empty ();
    1.50 +
    1.51 +  set->clear ();
    1.52 +
    1.53 +  return set;
    1.54 +}
    1.55 +
    1.56 +/**
    1.57 + * hb_set_get_empty:
    1.58 + *
    1.59 + * Return value: (transfer full):
    1.60 + *
    1.61 + * Since: 1.0
    1.62 + **/
    1.63 +hb_set_t *
    1.64 +hb_set_get_empty (void)
    1.65 +{
    1.66 +  static const hb_set_t _hb_set_nil = {
    1.67 +    HB_OBJECT_HEADER_STATIC,
    1.68 +    true, /* in_error */
    1.69 +
    1.70 +    {0} /* elts */
    1.71 +  };
    1.72 +
    1.73 +  return const_cast<hb_set_t *> (&_hb_set_nil);
    1.74 +}
    1.75 +
    1.76 +/**
    1.77 + * hb_set_reference: (skip)
    1.78 + * @set: a set.
    1.79 + *
    1.80 + * Return value: (transfer full):
    1.81 + *
    1.82 + * Since: 1.0
    1.83 + **/
    1.84 +hb_set_t *
    1.85 +hb_set_reference (hb_set_t *set)
    1.86 +{
    1.87 +  return hb_object_reference (set);
    1.88 +}
    1.89 +
    1.90 +/**
    1.91 + * hb_set_destroy: (skip)
    1.92 + * @set: a set.
    1.93 + *
    1.94 + * Since: 1.0
    1.95 + **/
    1.96 +void
    1.97 +hb_set_destroy (hb_set_t *set)
    1.98 +{
    1.99 +  if (!hb_object_destroy (set)) return;
   1.100 +
   1.101 +  set->fini ();
   1.102 +
   1.103 +  free (set);
   1.104 +}
   1.105 +
   1.106 +/**
   1.107 + * hb_set_set_user_data: (skip)
   1.108 + * @set: a set.
   1.109 + * @key:
   1.110 + * @data:
   1.111 + * @destroy (closure data):
   1.112 + * @replace:
   1.113 + *
   1.114 + * Return value:
   1.115 + *
   1.116 + * Since: 1.0
   1.117 + **/
   1.118 +hb_bool_t
   1.119 +hb_set_set_user_data (hb_set_t           *set,
   1.120 +		      hb_user_data_key_t *key,
   1.121 +		      void *              data,
   1.122 +		      hb_destroy_func_t   destroy,
   1.123 +		      hb_bool_t           replace)
   1.124 +{
   1.125 +  return hb_object_set_user_data (set, key, data, destroy, replace);
   1.126 +}
   1.127 +
   1.128 +/**
   1.129 + * hb_set_get_user_data: (skip)
   1.130 + * @set: a set.
   1.131 + * @key:
   1.132 + *
   1.133 + * Return value: (transfer none):
   1.134 + *
   1.135 + * Since: 1.0
   1.136 + **/
   1.137 +void *
   1.138 +hb_set_get_user_data (hb_set_t           *set,
   1.139 +		      hb_user_data_key_t *key)
   1.140 +{
   1.141 +  return hb_object_get_user_data (set, key);
   1.142 +}
   1.143 +
   1.144 +
   1.145 +/**
   1.146 + * hb_set_allocation_successful:
   1.147 + * @set: a set.
   1.148 + *
   1.149 + * 
   1.150 + *
   1.151 + * Return value: 
   1.152 + *
   1.153 + * Since: 1.0
   1.154 + **/
   1.155 +hb_bool_t
   1.156 +hb_set_allocation_successful (const hb_set_t  *set HB_UNUSED)
   1.157 +{
   1.158 +  return !set->in_error;
   1.159 +}
   1.160 +
   1.161 +/**
   1.162 + * hb_set_clear:
   1.163 + * @set: a set.
   1.164 + *
   1.165 + * 
   1.166 + *
   1.167 + * Since: 1.0
   1.168 + **/
   1.169 +void
   1.170 +hb_set_clear (hb_set_t *set)
   1.171 +{
   1.172 +  set->clear ();
   1.173 +}
   1.174 +
   1.175 +/**
   1.176 + * hb_set_is_empty:
   1.177 + * @set: a set.
   1.178 + *
   1.179 + * 
   1.180 + *
   1.181 + * Return value: 
   1.182 + *
   1.183 + * Since: 1.0
   1.184 + **/
   1.185 +hb_bool_t
   1.186 +hb_set_is_empty (const hb_set_t *set)
   1.187 +{
   1.188 +  return set->is_empty ();
   1.189 +}
   1.190 +
   1.191 +/**
   1.192 + * hb_set_has:
   1.193 + * @set: a set.
   1.194 + * @codepoint: 
   1.195 + *
   1.196 + * 
   1.197 + *
   1.198 + * Return value: 
   1.199 + *
   1.200 + * Since: 1.0
   1.201 + **/
   1.202 +hb_bool_t
   1.203 +hb_set_has (const hb_set_t *set,
   1.204 +	    hb_codepoint_t  codepoint)
   1.205 +{
   1.206 +  return set->has (codepoint);
   1.207 +}
   1.208 +
   1.209 +/**
   1.210 + * hb_set_add:
   1.211 + * @set: a set.
   1.212 + * @codepoint: 
   1.213 + *
   1.214 + * 
   1.215 + *
   1.216 + * Since: 1.0
   1.217 + **/
   1.218 +void
   1.219 +hb_set_add (hb_set_t       *set,
   1.220 +	    hb_codepoint_t  codepoint)
   1.221 +{
   1.222 +  set->add (codepoint);
   1.223 +}
   1.224 +
   1.225 +/**
   1.226 + * hb_set_add_range:
   1.227 + * @set: a set.
   1.228 + * @first: 
   1.229 + * @last: 
   1.230 + *
   1.231 + * 
   1.232 + *
   1.233 + * Since: 1.0
   1.234 + **/
   1.235 +void
   1.236 +hb_set_add_range (hb_set_t       *set,
   1.237 +		  hb_codepoint_t  first,
   1.238 +		  hb_codepoint_t  last)
   1.239 +{
   1.240 +  set->add_range (first, last);
   1.241 +}
   1.242 +
   1.243 +/**
   1.244 + * hb_set_del:
   1.245 + * @set: a set.
   1.246 + * @codepoint: 
   1.247 + *
   1.248 + * 
   1.249 + *
   1.250 + * Since: 1.0
   1.251 + **/
   1.252 +void
   1.253 +hb_set_del (hb_set_t       *set,
   1.254 +	    hb_codepoint_t  codepoint)
   1.255 +{
   1.256 +  set->del (codepoint);
   1.257 +}
   1.258 +
   1.259 +/**
   1.260 + * hb_set_del_range:
   1.261 + * @set: a set.
   1.262 + * @first: 
   1.263 + * @last: 
   1.264 + *
   1.265 + * 
   1.266 + *
   1.267 + * Since: 1.0
   1.268 + **/
   1.269 +void
   1.270 +hb_set_del_range (hb_set_t       *set,
   1.271 +		  hb_codepoint_t  first,
   1.272 +		  hb_codepoint_t  last)
   1.273 +{
   1.274 +  set->del_range (first, last);
   1.275 +}
   1.276 +
   1.277 +/**
   1.278 + * hb_set_is_equal:
   1.279 + * @set: a set.
   1.280 + * @other: 
   1.281 + *
   1.282 + * 
   1.283 + *
   1.284 + * Return value: 
   1.285 + *
   1.286 + * Since: 1.0
   1.287 + **/
   1.288 +hb_bool_t
   1.289 +hb_set_is_equal (const hb_set_t *set,
   1.290 +		 const hb_set_t *other)
   1.291 +{
   1.292 +  return set->is_equal (other);
   1.293 +}
   1.294 +
   1.295 +/**
   1.296 + * hb_set_set:
   1.297 + * @set: a set.
   1.298 + * @other: 
   1.299 + *
   1.300 + * 
   1.301 + *
   1.302 + * Since: 1.0
   1.303 + **/
   1.304 +void
   1.305 +hb_set_set (hb_set_t       *set,
   1.306 +	    const hb_set_t *other)
   1.307 +{
   1.308 +  set->set (other);
   1.309 +}
   1.310 +
   1.311 +/**
   1.312 + * hb_set_union:
   1.313 + * @set: a set.
   1.314 + * @other: 
   1.315 + *
   1.316 + * 
   1.317 + *
   1.318 + * Since: 1.0
   1.319 + **/
   1.320 +void
   1.321 +hb_set_union (hb_set_t       *set,
   1.322 +	      const hb_set_t *other)
   1.323 +{
   1.324 +  set->union_ (other);
   1.325 +}
   1.326 +
   1.327 +/**
   1.328 + * hb_set_intersect:
   1.329 + * @set: a set.
   1.330 + * @other: 
   1.331 + *
   1.332 + * 
   1.333 + *
   1.334 + * Since: 1.0
   1.335 + **/
   1.336 +void
   1.337 +hb_set_intersect (hb_set_t       *set,
   1.338 +		  const hb_set_t *other)
   1.339 +{
   1.340 +  set->intersect (other);
   1.341 +}
   1.342 +
   1.343 +/**
   1.344 + * hb_set_subtract:
   1.345 + * @set: a set.
   1.346 + * @other: 
   1.347 + *
   1.348 + * 
   1.349 + *
   1.350 + * Since: 1.0
   1.351 + **/
   1.352 +void
   1.353 +hb_set_subtract (hb_set_t       *set,
   1.354 +		 const hb_set_t *other)
   1.355 +{
   1.356 +  set->subtract (other);
   1.357 +}
   1.358 +
   1.359 +/**
   1.360 + * hb_set_symmetric_difference:
   1.361 + * @set: a set.
   1.362 + * @other: 
   1.363 + *
   1.364 + * 
   1.365 + *
   1.366 + * Since: 1.0
   1.367 + **/
   1.368 +void
   1.369 +hb_set_symmetric_difference (hb_set_t       *set,
   1.370 +			     const hb_set_t *other)
   1.371 +{
   1.372 +  set->symmetric_difference (other);
   1.373 +}
   1.374 +
   1.375 +/**
   1.376 + * hb_set_invert:
   1.377 + * @set: a set.
   1.378 + *
   1.379 + * 
   1.380 + *
   1.381 + * Since: 1.0
   1.382 + **/
   1.383 +void
   1.384 +hb_set_invert (hb_set_t *set)
   1.385 +{
   1.386 +  set->invert ();
   1.387 +}
   1.388 +
   1.389 +/**
   1.390 + * hb_set_get_population:
   1.391 + * @set: a set.
   1.392 + *
   1.393 + * Returns the number of numbers in the set.
   1.394 + *
   1.395 + * Return value: set population.
   1.396 + *
   1.397 + * Since: 1.0
   1.398 + **/
   1.399 +unsigned int
   1.400 +hb_set_get_population (const hb_set_t *set)
   1.401 +{
   1.402 +  return set->get_population ();
   1.403 +}
   1.404 +
   1.405 +/**
   1.406 + * hb_set_get_min:
   1.407 + * @set: a set.
   1.408 + *
   1.409 + * Finds the minimum number in the set.
   1.410 + *
   1.411 + * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
   1.412 + *
   1.413 + * Since: 1.0
   1.414 + **/
   1.415 +hb_codepoint_t
   1.416 +hb_set_get_min (const hb_set_t *set)
   1.417 +{
   1.418 +  return set->get_min ();
   1.419 +}
   1.420 +
   1.421 +/**
   1.422 + * hb_set_get_max:
   1.423 + * @set: a set.
   1.424 + *
   1.425 + * Finds the maximum number in the set.
   1.426 + *
   1.427 + * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
   1.428 + *
   1.429 + * Since: 1.0
   1.430 + **/
   1.431 +hb_codepoint_t
   1.432 +hb_set_get_max (const hb_set_t *set)
   1.433 +{
   1.434 +  return set->get_max ();
   1.435 +}
   1.436 +
   1.437 +/**
   1.438 + * hb_set_next:
   1.439 + * @set: a set.
   1.440 + * @codepoint: (inout):
   1.441 + *
   1.442 + * 
   1.443 + *
   1.444 + * Return value: whether there was a next value.
   1.445 + *
   1.446 + * Since: 1.0
   1.447 + **/
   1.448 +hb_bool_t
   1.449 +hb_set_next (const hb_set_t *set,
   1.450 +	     hb_codepoint_t *codepoint)
   1.451 +{
   1.452 +  return set->next (codepoint);
   1.453 +}
   1.454 +
   1.455 +/**
   1.456 + * hb_set_next_range:
   1.457 + * @set: a set.
   1.458 + * @first: (out): output first codepoint in the range.
   1.459 + * @last: (inout): input current last and output last codepoint in the range.
   1.460 + *
   1.461 + * Gets the next consecutive range of numbers in @set that
   1.462 + * are greater than current value of @last.
   1.463 + *
   1.464 + * Return value: whether there was a next range.
   1.465 + *
   1.466 + * Since: 1.0
   1.467 + **/
   1.468 +hb_bool_t
   1.469 +hb_set_next_range (const hb_set_t *set,
   1.470 +		   hb_codepoint_t *first,
   1.471 +		   hb_codepoint_t *last)
   1.472 +{
   1.473 +  return set->next_range (first, last);
   1.474 +}

mercurial