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

@ -716,15 +716,12 @@ static void save_dives_buffer(struct membuffer *b, bool select_only, bool anonym
show_utf8_blanked(b, ds->description, " description='", "'", 1, anonymize);
put_format(b, ">\n");
show_utf8_blanked(b, ds->notes, " <notes>", " </notes>\n", 0, anonymize);
if (ds->taxonomy.nr) {
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'", t->category);
put_format(b, " origin='%d'", t->origin);
show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize);
put_format(b, "/>\n");
}
for (auto const &t: ds->taxonomy) {
if (t.category != TC_NONE && !t.value.empty()) {
put_format(b, " <geo cat='%d'", t.category);
put_format(b, " origin='%d'", t.origin);
show_utf8_blanked(b, t.value.c_str(), " value='", "'", 1, anonymize);
put_format(b, "/>\n");
}
}
put_format(b, "</site>\n");
@ -921,15 +918,12 @@ static void save_dive_sites_buffer(struct membuffer *b, const struct dive_site *
show_utf8_blanked(b, ds->description, " description='", "'", 1, anonymize);
put_format(b, ">\n");
show_utf8_blanked(b, ds->notes, " <notes>", " </notes>\n", 0, anonymize);
if (ds->taxonomy.nr) {
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'", t->category);
put_format(b, " origin='%d'", t->origin);
show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize);
put_format(b, "/>\n");
}
for (const auto &t: ds->taxonomy) {
if (t.category != TC_NONE && !t.value.empty()) {
put_format(b, " <geo cat='%d'", t.category);
put_format(b, " origin='%d'", t.origin);
show_utf8_blanked(b, t.value.c_str(), " value='", "'", 1, anonymize);
put_format(b, "/>\n");
}
}
put_format(b, "</site>\n");