BEAST - Free Software Audio Synthesizer and Tracker  0.10.0
sfistore.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __SFI_STORE_H__
3 #define __SFI_STORE_H__
4 
5 #include <sfi/sfivalues.hh>
6 #include <sfi/sfiring.hh>
7 
8 G_BEGIN_DECLS
9 
10 /* --- typedefs and structures --- */
11 typedef gint /* -errno || length */ (*SfiStoreReadBin) (gpointer data,
12  void *buffer,
13  guint blength);
14 typedef struct
15 {
16  GString *text;
17  guint indent;
18  SfiRing *bblocks;
19  guint needs_break : 1;
20  guint flushed : 1;
21  gchar comment_start;
22 } SfiWStore;
23 #define SFI_TOKEN_UNMATCHED ((GTokenType) (G_TOKEN_LAST + 1))
24 #define SFI_TOKEN_LAST ((GTokenType) (SFI_TOKEN_UNMATCHED + 1))
25 typedef struct _SfiRStore SfiRStore;
26 typedef GTokenType (*SfiStoreParser) (gpointer context_data,
27  SfiRStore *rstore, /* parser_this */
28  GScanner *scanner,
29  gpointer user_data);
30 struct _SfiRStore
31 {
32  GScanner *scanner;
33  gchar *fname;
34  gint close_fd;
35  gpointer parser_this;
36  SfiNum bin_offset;
37 };
38 
39 
40 /* --- writable store --- */
41 SfiWStore* sfi_wstore_new (void);
42 void sfi_wstore_destroy (SfiWStore *wstore);
43 void sfi_wstore_push_level (SfiWStore *wstore);
44 void sfi_wstore_pop_level (SfiWStore *wstore);
45 void sfi_wstore_break (SfiWStore *wstore);
46 void sfi_wstore_puts (SfiWStore *wstore,
47  const gchar *string);
48 void sfi_wstore_putc (SfiWStore *wstore,
49  gchar character);
50 #define sfi_wstore_printf(wstore, ...) sfi_wstore_puts (wstore, Rapicorn::string_format (__VA_ARGS__).c_str())
51 void sfi_wstore_putf (SfiWStore *wstore,
52  gfloat vfloat);
53 void sfi_wstore_putd (SfiWStore *wstore,
54  gdouble vdouble);
55 void sfi_wstore_put_value (SfiWStore *wstore,
56  const GValue *value);
57 void sfi_wstore_put_param (SfiWStore *wstore,
58  const GValue *value,
59  GParamSpec *pspec);
60 void sfi_wstore_put_binary (SfiWStore *wstore,
61  SfiStoreReadBin reader,
62  gpointer data,
63  GDestroyNotify destroy);
64 gint /*-errno*/ sfi_wstore_flush_fd (SfiWStore *wstore,
65  gint fd);
66 const gchar* sfi_wstore_peek_text (SfiWStore *wstore,
67  guint *length);
68 
69 
70 /* --- readable store --- */
71 SfiRStore* sfi_rstore_new (void);
72 SfiRStore* sfi_rstore_new_open (const gchar *fname);
73 void sfi_rstore_destroy (SfiRStore *rstore);
74 void sfi_rstore_input_fd (SfiRStore *rstore,
75  gint fd,
76  const gchar *fname);
77 void sfi_rstore_input_text (SfiRStore *rstore,
78  const gchar *text,
79  const gchar *text_name);
80 gboolean sfi_rstore_eof (SfiRStore *rstore);
81 GTokenType sfi_rstore_parse_param (SfiRStore *rstore,
82  GValue *value,
83  GParamSpec *pspec);
84 GTokenType sfi_rstore_ensure_bin_offset (SfiRStore *rstore);
85 guint64 sfi_rstore_get_bin_offset (SfiRStore *rstore);
86 GTokenType sfi_rstore_parse_binary (SfiRStore *rstore,
87  SfiNum *offset_p,
88  SfiNum *length_p);
89 GTokenType sfi_rstore_parse_zbinary (SfiRStore *rstore,
90  SfiNum *offset_p,
91  SfiNum *length_p);
92 GTokenType sfi_rstore_parse_until (SfiRStore *rstore,
93  GTokenType closing_token,
94  gpointer context_data,
95  SfiStoreParser try_statement,
96  gpointer user_data);
97 guint sfi_rstore_parse_all (SfiRStore *rstore,
98  gpointer context_data,
99  SfiStoreParser try_statement,
100  gpointer user_data);
101 void sfi_rstore_error (SfiRStore *rstore, const std::string &msg);
102 void sfi_rstore_unexp_token (SfiRStore *rstore,
103  GTokenType expected_token);
104 void sfi_rstore_warn (SfiRStore *rstore, const std::string &msg);
105 GTokenType sfi_rstore_warn_skip (SfiRStore *rstore, const std::string &msg);
106 typedef gboolean (SfiRStoreQuickScan) (SfiRStore *rstore,
107  gpointer data);
108 void sfi_rstore_quick_scan (SfiRStore *rstore,
109  const gchar *identifier,
110  SfiRStoreQuickScan qcheck,
111  gpointer data);
112 
113 
114 /* --- convenience --- */
115 #define sfi_scanner_parse_or_return(scanner, token) G_STMT_START { \
116  GTokenType _t = GTokenType (token); \
117  if (g_scanner_get_next_token (scanner) != _t) \
118  return _t; \
119 } G_STMT_END
120 #define sfi_scanner_peek_or_return(scanner, token) G_STMT_START { \
121  GTokenType _t = GTokenType (token); \
122  GScanner *__s = (scanner); \
123  if (g_scanner_peek_next_token (__s) != _t) \
124  { \
125  g_scanner_get_next_token (__s); /* advance to error pos */ \
126  return _t; \
127  } \
128 } G_STMT_END
129 
130 G_END_DECLS
131 
132 #endif /* __SFI_STORE_H__ */
STL class.
Definition: sfistore.hh:30
Definition: sfiring.hh:23
Definition: sfistore.hh:14