1 | /* |
2 | * Copyright © 2021 Benjamin Otte |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2.1 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | * |
17 | * Authors: Benjamin Otte <otte@gnome.org> |
18 | */ |
19 | |
20 | |
21 | #ifndef __GTK_JSON_PRINTER_H__ |
22 | #define __GTK_JSON_PRINTER_H__ |
23 | |
24 | #include <glib.h> |
25 | |
26 | G_BEGIN_DECLS |
27 | |
28 | typedef struct _GtkJsonPrinter GtkJsonPrinter; |
29 | |
30 | typedef enum { |
31 | GTK_JSON_PRINTER_PRETTY = (1 << 0), |
32 | GTK_JSON_PRINTER_ASCII = (1 << 1), |
33 | } GtkJsonPrinterFlags; |
34 | |
35 | typedef void (* GtkJsonPrinterWriteFunc) (GtkJsonPrinter *printer, |
36 | const char *s, |
37 | gpointer user_data); |
38 | |
39 | |
40 | GtkJsonPrinter * gtk_json_printer_new (GtkJsonPrinterWriteFunc write_func, |
41 | gpointer data, |
42 | GDestroyNotify destroy); |
43 | void gtk_json_printer_free (GtkJsonPrinter *self); |
44 | |
45 | void gtk_json_printer_set_flags (GtkJsonPrinter *self, |
46 | GtkJsonPrinterFlags flags); |
47 | GtkJsonPrinterFlags gtk_json_printer_get_flags (GtkJsonPrinter *self); |
48 | void gtk_json_printer_set_indentation (GtkJsonPrinter *self, |
49 | gsize amount); |
50 | gsize gtk_json_printer_get_indentation (GtkJsonPrinter *self); |
51 | |
52 | gsize gtk_json_printer_get_depth (GtkJsonPrinter *self); |
53 | gsize gtk_json_printer_get_n_elements (GtkJsonPrinter *self); |
54 | |
55 | void gtk_json_printer_add_boolean (GtkJsonPrinter *self, |
56 | const char *name, |
57 | gboolean value); |
58 | void gtk_json_printer_add_number (GtkJsonPrinter *self, |
59 | const char *name, |
60 | double value); |
61 | void gtk_json_printer_add_integer (GtkJsonPrinter *self, |
62 | const char *name, |
63 | int value); |
64 | void gtk_json_printer_add_string (GtkJsonPrinter *self, |
65 | const char *name, |
66 | const char *s); |
67 | void gtk_json_printer_add_null (GtkJsonPrinter *self, |
68 | const char *name); |
69 | |
70 | void gtk_json_printer_start_object (GtkJsonPrinter *self, |
71 | const char *name); |
72 | void gtk_json_printer_start_array (GtkJsonPrinter *self, |
73 | const char *name); |
74 | void gtk_json_printer_end (GtkJsonPrinter *self); |
75 | |
76 | |
77 | G_END_DECLS |
78 | |
79 | #endif /* __GTK_JSON_PRINTER_H__ */ |
80 | |