BEAST/BSE - Better Audio System and Sound Engine
0.8.2
|
00001 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __SFI_STORE_H__ 00003 #define __SFI_STORE_H__ 00004 00005 #include <sfi/sfivalues.hh> 00006 #include <sfi/sfiring.hh> 00007 00008 G_BEGIN_DECLS 00009 00010 /* --- typedefs and structures --- */ 00011 typedef gint /* -errno || length */ (*SfiStoreReadBin) (gpointer data, 00012 void *buffer, 00013 guint blength); 00014 typedef struct 00015 { 00016 GString *text; 00017 guint indent; 00018 SfiRing *bblocks; 00019 guint needs_break : 1; 00020 guint flushed : 1; 00021 gchar comment_start; 00022 } SfiWStore; 00023 #define SFI_TOKEN_UNMATCHED ((GTokenType) (G_TOKEN_LAST + 1)) 00024 #define SFI_TOKEN_LAST ((GTokenType) (SFI_TOKEN_UNMATCHED + 1)) 00025 typedef struct _SfiRStore SfiRStore; 00026 typedef GTokenType (*SfiStoreParser) (gpointer context_data, 00027 SfiRStore *rstore, /* parser_this */ 00028 GScanner *scanner, 00029 gpointer user_data); 00030 struct _SfiRStore 00031 { 00032 GScanner *scanner; 00033 gchar *fname; 00034 gint close_fd; 00035 gpointer parser_this; 00036 SfiNum bin_offset; 00037 }; 00038 00039 00040 /* --- writable store --- */ 00041 SfiWStore* sfi_wstore_new (void); 00042 void sfi_wstore_destroy (SfiWStore *wstore); 00043 void sfi_wstore_push_level (SfiWStore *wstore); 00044 void sfi_wstore_pop_level (SfiWStore *wstore); 00045 void sfi_wstore_break (SfiWStore *wstore); 00046 void sfi_wstore_puts (SfiWStore *wstore, 00047 const gchar *string); 00048 void sfi_wstore_putc (SfiWStore *wstore, 00049 gchar character); 00050 #define sfi_wstore_printf(wstore, ...) sfi_wstore_puts (wstore, Rapicorn::string_format (__VA_ARGS__).c_str()) 00051 void sfi_wstore_putf (SfiWStore *wstore, 00052 gfloat vfloat); 00053 void sfi_wstore_putd (SfiWStore *wstore, 00054 gdouble vdouble); 00055 void sfi_wstore_put_value (SfiWStore *wstore, 00056 const GValue *value); 00057 void sfi_wstore_put_param (SfiWStore *wstore, 00058 const GValue *value, 00059 GParamSpec *pspec); 00060 void sfi_wstore_put_binary (SfiWStore *wstore, 00061 SfiStoreReadBin reader, 00062 gpointer data, 00063 GDestroyNotify destroy); 00064 gint /*-errno*/ sfi_wstore_flush_fd (SfiWStore *wstore, 00065 gint fd); 00066 const gchar* sfi_wstore_peek_text (SfiWStore *wstore, 00067 guint *length); 00068 00069 00070 /* --- readable store --- */ 00071 SfiRStore* sfi_rstore_new (void); 00072 SfiRStore* sfi_rstore_new_open (const gchar *fname); 00073 void sfi_rstore_destroy (SfiRStore *rstore); 00074 void sfi_rstore_input_fd (SfiRStore *rstore, 00075 gint fd, 00076 const gchar *fname); 00077 void sfi_rstore_input_text (SfiRStore *rstore, 00078 const gchar *text, 00079 const gchar *text_name); 00080 gboolean sfi_rstore_eof (SfiRStore *rstore); 00081 GTokenType sfi_rstore_parse_param (SfiRStore *rstore, 00082 GValue *value, 00083 GParamSpec *pspec); 00084 GTokenType sfi_rstore_ensure_bin_offset (SfiRStore *rstore); 00085 guint64 sfi_rstore_get_bin_offset (SfiRStore *rstore); 00086 GTokenType sfi_rstore_parse_binary (SfiRStore *rstore, 00087 SfiNum *offset_p, 00088 SfiNum *length_p); 00089 GTokenType sfi_rstore_parse_zbinary (SfiRStore *rstore, 00090 SfiNum *offset_p, 00091 SfiNum *length_p); 00092 GTokenType sfi_rstore_parse_until (SfiRStore *rstore, 00093 GTokenType closing_token, 00094 gpointer context_data, 00095 SfiStoreParser try_statement, 00096 gpointer user_data); 00097 guint sfi_rstore_parse_all (SfiRStore *rstore, 00098 gpointer context_data, 00099 SfiStoreParser try_statement, 00100 gpointer user_data); 00101 void sfi_rstore_error (SfiRStore *rstore, const std::string &msg); 00102 void sfi_rstore_unexp_token (SfiRStore *rstore, 00103 GTokenType expected_token); 00104 void sfi_rstore_warn (SfiRStore *rstore, const std::string &msg); 00105 GTokenType sfi_rstore_warn_skip (SfiRStore *rstore, const std::string &msg); 00106 typedef gboolean (SfiRStoreQuickScan) (SfiRStore *rstore, 00107 gpointer data); 00108 void sfi_rstore_quick_scan (SfiRStore *rstore, 00109 const gchar *identifier, 00110 SfiRStoreQuickScan qcheck, 00111 gpointer data); 00112 00113 00114 /* --- convenience --- */ 00115 #define sfi_scanner_parse_or_return(scanner, token) G_STMT_START { \ 00116 GTokenType _t = GTokenType (token); \ 00117 if (g_scanner_get_next_token (scanner) != _t) \ 00118 return _t; \ 00119 } G_STMT_END 00120 #define sfi_scanner_peek_or_return(scanner, token) G_STMT_START { \ 00121 GTokenType _t = GTokenType (token); \ 00122 GScanner *__s = (scanner); \ 00123 if (g_scanner_peek_next_token (__s) != _t) \ 00124 { \ 00125 g_scanner_get_next_token (__s); /* advance to error pos */ \ 00126 return _t; \ 00127 } \ 00128 } G_STMT_END 00129 00130 G_END_DECLS 00131 00132 #endif /* __SFI_STORE_H__ */