mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: convert dive computer extra data to C++
Use std::string and std::vector. Much simpler code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b9a2eff3c9
commit
bc761344d4
14 changed files with 101 additions and 161 deletions
|
@ -119,12 +119,11 @@ static void save_tags(struct membuffer *b, struct tag_entry *tags)
|
|||
put_string(b, "\n");
|
||||
}
|
||||
|
||||
static void save_extra_data(struct membuffer *b, struct extra_data *ed)
|
||||
static void save_extra_data(struct membuffer *b, const struct divecomputer *dc)
|
||||
{
|
||||
while (ed) {
|
||||
if (ed->key && ed->value)
|
||||
put_format(b, "keyvalue \"%s\" \"%s\"\n", ed->key ? : "", ed->value ? : "");
|
||||
ed = ed->next;
|
||||
for (const auto &ed: dc->extra_data) {
|
||||
if (!ed.key.empty() && !ed.value.empty())
|
||||
put_format(b, "keyvalue \"%s\" \"%s\"\n", ed.key.c_str(), ed.value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +441,7 @@ static void save_dc(struct membuffer *b, struct dive *dive, struct divecomputer
|
|||
save_salinity(b, dc);
|
||||
put_duration(b, dc->surfacetime, "surfacetime ", "min\n");
|
||||
|
||||
save_extra_data(b, dc->extra_data);
|
||||
save_extra_data(b, dc);
|
||||
save_events(b, dive, dc->events);
|
||||
save_samples(b, dive, dc);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue