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_UTILS_H__ 00003 #define __SFI_UTILS_H__ 00004 00005 #include <math.h> 00006 #include <bse/gsldefs.hh> 00007 #include <sfi/sfi.hh> 00008 00009 G_BEGIN_DECLS 00010 00011 typedef struct 00012 { 00013 guint line_number; 00014 guint n_fields; 00015 gchar **fields; 00016 } SfiUtilFileEntry; 00017 00018 typedef struct 00019 { 00020 guint n_entries; 00021 SfiUtilFileEntry *entries; 00022 guint n_formats; 00023 gchar **formats; 00024 gpointer free1, free2; 00025 } SfiUtilFileList; 00026 00027 /* value extraction from formats: 00028 * # <something> -> value is <something> 00029 * <num> -> value is <num> word of line 00030 * <num> n <nth> -> <nth> number found in word <num> 00031 * <num> b <nth> -> <nth> number found in basename(word <num>) 00032 */ 00033 SfiUtilFileList* sfi_util_file_list_read (gint fd); 00034 SfiUtilFileList* sfi_util_file_list_read_simple (const gchar *file_name, 00035 guint n_formats, 00036 const gchar *formats); 00037 void sfi_util_file_list_free (SfiUtilFileList *text); 00038 const gchar* sfi_util_file_entry_get_field (SfiUtilFileEntry *entry, 00039 const gchar **format_p); 00040 gchar* sfi_util_file_entry_get_string (SfiUtilFileEntry *entry, 00041 const gchar *format, 00042 const gchar *dflt); 00043 gdouble sfi_util_file_entry_get_num (SfiUtilFileEntry *line, 00044 const gchar *format, 00045 gdouble dflt); 00046 00047 00048 gchar* sfi_util_file_name_subst_ext (const gchar *file_name, 00049 const gchar *new_extension); 00050 00051 typedef struct { 00052 gchar short_opt; 00053 gchar *long_opt; 00054 const gchar **value_p; 00055 guint takes_arg : 1; 00056 } SfiArgument; 00057 void sfi_arguments_parse (gint *argc_p, 00058 gchar ***argv_p, 00059 guint n_options, 00060 const SfiArgument *options); 00061 SfiRing* sfi_arguments_parse_list (gint *argc_p, 00062 gchar ***argv_p, 00063 guint n_options, 00064 const SfiArgument *options); 00065 void sfi_arguments_collapse (gint *argc_p, 00066 gchar ***argv_p); 00067 00068 /* format for value extraction: 00069 * # <something> -> string is <something> 00070 * n <nth> -> <nth> number found in string 00071 * b <nth> -> <nth> number found in basename(string) 00072 * c [*<num>] -> counter (with optional multiplication) 00073 * if <nth>==0, number may not be preceeded by non-digit chars 00074 */ 00075 gdouble sfi_arguments_extract_num (const gchar *string, 00076 const gchar *format, 00077 gdouble *counter, 00078 gdouble dflt); 00079 gboolean sfi_arguments_read_num (const gchar **option, 00080 gdouble *num); 00081 guint sfi_arguments_read_all_nums (const gchar *option, 00082 gdouble *first, 00083 ...) G_GNUC_NULL_TERMINATED; 00084 00085 G_END_DECLS 00086 00087 #endif /* __SFI_UTILS_H__ */