core: convert cylinder_t and cylinder_table to C++

This had to be done simultaneously, because the table macros
do not work properly with C++ objects.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-28 21:31:11 +02:00 committed by bstoeger
parent 284582d2e8
commit 28520da655
48 changed files with 593 additions and 710 deletions

View file

@ -177,28 +177,22 @@ static void put_gasmix(struct membuffer *b, struct gasmix mix)
static void save_cylinder_info(struct membuffer *b, struct dive *dive)
{
int i, nr;
nr = nr_cylinders(dive);
for (i = 0; i < nr; i++) {
cylinder_t *cylinder = get_cylinder(dive, i);
int volume = cylinder->type.size.mliter;
const char *description = cylinder->type.description;
int use = cylinder->cylinder_use;
for (auto &cyl: dive->cylinders) {
int volume = cyl.type.size.mliter;
int use = cyl.cylinder_use;
put_format(b, " <cylinder");
if (volume)
put_milli(b, " size='", volume, " l'");
put_pressure(b, cylinder->type.workingpressure, " workpressure='", " bar'");
show_utf8(b, description, " description='", "'", 1);
put_gasmix(b, cylinder->gasmix);
put_pressure(b, cylinder->start, " start='", " bar'");
put_pressure(b, cylinder->end, " end='", " bar'");
put_pressure(b, cyl.type.workingpressure, " workpressure='", " bar'");
show_utf8(b, cyl.type.description.c_str(), " description='", "'", 1);
put_gasmix(b, cyl.gasmix);
put_pressure(b, cyl.start, " start='", " bar'");
put_pressure(b, cyl.end, " end='", " bar'");
if (use > OC_GAS && use < NUM_GAS_USE)
show_utf8(b, cylinderuse_text[use], " use='", "'", 1);
if (cylinder->depth.mm != 0)
put_milli(b, " depth='", cylinder->depth.mm, " m'");
if (cyl.depth.mm != 0)
put_milli(b, " depth='", cyl.depth.mm, " m'");
put_format(b, " />\n");
}
}