blob: 291e24974e65c5e50f02a135434072bcc58901da [file] [log] [blame]
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -04001/*
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
27#ifndef HB_H_IN
28#error "Include <hb.h> instead."
29#endif
30
31#ifndef HB_SET_H
32#define HB_SET_H
33
34#include "hb-common.h"
35
36HB_BEGIN_DECLS
37
38
Behdad Esfahbod1bc1cb32012-06-16 15:21:55 -040039typedef struct hb_set_t hb_set_t;
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040040
41
42hb_set_t *
43hb_set_create (void);
44
45hb_set_t *
46hb_set_get_empty (void);
47
48hb_set_t *
49hb_set_reference (hb_set_t *set);
50
51void
52hb_set_destroy (hb_set_t *set);
53
54hb_bool_t
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -040055hb_set_set_user_data (hb_set_t *set,
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040056 hb_user_data_key_t *key,
57 void * data,
58 hb_destroy_func_t destroy,
59 hb_bool_t replace);
60
61void *
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -040062hb_set_get_user_data (hb_set_t *set,
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040063 hb_user_data_key_t *key);
64
65
Behdad Esfahbod0594a242012-06-05 20:35:40 -040066/* Returns false if allocation has failed before */
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040067hb_bool_t
Behdad Esfahbodaec89de2012-11-15 16:15:42 -080068hb_set_allocation_successful (const hb_set_t *set);
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040069
70void
71hb_set_clear (hb_set_t *set);
72
73hb_bool_t
Behdad Esfahbodaec89de2012-11-15 16:15:42 -080074hb_set_is_empty (const hb_set_t *set);
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -040075
76hb_bool_t
Behdad Esfahbodaec89de2012-11-15 16:15:42 -080077hb_set_has (const hb_set_t *set,
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040078 hb_codepoint_t codepoint);
79
Behdad Esfahbod29ce4462012-05-25 14:17:54 -040080/* Right now limited to 16-bit integers. Eventually will do full codepoint range, sans -1
81 * which we will use as a sentinel. */
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040082void
83hb_set_add (hb_set_t *set,
84 hb_codepoint_t codepoint);
85
86void
Behdad Esfahbodaec89de2012-11-15 16:15:42 -080087hb_set_add_range (hb_set_t *set,
88 hb_codepoint_t first,
89 hb_codepoint_t last);
90
91void
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -040092hb_set_del (hb_set_t *set,
93 hb_codepoint_t codepoint);
94
Behdad Esfahbodaec89de2012-11-15 16:15:42 -080095void
96hb_set_del_range (hb_set_t *set,
97 hb_codepoint_t first,
98 hb_codepoint_t last);
99
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400100hb_bool_t
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800101hb_set_is_equal (const hb_set_t *set,
102 const hb_set_t *other);
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -0400103
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400104void
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800105hb_set_set (hb_set_t *set,
106 const hb_set_t *other);
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400107
108void
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800109hb_set_union (hb_set_t *set,
110 const hb_set_t *other);
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400111
112void
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800113hb_set_intersect (hb_set_t *set,
114 const hb_set_t *other);
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400115
116void
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800117hb_set_subtract (hb_set_t *set,
118 const hb_set_t *other);
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400119
Behdad Esfahbod62c3e112012-05-25 13:48:00 -0400120void
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800121hb_set_symmetric_difference (hb_set_t *set,
122 const hb_set_t *other);
123
Behdad Esfahbod8165f272013-01-02 22:50:36 -0600124void
125hb_set_invert (hb_set_t *set);
126
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800127unsigned int
Behdad Esfahbodac064a22012-11-21 01:14:19 -0500128hb_set_get_population (const hb_set_t *set);
Behdad Esfahbod62c3e112012-05-25 13:48:00 -0400129
Behdad Esfahbod29ce4462012-05-25 14:17:54 -0400130/* Returns -1 if set empty. */
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400131hb_codepoint_t
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800132hb_set_get_min (const hb_set_t *set);
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400133
Behdad Esfahbod29ce4462012-05-25 14:17:54 -0400134/* Returns -1 if set empty. */
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400135hb_codepoint_t
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800136hb_set_get_max (const hb_set_t *set);
Behdad Esfahbod6c6ccaf2012-04-24 14:21:15 -0400137
Behdad Esfahbod29ce4462012-05-25 14:17:54 -0400138/* Pass -1 in to get started. */
139hb_bool_t
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800140hb_set_next (const hb_set_t *set,
Behdad Esfahbod29ce4462012-05-25 14:17:54 -0400141 hb_codepoint_t *codepoint);
142
Behdad Esfahbodaec89de2012-11-15 16:15:42 -0800143/* Pass -1 for first and last to get started. */
144hb_bool_t
145hb_set_next_range (const hb_set_t *set,
146 hb_codepoint_t *first,
147 hb_codepoint_t *last);
Behdad Esfahbod0b08adb2012-04-23 22:41:09 -0400148
149
150HB_END_DECLS
151
152#endif /* HB_SET_H */