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