gtkbitset.h 9.76 KB
Newer Older
Benjamin Otte's avatar
Benjamin Otte committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright © 2020 Benjamin Otte
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */


#ifndef __GTK_BITSET_H__
#define __GTK_BITSET_H__

#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

#include <gtk/gtktypes.h>

G_BEGIN_DECLS

#define GTK_TYPE_BITSET (gtk_bitset_get_type ())

GDK_AVAILABLE_IN_ALL
GType                   gtk_bitset_get_type                     (void) G_GNUC_CONST;

GDK_AVAILABLE_IN_ALL
GtkBitset *             gtk_bitset_ref                          (GtkBitset              *self);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_unref                        (GtkBitset              *self);
41
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkBitset, gtk_bitset_unref)
Benjamin Otte's avatar
Benjamin Otte committed
42
43
44
45
46
47
48
49
50
51

GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_contains                     (const GtkBitset        *self,
                                                                 guint                   value);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_is_empty                     (const GtkBitset        *self);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_equals                       (const GtkBitset        *self,
                                                                 const GtkBitset        *other);
GDK_AVAILABLE_IN_ALL
52
53
54
55
56
57
58
59
60
guint64                 gtk_bitset_get_size                     (const GtkBitset        *self);
GDK_AVAILABLE_IN_ALL
guint64                 gtk_bitset_get_size_in_range            (const GtkBitset        *self,
                                                                 guint                   first,
                                                                 guint                   last);
GDK_AVAILABLE_IN_ALL
guint                   gtk_bitset_get_nth                      (const GtkBitset        *self,
                                                                 guint                   nth);
GDK_AVAILABLE_IN_ALL
Benjamin Otte's avatar
Benjamin Otte committed
61
62
63
64
65
66
67
68
guint                   gtk_bitset_get_minimum                  (const GtkBitset        *self);
GDK_AVAILABLE_IN_ALL
guint                   gtk_bitset_get_maximum                  (const GtkBitset        *self);

GDK_AVAILABLE_IN_ALL
GtkBitset *             gtk_bitset_new_empty                    (void);
GDK_AVAILABLE_IN_ALL
GtkBitset *             gtk_bitset_copy                         (const GtkBitset        *self);
69
70
71
GDK_AVAILABLE_IN_ALL
GtkBitset *             gtk_bitset_new_range                    (guint                   start,
                                                                 guint                   n_items);
Benjamin Otte's avatar
Benjamin Otte committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_remove_all                   (GtkBitset              *self);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_add                          (GtkBitset              *self,
                                                                 guint                   value);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_remove                       (GtkBitset              *self,
                                                                 guint                   value);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_add_range                    (GtkBitset              *self,
                                                                 guint                   start,
                                                                 guint                   n_items);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_remove_range                 (GtkBitset              *self,
                                                                 guint                   start,
                                                                 guint                   n_items);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_add_range_closed             (GtkBitset              *self,
                                                                 guint                   first,
                                                                 guint                   last);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_remove_range_closed          (GtkBitset              *self,
                                                                 guint                   first,
                                                                 guint                   last);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_add_rectangle                (GtkBitset              *self,
                                                                 guint                   start,
                                                                 guint                   width,
                                                                 guint                   height,
                                                                 guint                   stride);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_remove_rectangle             (GtkBitset              *self,
                                                                 guint                   start,
                                                                 guint                   width,
                                                                 guint                   height,
                                                                 guint                   stride);

GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_union                        (GtkBitset              *self,
                                                                 const GtkBitset        *other);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_intersect                    (GtkBitset              *self,
                                                                 const GtkBitset        *other);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_subtract                     (GtkBitset              *self,
                                                                 const GtkBitset        *other);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_difference                   (GtkBitset              *self,
                                                                 const GtkBitset        *other);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_shift_left                   (GtkBitset              *self,
                                                                 guint                   amount);
GDK_AVAILABLE_IN_ALL
void                    gtk_bitset_shift_right                  (GtkBitset              *self,
                                                                 guint                   amount);
GDK_AVAILABLE_IN_ALL
129
void                    gtk_bitset_splice                       (GtkBitset              *self,
Benjamin Otte's avatar
Benjamin Otte committed
130
131
132
133
                                                                 guint                   position,
                                                                 guint                   removed,
                                                                 guint                   added);

Matthias Clasen's avatar
Matthias Clasen committed
134
135
136
137
/**
 * GtkBitsetIter:
 *
 * An opaque, stack-allocated struct for iterating
Matthias Clasen's avatar
Matthias Clasen committed
138
139
140
141
142
 * over the elements of a `GtkBitset`.
 *
 * Before a `GtkBitsetIter` can be used, it needs to be initialized with
 * [func@Gtk.BitsetIter.init_first], [func@Gtk.BitsetIter.init_last]
 * or [func@Gtk.BitsetIter.init_at].
Matthias Clasen's avatar
Matthias Clasen committed
143
 */
Matthias Clasen's avatar
Matthias Clasen committed
144
145
146
147
typedef struct _GtkBitsetIter GtkBitsetIter;

struct _GtkBitsetIter
{
148
  /*< private >*/
Matthias Clasen's avatar
Matthias Clasen committed
149
150
  gpointer private_data[10];
};
Benjamin Otte's avatar
Benjamin Otte committed
151

152
153
154
GDK_AVAILABLE_IN_4_6
GType                   gtk_bitset_iter_get_type                (void) G_GNUC_CONST;

Benjamin Otte's avatar
Benjamin Otte committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_iter_init_first              (GtkBitsetIter          *iter,
                                                                 const GtkBitset        *set,
                                                                 guint                  *value);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_iter_init_last               (GtkBitsetIter          *iter,
                                                                 const GtkBitset        *set,
                                                                 guint                  *value);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_iter_init_at                 (GtkBitsetIter          *iter,
                                                                 const GtkBitset        *set,
                                                                 guint                   target,
                                                                 guint                  *value);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_iter_next                    (GtkBitsetIter          *iter,
                                                                 guint                  *value);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_iter_previous                (GtkBitsetIter          *iter,
                                                                 guint                  *value);
GDK_AVAILABLE_IN_ALL
guint                   gtk_bitset_iter_get_value               (const GtkBitsetIter    *iter);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_bitset_iter_is_valid                (const GtkBitsetIter    *iter);

G_END_DECLS

#endif /* __GTK_BITSET_H__ */