mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: convert parser_state to C++
Add constructor, destructor and use std::string for memory management of text data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5e466d91f0
commit
8d96b7557d
8 changed files with 179 additions and 227 deletions
|
@ -131,7 +131,7 @@ static int cobalt_dive(void *param, int, char **data, char **)
|
|||
settings_start(state);
|
||||
dc_settings_start(state);
|
||||
if (data[9]) {
|
||||
utf8_string(data[9], &state->cur_settings.dc.serial_nr);
|
||||
utf8_string_std(data[9], &state->cur_settings.dc.serial_nr);
|
||||
state->cur_settings.dc.deviceid = atoi(data[9]);
|
||||
state->cur_settings.dc.model = strdup("Cobalt import");
|
||||
}
|
||||
|
@ -211,14 +211,12 @@ extern "C" int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char
|
|||
int retval;
|
||||
struct parser_state state;
|
||||
|
||||
init_parser_state(&state);
|
||||
state.log = log;
|
||||
state.sql_handle = handle;
|
||||
|
||||
char get_dives[] = "select Id,strftime('%s',DiveStartTime),LocationId,'buddy','notes',Units,(MaxDepthPressure*10000/SurfacePressure)-10000,DiveMinutes,SurfacePressure,SerialNumber,'model' from Dive where IsViewDeleted = 0";
|
||||
|
||||
retval = sqlite3_exec(handle, get_dives, &cobalt_dive, &state, NULL);
|
||||
free_parser_state(&state);
|
||||
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "Database query failed '%s'.\n", url);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue