aboutsummaryrefslogtreecommitdiffstats
path: root/core/file.h
AgeCommit message (Collapse)Author
2020-10-24devices: create device nodes in parsersGravatar Berthold Stoeger
So far, we added a non-global device table to the parser states. Now, create device nodes in that table instead of in the global table. Thus, on undo of dive-import, the new device nodes will be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24parser: add device_table to parser stateGravatar Berthold Stoeger
If we want to avoid the parsers to directly modify global data, we have to provide a device_table to parse into. This adds such a state and the corresponding function parameters. However, for now this is unused. Adding new parameters is very painful and this commit shows that we urgently need a "struct divelog" collecting all those tables! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17filter: remove filter_preset_table_tGravatar Berthold Stoeger
We used a typedef "filter_preset_table_t" for the filter preset table, because it is a "std::vector<filter_preset>". However, that is in contrast to all the other global tables (dives, trips, sites) that we have. Therefore, turn this into a standard struct, which simply inherits from "std::vector<filter_preset>". Note that while inheriting from std::vector<> is generally not recommended, it is not a problem here, because we don't modify it in any shape or form. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29filter: load filter presets from XML filesGravatar Berthold Stoeger
This is a bit painful: since we don't want to modify the filter presets when the user imports (as opposed to opens) a log, we have to provide a table where the parser stores the presets. Calling the parser is getting quite unwieldy, since many tables are passed. We probably should introduce a structure representing a full log-book at one point, which collects all the things that are saved to the log. Apart from that, this is simply the counterpart to saving to XML. The interpretation of the string data is performed by core functions, not the parser itself to avoid code duplication with the git parser. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-03DataTrak import: Add support for WLog extensions.Gravatar Salvador Cuñat
WLog is a Win32 based ancient shareware program whose target was: 1) fully support divelogs coming from DataTrak (DOS or Win) 2) fill some meaningful data which wasn't supported by Uwatec software 3) have a more user-friendly GUI than Datatrak had The problem achieving goals 1) and 2) at the same time was solved by adding a complementary file with .add extension and - mandatory - same base name than .log file (including directory tree). This .add file has a fixed structure composed of a 12 bytes header, including file type check and Nº of dives following; then a fixed 850 bytes size for each dive in the log file. Data fields size and position are fixed inside these blocks and heavily zero padded, so they are easy to parse. A serious restriction imposed to the WLog user was *Do not edit the logs with other software than Wlog*; this was due the order of dives in .log file being the same than the order of dives in .add file. Thought you could show a WLog divelog in Datatrak, editing it resulted in mixing all extended data for dives following the edited one. Thus, we have to trust files are correct and is to the user ensure this is so. If extended data are mangled, they are mangled in WLog too and we are not trying to fix the mess, just importing. On the technical side, we try to be smart about tank names as neither DataTrak nor WLog record them. So we just take the first tank in users list matching the volume recorded in WLog. For weights we add a translatable "unknown" string as an empty string results in weight not being shown in subsurface-mobile (which could be a reportable issue, BTW). Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-05-01cleanup: move dive_table from dive.h to divelist.hGravatar Berthold Stoeger
This allows us to decouple dive.h and divelist.h, a small step in include disentangling. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: move file-related function declarations to file.hGravatar Berthold Stoeger
A number of architecture-dependent functions were declared in dive.h. Move them to file.h so that not all file-manipulating translation units have to include dive.h. This is a small step in avoiding mass-recompilation on every change to dive.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: move error reporting function declarations to errorhelper.hGravatar Berthold Stoeger
Move the declarations of the "report_error()" and "set_error_cb()" functions and the "verbose" variable to errorhelper.h. Thus, error-reporting translation units don't have to import the big dive.h header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: move parse-function declarations out of "dive.h"Gravatar Berthold Stoeger
Move the declaration of these functions to "file.h" and "parse.h" according to the translation unit they are defined in. Thus, not all users of "dive.h" have to suck in "sqlite3.h". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Parser: parse into custom dive site tableGravatar Berthold Stoeger
To extend the undo system to dive sites, the importers and downloaders must not parse directly into the global dive site table. Instead, pass a dive_site_table argument to parse into. For now, always pass the global dive_site_table so that this commit should not cause any functional change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28Cleanup: put all function declarations in file.h in extern "C"Gravatar Berthold Stoeger
Some of the functions declarations were not in 'extern "C"', despite being C functions. This worked only because they weren't called from C++. Nevertheless, it seems like a dangerous proposition to have the same function declared once as C and once as C++. Therefore, always put them in extern "C" (if compiling in C++ mode, evidently). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Parser: add trip_table parameter to parsing functionsGravatar Berthold Stoeger
To allow parsing into arbitrary trip_tables, add the corresponding parameter to the parsing functions and the parser state. Currently, all callers pass the global trip_table so there should be no change in functionality. These arguments will be replaced in subsequent commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-28Parser: parse text-based files into arbitrary tableGravatar Berthold Stoeger
In d815e0c9476ef62e6b84fb28ce48ab7cddefe77e a dive_table pointer was added to the parsing functions to allow parsing into tables other than the global dive table. This will be necessary for undo of import and implementation a cleaner interface. A few cases, notably CSV and proprietary formats were forgotten. Implement parsing into arbitrary tables also for these cases. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23Parse: pass dive_table argument to parse_file()Gravatar Berthold Stoeger
To enable undo of divelog-importing it is crucial that parse_file() can parse into arbitrary dive tables. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08Make a few functions of static linkageGravatar Berthold Stoeger
Make functions in core/file.c, core/parse.c and core/import-csv.c that were not used outside their translation unit of static linkage. parse_date is moved from core/file.c to core/import-csv.c, since it is used only there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-05-07Datatrak import rework: changes of file.c and file.hGravatar Salvador Cuñat
Datatrak import is called from parse_file() in file.c. This function reads the full file to be imported into a memblock structure. It's easier and more secure, to parse this buffer instead of the file itself. These are the necessary changes in function datatrak_import() declaration and call. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-04-29Add SPDX header to core C filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>