hb-set.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. #ifndef HB_H_IN
  27. #error "Include <hb.h> instead."
  28. #endif
  29. #ifndef HB_SET_H
  30. #define HB_SET_H
  31. #include "hb-common.h"
  32. HB_BEGIN_DECLS
  33. #define HB_SET_VALUE_INVALID ((hb_codepoint_t) -1)
  34. typedef struct hb_set_t hb_set_t;
  35. hb_set_t *
  36. hb_set_create (void);
  37. hb_set_t *
  38. hb_set_get_empty (void);
  39. hb_set_t *
  40. hb_set_reference (hb_set_t *set);
  41. void
  42. hb_set_destroy (hb_set_t *set);
  43. hb_bool_t
  44. hb_set_set_user_data (hb_set_t *set,
  45. hb_user_data_key_t *key,
  46. void * data,
  47. hb_destroy_func_t destroy,
  48. hb_bool_t replace);
  49. void *
  50. hb_set_get_user_data (hb_set_t *set,
  51. hb_user_data_key_t *key);
  52. /* Returns false if allocation has failed before */
  53. hb_bool_t
  54. hb_set_allocation_successful (const hb_set_t *set);
  55. void
  56. hb_set_clear (hb_set_t *set);
  57. hb_bool_t
  58. hb_set_is_empty (const hb_set_t *set);
  59. hb_bool_t
  60. hb_set_has (const hb_set_t *set,
  61. hb_codepoint_t codepoint);
  62. /* Right now limited to 16-bit integers. Eventually will do full codepoint range, sans -1
  63. * which we will use as a sentinel. */
  64. void
  65. hb_set_add (hb_set_t *set,
  66. hb_codepoint_t codepoint);
  67. void
  68. hb_set_add_range (hb_set_t *set,
  69. hb_codepoint_t first,
  70. hb_codepoint_t last);
  71. void
  72. hb_set_del (hb_set_t *set,
  73. hb_codepoint_t codepoint);
  74. void
  75. hb_set_del_range (hb_set_t *set,
  76. hb_codepoint_t first,
  77. hb_codepoint_t last);
  78. hb_bool_t
  79. hb_set_is_equal (const hb_set_t *set,
  80. const hb_set_t *other);
  81. void
  82. hb_set_set (hb_set_t *set,
  83. const hb_set_t *other);
  84. void
  85. hb_set_union (hb_set_t *set,
  86. const hb_set_t *other);
  87. void
  88. hb_set_intersect (hb_set_t *set,
  89. const hb_set_t *other);
  90. void
  91. hb_set_subtract (hb_set_t *set,
  92. const hb_set_t *other);
  93. void
  94. hb_set_symmetric_difference (hb_set_t *set,
  95. const hb_set_t *other);
  96. void
  97. hb_set_invert (hb_set_t *set);
  98. unsigned int
  99. hb_set_get_population (const hb_set_t *set);
  100. /* Returns -1 if set empty. */
  101. hb_codepoint_t
  102. hb_set_get_min (const hb_set_t *set);
  103. /* Returns -1 if set empty. */
  104. hb_codepoint_t
  105. hb_set_get_max (const hb_set_t *set);
  106. /* Pass -1 in to get started. */
  107. hb_bool_t
  108. hb_set_next (const hb_set_t *set,
  109. hb_codepoint_t *codepoint);
  110. /* Pass -1 for first and last to get started. */
  111. hb_bool_t
  112. hb_set_next_range (const hb_set_t *set,
  113. hb_codepoint_t *first,
  114. hb_codepoint_t *last);
  115. HB_END_DECLS
  116. #endif /* HB_SET_H */