mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: turn divecomputer list into std::vector<>
Since struct divecomputer is now fully C++ (i.e. cleans up after itself), we can simply turn the list of divecomputers into an std::vector<>. This makes the code quite a bit simpler, because the first divecomputer was actually a subobject. Yes, this makes the common case of a single divecomputer a little bit less efficient, but it really shouldn't matter. If it does, we can still write a special std::vector<>- like container that keeps the first element inline. This change makes pointers-to-divecomputers not stable. So always access the divecomputer via its index. As far as I can tell, most of the code already does this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e237f29fb2
commit
284582d2e8
54 changed files with 738 additions and 893 deletions
|
@ -152,7 +152,7 @@ void ostctools_import(const char *file, struct divelog *log)
|
|||
return;
|
||||
}
|
||||
std::string tmp = devdata.vendor + " " + devdata.model + " (Imported from OSTCTools)";
|
||||
ostcdive->dc.model = tmp.c_str();
|
||||
ostcdive->dcs[0].model = tmp;
|
||||
|
||||
// Parse the dive data
|
||||
rc = libdc_buffer_parser(ostcdive.get(), &devdata, buffer.data(), i + 1);
|
||||
|
@ -161,14 +161,14 @@ void ostctools_import(const char *file, struct divelog *log)
|
|||
|
||||
// Serial number is not part of the header nor the profile, so libdc won't
|
||||
// catch it. If Serial is part of the extra_data, and set to zero, replace it.
|
||||
ostcdive->dc.serial = std::to_string(serial);
|
||||
ostcdive->dcs[0].serial = std::to_string(serial);
|
||||
|
||||
auto it = find_if(ostcdive->dc.extra_data.begin(), ostcdive->dc.extra_data.end(),
|
||||
auto it = find_if(ostcdive->dcs[0].extra_data.begin(), ostcdive->dcs[0].extra_data.end(),
|
||||
[](auto &ed) { return ed.key == "Serial"; });
|
||||
if (it != ostcdive->dc.extra_data.end() && it->value == "0")
|
||||
it->value = ostcdive->dc.serial.c_str();
|
||||
else if (it == ostcdive->dc.extra_data.end())
|
||||
add_extra_data(&ostcdive->dc, "Serial", ostcdive->dc.serial);
|
||||
if (it != ostcdive->dcs[0].extra_data.end() && it->value == "0")
|
||||
it->value = ostcdive->dcs[0].serial.c_str();
|
||||
else if (it == ostcdive->dcs[0].extra_data.end())
|
||||
add_extra_data(&ostcdive->dcs[0], "Serial", ostcdive->dcs[0].serial);
|
||||
|
||||
record_dive_to_table(ostcdive.release(), log->dives.get());
|
||||
sort_dive_table(log->dives.get());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue