hb-set.h 3.7 KB

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