core: convert taxonomy.c to C++

Since the taxonomy is now a real C++ struct with constructor
and destructor, dive_site has to be converted to C++ as well.

A bit hairy for now, but will ultimately be distinctly simpler.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-04 13:39:04 +02:00 committed by bstoeger
parent 3c1401785b
commit 3f8b4604be
39 changed files with 259 additions and 336 deletions

View file

@ -133,6 +133,12 @@ static void addStringToSortedList(QStringList &l, const std::string &s)
l.insert(it, qs);
}
// Safely treat null-strings. Remove once everyhting is converted to std::string
static std::string c_to_std(const char *s)
{
return s ? std::string(s) : std::string();
}
QStringList formatFullCylinderList()
{
QStringList cylinders;
@ -140,7 +146,7 @@ QStringList formatFullCylinderList()
int i = 0;
for_each_dive (i, d) {
for (int j = 0; j < d->cylinders.nr; j++)
addStringToSortedList(cylinders, get_cylinder(d, j)->type.description);
addStringToSortedList(cylinders, c_to_std(get_cylinder(d, j)->type.description));
}
for (const auto &ti: tank_info_table)