1 /* LIBGIMP - The GIMP Library
2  * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
3  *
4  * Config file serialization and deserialization interface
5  * Copyright (C) 2001-2003  Sven Neumann <sven@gimp.org>
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 3 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  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library.  If not, see
19  * <https://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23 #error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24 #endif
25 
26 #ifndef __GIMP_CONFIG_IFACE_H__
27 #define __GIMP_CONFIG_IFACE_H__
28 
29 G_BEGIN_DECLS
30 
31 /* For information look into the C source or the html documentation */
32 
33 
34 #define GIMP_TYPE_CONFIG               (gimp_config_get_type ())
35 #define GIMP_IS_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONFIG))
36 #define GIMP_CONFIG(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONFIG, GimpConfig))
37 #define GIMP_CONFIG_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_CONFIG, GimpConfigInterface))
38 
39 
40 typedef struct _GimpConfigInterface GimpConfigInterface;
41 
42 struct _GimpConfigInterface
43 {
44   GTypeInterface base_iface;
45 
46   gboolean     (* serialize)            (GimpConfig       *config,
47                                          GimpConfigWriter *writer,
48                                          gpointer          data);
49   gboolean     (* deserialize)          (GimpConfig       *config,
50                                          GScanner         *scanner,
51                                          gint              nest_level,
52                                          gpointer          data);
53   gboolean     (* serialize_property)   (GimpConfig       *config,
54                                          guint             property_id,
55                                          const GValue     *value,
56                                          GParamSpec       *pspec,
57                                          GimpConfigWriter *writer);
58   gboolean     (* deserialize_property) (GimpConfig       *config,
59                                          guint             property_id,
60                                          GValue           *value,
61                                          GParamSpec       *pspec,
62                                          GScanner         *scanner,
63                                          GTokenType       *expected);
64   GimpConfig * (* duplicate)            (GimpConfig       *config);
65   gboolean     (* equal)                (GimpConfig       *a,
66                                          GimpConfig       *b);
67   void         (* reset)                (GimpConfig       *config);
68   gboolean     (* copy)                 (GimpConfig       *src,
69                                          GimpConfig       *dest,
70                                          GParamFlags       flags);
71 };
72 
73 
74 GType      gimp_config_get_type            (void) G_GNUC_CONST;
75 
76 GIMP_DEPRECATED_FOR (gimp_config_get_type)
77 GType      gimp_config_interface_get_type  (void) G_GNUC_CONST;
78 
79 gboolean   gimp_config_serialize_to_file   (GimpConfig       *config,
80                                             const gchar      *filename,
81                                             const gchar      *header,
82                                             const gchar      *footer,
83                                             gpointer          data,
84                                             GError          **error);
85 gboolean   gimp_config_serialize_to_gfile  (GimpConfig       *config,
86                                             GFile            *file,
87                                             const gchar      *header,
88                                             const gchar      *footer,
89                                             gpointer          data,
90                                             GError          **error);
91 gboolean   gimp_config_serialize_to_stream (GimpConfig       *config,
92                                             GOutputStream    *output,
93                                             const gchar      *header,
94                                             const gchar      *footer,
95                                             gpointer          data,
96                                             GError          **error);
97 gboolean   gimp_config_serialize_to_fd     (GimpConfig       *config,
98                                             gint              fd,
99                                             gpointer          data);
100 gchar    * gimp_config_serialize_to_string (GimpConfig       *config,
101                                             gpointer          data);
102 gboolean   gimp_config_deserialize_file    (GimpConfig       *config,
103                                             const gchar      *filename,
104                                             gpointer          data,
105                                             GError          **error);
106 gboolean   gimp_config_deserialize_gfile   (GimpConfig       *config,
107                                             GFile            *file,
108                                             gpointer          data,
109                                             GError          **error);
110 gboolean   gimp_config_deserialize_stream  (GimpConfig       *config,
111                                             GInputStream     *input,
112                                             gpointer          data,
113                                             GError          **error);
114 gboolean   gimp_config_deserialize_string  (GimpConfig       *config,
115                                             const gchar      *text,
116                                             gint              text_len,
117                                             gpointer          data,
118                                             GError          **error);
119 gboolean   gimp_config_deserialize_return  (GScanner         *scanner,
120                                             GTokenType        expected_token,
121                                             gint              nest_level);
122 
123 gboolean   gimp_config_serialize           (GimpConfig       *config,
124                                             GimpConfigWriter *writer,
125                                             gpointer          data);
126 gboolean   gimp_config_deserialize         (GimpConfig       *config,
127                                             GScanner         *scanner,
128                                             gint              nest_level,
129                                             gpointer          data);
130 gpointer   gimp_config_duplicate           (GimpConfig       *config);
131 gboolean   gimp_config_is_equal_to         (GimpConfig       *a,
132                                             GimpConfig       *b);
133 void       gimp_config_reset               (GimpConfig       *config);
134 gboolean   gimp_config_copy                (GimpConfig       *src,
135                                             GimpConfig       *dest,
136                                             GParamFlags       flags);
137 
138 
139 G_END_DECLS
140 
141 #endif  /* __GIMP_CONFIG_IFACE_H__ */
142