summaryrefslogtreecommitdiff
path: root/sfile.h
blob: 4ac63b7258acb32de2245e118bf39b7bd72290b5 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
typedef struct SFormat SFormat;
typedef struct SFileInput SFileInput;
typedef struct SFileOutput SFileOutput;

/* - Describing Types - */
SFormat *sformat_new (gpointer f);
gpointer sformat_new_record (const char  *name,
			     gpointer     content,
			     ...);
gpointer sformat_new_list (const char  *name,
			   gpointer	content);
gpointer sformat_new_pointer (const char  *name);
gpointer sformat_new_integer (const char  *name);
gpointer sformat_new_string (const char  *name);

/* - Reading - */
SFileInput *  sfile_load        (const char  *filename,
				 SFormat       *format,
				 GError     **err);
void     sfile_begin_get_record (SFileInput  *file, const char *name);
int      sfile_begin_get_list   (SFileInput  *file, const char *name);
void     sfile_get_pointer      (SFileInput  *file,
				 const char *name,
				 gpointer    *pointer);
void     sfile_get_integer      (SFileInput  *file,
				 const char *name,
				 int         *integer);
void     sfile_get_string       (SFileInput  *file,
				 const char *name,
				 char       **string);
void     sfile_end_get          (SFileInput  *file,
				 const char *name,
				 gpointer     object);

#if 0
/* incremental loading (worth considering at least) */
SFileLoader *sfile_loader_new      (SFormat        *format);
void         sfile_loader_add_text (SFileLoader  *loader,
				    const char   *text,
				    int           len);
SFile *      sfile_loader_finish   (SFileLoader  *loader,
				    GError      **err);
void         sfile_loader_free     (SFileLoader  *loader);
#endif

/* - Writing - */

/* FIXME: see if we can't get rid of the names. It should be
= * possible to pass NULL to state_transition_check() and
 * have it interprete that as "whatever"
 */

SFileOutput *  sfile_output_mew (SFormat       *format);
void     sfile_begin_add_record (SFileOutput       *file,
				 const char *name);
void     sfile_begin_add_list   (SFileOutput       *file,
				 const char *name);
void     sfile_end_add          (SFileOutput       *file,
				 const char *name,
				 gpointer object);
void     sfile_add_string       (SFileOutput       *file,
				 const char *name,
				 const char  *string);
void     sfile_add_integer      (SFileOutput       *file,
				 const char *name,
				 int          integer);
void     sfile_add_pointer      (SFileOutput       *file,
				 const char *name,
				 gpointer     pointer);
gboolean sfile_save             (SFileOutput       *sfile,
				 const char  *filename,
				 GError     **err);