mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Read and write divemode changes (xml and git)
This provides for reading of divemode change events from dive logs and for writing them to dive logs. This applies to xml and git divelogs. Divemode change events have the following structure: event->name = "modechange" event->value = integer corresponding to enum dive_comp_type (dive.c), reflecting the type of divemode change (OC, CCR, PSCR, etc). In the dive log file, the event value is written as a string that corresponds to each of the enum values, e.g. <event name='modechange' divemode='OC' /> This xml is also read from the dive log file and translated to an appropriate value of event->value. The file diveeventitem.cpp was udated to reflect this new way of dealing with divemode change events. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
This commit is contained in:
parent
5f95c226ef
commit
b9174332d5
6 changed files with 48 additions and 7 deletions
|
@ -723,6 +723,15 @@ static void parse_dc_time(char *line, struct membuffer *str, void *_dc)
|
|||
static void parse_dc_watertemp(char *line, struct membuffer *str, void *_dc)
|
||||
{ (void) str; struct divecomputer *dc = _dc; dc->watertemp = get_temperature(line); }
|
||||
|
||||
|
||||
int get_divemode(const char *divemodestring) {
|
||||
for (int i = 0; i < NUM_DC_TYPE; i++) {
|
||||
if (!strcmp(divemodestring, divemode_text[i]))
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void parse_event_keyvalue(void *_event, const char *key, const char *value)
|
||||
{
|
||||
struct event *event = _event;
|
||||
|
@ -736,6 +745,8 @@ static void parse_event_keyvalue(void *_event, const char *key, const char *valu
|
|||
event->value = val;
|
||||
} else if (!strcmp(key, "name")) {
|
||||
/* We get the name from the string handling */
|
||||
} else if (!strcmp(key,"divemode")) {
|
||||
event->value = get_divemode(value);
|
||||
} else if (!strcmp(key, "cylinder")) {
|
||||
/* NOTE! We add one here as a marker that "yes, we got a cylinder index" */
|
||||
event->gas.index = 1+get_index(value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue