1 /*
2  * Copyright © 2018  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_MAP_H
32 #define HB_MAP_H
33 
34 #include "hb-common.h"
35 
36 HB_BEGIN_DECLS
37 
38 
39 /*
40  * Since: 1.7.7
41  */
42 #define HB_MAP_VALUE_INVALID ((hb_codepoint_t) -1)
43 
44 typedef struct hb_map_t hb_map_t;
45 
46 
47 HB_EXTERN hb_map_t *
48 hb_map_create (void);
49 
50 HB_EXTERN hb_map_t *
51 hb_map_get_empty (void);
52 
53 HB_EXTERN hb_map_t *
54 hb_map_reference (hb_map_t *map);
55 
56 HB_EXTERN void
57 hb_map_destroy (hb_map_t *map);
58 
59 HB_EXTERN hb_bool_t
60 hb_map_set_user_data (hb_map_t           *map,
61 		      hb_user_data_key_t *key,
62 		      void *              data,
63 		      hb_destroy_func_t   destroy,
64 		      hb_bool_t           replace);
65 
66 HB_EXTERN void *
67 hb_map_get_user_data (hb_map_t           *map,
68 		      hb_user_data_key_t *key);
69 
70 
71 /* Returns false if allocation has failed before */
72 HB_EXTERN hb_bool_t
73 hb_map_allocation_successful (const hb_map_t *map);
74 
75 HB_EXTERN void
76 hb_map_clear (hb_map_t *map);
77 
78 HB_EXTERN hb_bool_t
79 hb_map_is_empty (const hb_map_t *map);
80 
81 HB_EXTERN unsigned int
82 hb_map_get_population (const hb_map_t *map);
83 
84 HB_EXTERN void
85 hb_map_set (hb_map_t       *map,
86 	    hb_codepoint_t  key,
87 	    hb_codepoint_t  value);
88 
89 HB_EXTERN hb_codepoint_t
90 hb_map_get (const hb_map_t *map,
91 	    hb_codepoint_t  key);
92 
93 HB_EXTERN void
94 hb_map_del (hb_map_t       *map,
95 	    hb_codepoint_t  key);
96 
97 HB_EXTERN hb_bool_t
98 hb_map_has (const hb_map_t *map,
99 	    hb_codepoint_t  key);
100 
101 
102 HB_END_DECLS
103 
104 #endif /* HB_MAP_H */
105