core: port tag-list to C++

Also adds a new test, which tests merging of two tag-lists.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-29 17:57:48 +02:00 committed by bstoeger
parent 640ecb345b
commit f18acf6fb9
25 changed files with 195 additions and 227 deletions

View file

@ -311,18 +311,16 @@ void put_HTML_watertemp(struct membuffer *b, const struct dive *dive, const char
static void put_HTML_tags(struct membuffer *b, const struct dive *dive, const char *pre, const char *post)
{
put_string(b, pre);
struct tag_entry *tag = dive->tag_list;
if (!tag)
if (dive->tags.empty())
put_string(b, "[\"--\"");
const char *separator = "[";
while (tag) {
for (const divetag *tag: dive->tags) {
put_format(b, "%s\"", separator);
separator = ", ";
put_HTML_quoted(b, tag->tag->name.c_str());
put_HTML_quoted(b, tag->name.c_str());
put_string(b, "\"");
tag = tag->next;
}
put_string(b, "]");
put_string(b, post);