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:
Willem Ferguson 2018-04-07 14:56:37 +02:00 committed by Lubomir I. Ivanov
parent 5f95c226ef
commit b9174332d5
6 changed files with 48 additions and 7 deletions

View file

@ -301,7 +301,10 @@ static void save_one_event(struct membuffer *b, struct dive *dive, struct event
put_format(b, " <event time='%d:%02d min'", FRACTION(ev->time.seconds, 60));
show_index(b, ev->type, "type='", "'");
show_index(b, ev->flags, "flags='", "'");
show_index(b, ev->value, "value='", "'");
if (!strcmp(ev->name,"modechange"))
show_utf8(b, divemode_text[ev->value], "divemode='", "'",1);
else
show_index(b, ev->value, "value='", "'");
show_utf8(b, ev->name, " name='", "'", 1);
if (event_is_gaschange(ev)) {
struct gasmix *mix = get_gasmix_from_event(dive, ev);