diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/file.c | 10 | ||||
-rw-r--r-- | core/file.h | 4 | ||||
-rw-r--r-- | core/filterpreset.cpp | 8 | ||||
-rw-r--r-- | core/filterpreset.h | 14 | ||||
-rw-r--r-- | core/git-access.h | 2 | ||||
-rw-r--r-- | core/import-csv.c | 12 | ||||
-rw-r--r-- | core/import-csv.h | 6 | ||||
-rw-r--r-- | core/load-git.c | 4 | ||||
-rw-r--r-- | core/parse-xml.c | 2 | ||||
-rw-r--r-- | core/parse.h | 10 |
10 files changed, 39 insertions, 33 deletions
diff --git a/core/file.c b/core/file.c index e53859081..d8f9d48a9 100644 --- a/core/file.c +++ b/core/file.c @@ -77,7 +77,7 @@ out: static void zip_read(struct zip_file *file, const char *filename, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, filter_preset_table_t *filter_presets) + struct dive_site_table *sites, struct filter_preset_table *filter_presets) { int size = 1024, n, read = 0; char *mem = malloc(size); @@ -93,7 +93,7 @@ static void zip_read(struct zip_file *file, const char *filename, struct dive_ta } int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets) + struct filter_preset_table *filter_presets) { int success = 0; /* Grr. libzip needs to re-open the file, it can't take a buffer */ @@ -227,7 +227,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div */ static int open_by_filename(const char *filename, const char *fmt, struct memblock *mem, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets) + struct filter_preset_table *filter_presets) { // hack to be able to provide a comment for the translated string static char *csv_warning = QT_TRANSLATE_NOOP3("gettextFromC", @@ -258,7 +258,7 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo } static int parse_file_buffer(const char *filename, struct memblock *mem, struct dive_table *table, - struct trip_table *trips, struct dive_site_table *sites, filter_preset_table_t *filter_presets) + struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets) { int ret; char *fmt = strrchr(filename, '.'); @@ -305,7 +305,7 @@ int check_git_sha(const char *filename, struct git_repository **git_p, const cha return 1; } -int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, filter_preset_table_t *filter_presets) +int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets) { struct git_repository *git; const char *branch = NULL; diff --git a/core/file.h b/core/file.h index 1f692eb79..00b1dcbde 100644 --- a/core/file.h +++ b/core/file.h @@ -26,8 +26,8 @@ extern int datatrak_import(struct memblock *mem, struct memblock *wl_mem, struct extern void ostctools_import(const char *file, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); extern int readfile(const char *filename, struct memblock *mem); -extern int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, filter_preset_table_t *filter_presets); -extern int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, filter_preset_table_t *filter_presets); +extern int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); +extern int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); // Platform specific functions extern int subsurface_rename(const char *path, const char *newpath); diff --git a/core/filterpreset.cpp b/core/filterpreset.cpp index fa48a9fd2..e7534cbc7 100644 --- a/core/filterpreset.cpp +++ b/core/filterpreset.cpp @@ -3,7 +3,7 @@ #include "qthelper.h" #include "subsurface-string.h" -std::vector<filter_preset> filter_preset_table; +struct filter_preset_table filter_preset_table; extern "C" void clear_filter_presets(void) { @@ -74,7 +74,7 @@ extern "C" void filter_preset_set_name(struct filter_preset *preset, const char preset->name = name; } -static int filter_preset_add_to_table(const QString &name, const FilterData &d, filter_preset_table_t &table) +static int filter_preset_add_to_table(const QString &name, const FilterData &d, struct filter_preset_table &table) { // std::lower_bound does a binary search - the vector must be sorted. filter_preset newEntry { name, d }; @@ -86,7 +86,7 @@ static int filter_preset_add_to_table(const QString &name, const FilterData &d, } // Take care that the name doesn't already exist by adding numbers -static QString get_unique_preset_name(const QString &orig, const filter_preset_table_t &table) +static QString get_unique_preset_name(const QString &orig, const struct filter_preset_table &table) { QString res = orig; int count = 2; @@ -99,7 +99,7 @@ static QString get_unique_preset_name(const QString &orig, const filter_preset_t return res; } -extern "C" void add_filter_preset_to_table(const struct filter_preset *preset, filter_preset_table_t *table) +extern "C" void add_filter_preset_to_table(const struct filter_preset *preset, struct filter_preset_table *table) { QString name = get_unique_preset_name(preset->name, *table); filter_preset_add_to_table(name, preset->data, *table); diff --git a/core/filterpreset.h b/core/filterpreset.h index 86bf30221..df9b0b9ef 100644 --- a/core/filterpreset.h +++ b/core/filterpreset.h @@ -24,12 +24,18 @@ struct filter_preset { FilterData data; }; -using filter_preset_table_t = std::vector<filter_preset>; -extern filter_preset_table_t filter_preset_table; +// Subclassing standard library containers is generally +// not recommended. However, this makes interaction with +// C-code easier and since we don't add any member functions, +// this is not a problem. +struct filter_preset_table : public std::vector<filter_preset> +{ +}; + +extern struct filter_preset_table filter_preset_table; #else struct filter_preset; struct filter_preset_table; -typedef struct filter_preset_table filter_preset_table_t; #endif @@ -49,7 +55,7 @@ extern struct filter_preset *alloc_filter_preset(); extern void free_filter_preset(const struct filter_preset *preset); extern void filter_preset_set_name(struct filter_preset *preset, const char *name); extern void filter_preset_set_fulltext(struct filter_preset *preset, const char *fulltext, const char *fulltext_string_mode); -extern void add_filter_preset_to_table(const struct filter_preset *preset, filter_preset_table_t *table); +extern void add_filter_preset_to_table(const struct filter_preset *preset, struct filter_preset_table *table); extern void filter_preset_add_constraint(struct filter_preset *preset, const char *type, const char *string_mode, const char *range_mode, bool negate, const char *data); // called by the parser, therefore data passed as strings. diff --git a/core/git-access.h b/core/git-access.h index b980c5f9b..2c99f9e52 100644 --- a/core/git-access.h +++ b/core/git-access.h @@ -21,7 +21,7 @@ extern int check_git_sha(const char *filename, git_repository **git_p, const cha extern int sync_with_remote(struct git_repository *repo, const char *remote, const char *branch, enum remote_transport rt); extern int git_save_dives(struct git_repository *, const char *, const char *remote, bool select_only); extern int git_load_dives(struct git_repository *repo, const char *branch, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, filter_preset_table_t *filter_presets); + struct dive_site_table *sites, struct filter_preset_table *filter_presets); extern const char *get_sha(git_repository *repo, const char *branch); extern int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only, bool create_empty); extern const char *saved_git_id; diff --git a/core/import-csv.c b/core/import-csv.c index 846c397d7..09bcf9e93 100644 --- a/core/import-csv.c +++ b/core/import-csv.c @@ -105,7 +105,7 @@ static char *parse_dan_new_line(char *buf, const char *NL) static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, const char *tag); static int parse_dan_format(const char *filename, char **params, int pnr, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets) + struct filter_preset_table *filter_presets) { int ret = 0, i; size_t end_ptr = 0; @@ -286,7 +286,7 @@ static int parse_dan_format(const char *filename, char **params, int pnr, struct int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets) + struct filter_preset_table *filter_presets) { int ret, i; struct memblock mem; @@ -808,8 +808,8 @@ int parse_txt_file(const char *filename, const char *csv, struct dive_table *tab #define SBPARAMS 40 static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, filter_preset_table_t *filter_presets); -int parse_seabear_log(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, filter_preset_table_t *filter_presets) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); +int parse_seabear_log(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets) { char *params[SBPARAMS]; int pnr = 0; @@ -826,7 +826,7 @@ int parse_seabear_log(const char *filename, struct dive_table *table, struct tri static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets) + struct filter_preset_table *filter_presets) { int ret, i; struct memblock mem; @@ -954,7 +954,7 @@ static int parse_seabear_csv_file(const char *filename, char **params, int pnr, } int parse_manual_file(const char *filename, char **params, int pnr, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, filter_preset_table_t *filter_presets) + struct dive_site_table *sites, struct filter_preset_table *filter_presets) { struct memblock mem; time_t now; diff --git a/core/import-csv.h b/core/import-csv.h index 749849286..af8836dd7 100644 --- a/core/import-csv.h +++ b/core/import-csv.h @@ -24,14 +24,14 @@ extern "C" { #endif int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, struct dive_table *table, - struct trip_table *trips, struct dive_site_table *sites, filter_preset_table_t *filter_presets); + struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); int try_to_open_csv(struct memblock *mem, enum csv_format type, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); int parse_txt_file(const char *filename, const char *csv, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); int parse_seabear_log(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets); + struct filter_preset_table *filter_presets); int parse_manual_file(const char *filename, char **params, int pnr, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, filter_preset_table_t *filter_presets); + struct dive_site_table *sites, struct filter_preset_table *filter_presets); #ifdef __cplusplus } diff --git a/core/load-git.c b/core/load-git.c index 915db26e2..bcb311100 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -47,7 +47,7 @@ struct git_parser_state { struct dive_table *table; struct trip_table *trips; struct dive_site_table *sites; - filter_preset_table_t *filter_presets; + struct filter_preset_table *filter_presets; int o2pressure_sensor; }; @@ -1879,7 +1879,7 @@ const char *get_sha(git_repository *repo, const char *branch) * or report an error and return 1 if the load failed. */ int git_load_dives(struct git_repository *repo, const char *branch, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, filter_preset_table_t *filter_presets) + struct dive_site_table *sites, struct filter_preset_table *filter_presets) { int ret; struct git_parser_state state = { 0 }; diff --git a/core/parse-xml.c b/core/parse-xml.c index bce6d2f31..d3dda0c43 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -1721,7 +1721,7 @@ static const char *preprocess_divelog_de(const char *buffer) int parse_xml_buffer(const char *url, const char *buffer, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets, const char **params) + struct filter_preset_table *filter_presets, const char **params) { UNUSED(size); xmlDoc *doc; diff --git a/core/parse.h b/core/parse.h index 899a006f7..f3d4039e3 100644 --- a/core/parse.h +++ b/core/parse.h @@ -73,10 +73,10 @@ struct parser_state { int sample_rate; struct extra_data cur_extra_data; struct units xml_parsing_units; - struct dive_table *target_table; /* non-owning */ - struct trip_table *trips; /* non-owning */ - struct dive_site_table *sites; /* non-owning */ - filter_preset_table_t *filter_presets; /* non-owning */ + struct dive_table *target_table; /* non-owning */ + struct trip_table *trips; /* non-owning */ + struct dive_site_table *sites; /* non-owning */ + struct filter_preset_table *filter_presets; /* non-owning */ sqlite3 *sql_handle; /* for SQL based parsers */ event_allocation_t event_allocation; @@ -140,7 +140,7 @@ int atoi_n(char *ptr, unsigned int len); void parse_xml_init(void); int parse_xml_buffer(const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - filter_preset_table_t *filter_presets, const char **params); + struct filter_preset_table *filter_presets, const char **params); void parse_xml_exit(void); int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); |