hb-set.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
  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. /**
  34. * HB_SET_VALUE_INVALID:
  35. *
  36. * Unset #hb_set_t value.
  37. *
  38. * Since: 0.9.21
  39. */
  40. #define HB_SET_VALUE_INVALID ((hb_codepoint_t) -1)
  41. /**
  42. * hb_set_t:
  43. *
  44. * Data type for holding a set of integers. #hb_set_t's are
  45. * used to gather and contain glyph IDs, Unicode code
  46. * points, and various other collections of discrete
  47. * values.
  48. *
  49. **/
  50. typedef struct hb_set_t hb_set_t;
  51. HB_EXTERN hb_set_t *
  52. hb_set_create (void);
  53. HB_EXTERN hb_set_t *
  54. hb_set_get_empty (void);
  55. HB_EXTERN hb_set_t *
  56. hb_set_reference (hb_set_t *set);
  57. HB_EXTERN void
  58. hb_set_destroy (hb_set_t *set);
  59. HB_EXTERN hb_bool_t
  60. hb_set_set_user_data (hb_set_t *set,
  61. hb_user_data_key_t *key,
  62. void * data,
  63. hb_destroy_func_t destroy,
  64. hb_bool_t replace);
  65. HB_EXTERN void *
  66. hb_set_get_user_data (const hb_set_t *set,
  67. hb_user_data_key_t *key);
  68. /* Returns false if allocation has failed before */
  69. HB_EXTERN hb_bool_t
  70. hb_set_allocation_successful (const hb_set_t *set);
  71. HB_EXTERN hb_set_t *
  72. hb_set_copy (const hb_set_t *set);
  73. HB_EXTERN void
  74. hb_set_clear (hb_set_t *set);
  75. HB_EXTERN hb_bool_t
  76. hb_set_is_empty (const hb_set_t *set);
  77. HB_EXTERN void
  78. hb_set_invert (hb_set_t *set);
  79. HB_EXTERN hb_bool_t
  80. hb_set_has (const hb_set_t *set,
  81. hb_codepoint_t codepoint);
  82. HB_EXTERN void
  83. hb_set_add (hb_set_t *set,
  84. hb_codepoint_t codepoint);
  85. HB_EXTERN void
  86. hb_set_add_range (hb_set_t *set,
  87. hb_codepoint_t first,
  88. hb_codepoint_t last);
  89. HB_EXTERN void
  90. hb_set_add_sorted_array (hb_set_t *set,
  91. const hb_codepoint_t *sorted_codepoints,
  92. unsigned int num_codepoints);
  93. HB_EXTERN void
  94. hb_set_del (hb_set_t *set,
  95. hb_codepoint_t codepoint);
  96. HB_EXTERN void
  97. hb_set_del_range (hb_set_t *set,
  98. hb_codepoint_t first,
  99. hb_codepoint_t last);
  100. HB_EXTERN hb_bool_t
  101. hb_set_is_equal (const hb_set_t *set,
  102. const hb_set_t *other);
  103. HB_EXTERN unsigned int
  104. hb_set_hash (const hb_set_t *set);
  105. HB_EXTERN hb_bool_t
  106. hb_set_is_subset (const hb_set_t *set,
  107. const hb_set_t *larger_set);
  108. HB_EXTERN void
  109. hb_set_set (hb_set_t *set,
  110. const hb_set_t *other);
  111. HB_EXTERN void
  112. hb_set_union (hb_set_t *set,
  113. const hb_set_t *other);
  114. HB_EXTERN void
  115. hb_set_intersect (hb_set_t *set,
  116. const hb_set_t *other);
  117. HB_EXTERN void
  118. hb_set_subtract (hb_set_t *set,
  119. const hb_set_t *other);
  120. HB_EXTERN void
  121. hb_set_symmetric_difference (hb_set_t *set,
  122. const hb_set_t *other);
  123. HB_EXTERN unsigned int
  124. hb_set_get_population (const hb_set_t *set);
  125. /* Returns HB_SET_VALUE_INVALID if set empty. */
  126. HB_EXTERN hb_codepoint_t
  127. hb_set_get_min (const hb_set_t *set);
  128. /* Returns HB_SET_VALUE_INVALID if set empty. */
  129. HB_EXTERN hb_codepoint_t
  130. hb_set_get_max (const hb_set_t *set);
  131. /* Pass HB_SET_VALUE_INVALID in to get started. */
  132. HB_EXTERN hb_bool_t
  133. hb_set_next (const hb_set_t *set,
  134. hb_codepoint_t *codepoint);
  135. /* Pass HB_SET_VALUE_INVALID in to get started. */
  136. HB_EXTERN hb_bool_t
  137. hb_set_previous (const hb_set_t *set,
  138. hb_codepoint_t *codepoint);
  139. /* Pass HB_SET_VALUE_INVALID for first and last to get started. */
  140. HB_EXTERN hb_bool_t
  141. hb_set_next_range (const hb_set_t *set,
  142. hb_codepoint_t *first,
  143. hb_codepoint_t *last);
  144. /* Pass HB_SET_VALUE_INVALID for first and last to get started. */
  145. HB_EXTERN hb_bool_t
  146. hb_set_previous_range (const hb_set_t *set,
  147. hb_codepoint_t *first,
  148. hb_codepoint_t *last);
  149. /* Pass HB_SET_VALUE_INVALID in to get started. */
  150. HB_EXTERN unsigned int
  151. hb_set_next_many (const hb_set_t *set,
  152. hb_codepoint_t codepoint,
  153. hb_codepoint_t *out,
  154. unsigned int size);
  155. HB_END_DECLS
  156. #endif /* HB_SET_H */