Imported Upstream version 0.9.3
[platform/upstream/harfbuzz.git] / src / hb-set.h
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
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
36 HB_BEGIN_DECLS
37
38
39 typedef struct hb_set_t hb_set_t;
40
41
42 hb_set_t *
43 hb_set_create (void);
44
45 hb_set_t *
46 hb_set_get_empty (void);
47
48 hb_set_t *
49 hb_set_reference (hb_set_t *set);
50
51 void
52 hb_set_destroy (hb_set_t *set);
53
54 hb_bool_t
55 hb_set_set_user_data (hb_set_t           *set,
56                       hb_user_data_key_t *key,
57                       void *              data,
58                       hb_destroy_func_t   destroy,
59                       hb_bool_t           replace);
60
61 void *
62 hb_set_get_user_data (hb_set_t           *set,
63                       hb_user_data_key_t *key);
64
65
66 /* Returns false if allocation has failed before */
67 hb_bool_t
68 hb_set_allocation_successful (hb_set_t  *set);
69
70 void
71 hb_set_clear (hb_set_t *set);
72
73 hb_bool_t
74 hb_set_empty (hb_set_t *set);
75
76 hb_bool_t
77 hb_set_has (hb_set_t       *set,
78             hb_codepoint_t  codepoint);
79
80 /* Right now limited to 16-bit integers.  Eventually will do full codepoint range, sans -1
81  * which we will use as a sentinel. */
82 void
83 hb_set_add (hb_set_t       *set,
84             hb_codepoint_t  codepoint);
85
86 void
87 hb_set_del (hb_set_t       *set,
88             hb_codepoint_t  codepoint);
89
90 hb_bool_t
91 hb_set_equal (hb_set_t *set,
92               hb_set_t *other);
93
94 void
95 hb_set_set (hb_set_t *set,
96             hb_set_t *other);
97
98 void
99 hb_set_union (hb_set_t *set,
100               hb_set_t *other);
101
102 void
103 hb_set_intersect (hb_set_t *set,
104                   hb_set_t *other);
105
106 void
107 hb_set_subtract (hb_set_t *set,
108                  hb_set_t *other);
109
110 void
111 hb_set_symmetric_difference (hb_set_t *set,
112                              hb_set_t *other);
113
114 /* Returns -1 if set empty. */
115 hb_codepoint_t
116 hb_set_min (hb_set_t *set);
117
118 /* Returns -1 if set empty. */
119 hb_codepoint_t
120 hb_set_max (hb_set_t *set);
121
122 /* Pass -1 in to get started. */
123 hb_bool_t
124 hb_set_next (hb_set_t       *set,
125              hb_codepoint_t *codepoint);
126
127 /* TODO: Add faster iteration API? */
128
129
130 HB_END_DECLS
131
132 #endif /* HB_SET_H */