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

@ -933,11 +933,10 @@ static void save_divesites(git_repository *repo, struct dir *tree)
show_utf8(&b, "description ", ds->description, "\n");
show_utf8(&b, "notes ", ds->notes, "\n");
put_location(&b, &ds->location, "gps ", "\n");
for (int j = 0; j < ds->taxonomy.nr; j++) {
struct taxonomy *t = &ds->taxonomy.category[j];
if (t->category != TC_NONE && t->value) {
put_format(&b, "geo cat %d origin %d ", t->category, t->origin);
show_utf8(&b, "", t->value, "\n" );
for (const auto &t: ds->taxonomy) {
if (t.category != TC_NONE && !t.value.empty()) {
put_format(&b, "geo cat %d origin %d ", t.category, t.origin);
show_utf8(&b, "", t.value.c_str(), "\n" );
}
}
blob_insert(repo, subdir, &b, mb_cstring(&site_file_name));