1 | /* GIO - GLib Input, Output and Streaming Library |
2 | * |
3 | * Copyright (C) 2009 Red Hat, Inc. |
4 | * |
5 | * SPDX-License-Identifier: LGPL-2.1-or-later |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2.1 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Lesser General |
18 | * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
19 | * |
20 | * Author: Alexander Larsson <alexl@redhat.com> |
21 | */ |
22 | |
23 | #ifndef __G_CONVERTER_H__ |
24 | #define __G_CONVERTER_H__ |
25 | |
26 | #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) |
27 | #error "Only <gio/gio.h> can be included directly." |
28 | #endif |
29 | |
30 | #include <gio/giotypes.h> |
31 | |
32 | G_BEGIN_DECLS |
33 | |
34 | #define G_TYPE_CONVERTER (g_converter_get_type ()) |
35 | #define G_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_CONVERTER, GConverter)) |
36 | #define G_IS_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_CONVERTER)) |
37 | #define G_CONVERTER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_CONVERTER, GConverterIface)) |
38 | |
39 | typedef struct _GConverterIface GConverterIface; |
40 | |
41 | /** |
42 | * GConverterIface: |
43 | * @g_iface: The parent interface. |
44 | * @convert: Converts data. |
45 | * @reset: Reverts the internal state of the converter to its initial state. |
46 | * |
47 | * Provides an interface for converting data from one type |
48 | * to another type. The conversion can be stateful |
49 | * and may fail at any place. |
50 | * |
51 | * Since: 2.24 |
52 | **/ |
53 | struct _GConverterIface |
54 | { |
55 | GTypeInterface g_iface; |
56 | |
57 | /* Virtual Table */ |
58 | |
59 | GConverterResult (* convert) (GConverter *converter, |
60 | const void *inbuf, |
61 | gsize inbuf_size, |
62 | void *outbuf, |
63 | gsize outbuf_size, |
64 | GConverterFlags flags, |
65 | gsize *bytes_read, |
66 | gsize *bytes_written, |
67 | GError **error); |
68 | void (* reset) (GConverter *converter); |
69 | }; |
70 | |
71 | GIO_AVAILABLE_IN_ALL |
72 | GType g_converter_get_type (void) G_GNUC_CONST; |
73 | |
74 | GIO_AVAILABLE_IN_ALL |
75 | GConverterResult g_converter_convert (GConverter *converter, |
76 | const void *inbuf, |
77 | gsize inbuf_size, |
78 | void *outbuf, |
79 | gsize outbuf_size, |
80 | GConverterFlags flags, |
81 | gsize *bytes_read, |
82 | gsize *bytes_written, |
83 | GError **error); |
84 | GIO_AVAILABLE_IN_ALL |
85 | void g_converter_reset (GConverter *converter); |
86 | |
87 | |
88 | G_END_DECLS |
89 | |
90 | |
91 | #endif /* __G_CONVERTER_H__ */ |
92 | |