core: introduce a few user-defined literals for unit types

Thise makes initialization of unit types more palatable.

For example:

    surface.time = sample.time - duration_t { .seconds = 20 };
=>  surface.time = sample.time - 20_sec;

    delta_depth.mm = feet_to_mm(1.0); // 1ft
=>  delta_depth = 1_ft;

    get_cylinderid_at_time(..., { .seconds = 20 * 60 + 1 }));
=>  get_cylinderid_at_time(..., 20_min + 1_sec));

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-09-03 17:04:48 +02:00 committed by bstoeger
parent f09601bc93
commit ae81b42fe2
36 changed files with 320 additions and 264 deletions

View file

@ -519,10 +519,10 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log)
{
cylinder_t cyl;
cyl.cylinder_use = OXYGEN;
cyl.type.size.mliter = 3000;
cyl.type.workingpressure.mbar = 200000;
cyl.type.size = 3_l;
cyl.type.workingpressure = 200_bar;
cyl.type.description = "3l Mk6";
cyl.gasmix.o2.permille = 1000;
cyl.gasmix.o2 = 100_percent;
cyl.manually_added = true;
cyl.bestmix_o2 = 0;
cyl.bestmix_he = 0;
@ -532,8 +532,8 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log)
{
cylinder_t cyl;
cyl.cylinder_use = DILUENT;
cyl.type.size.mliter = 3000;
cyl.type.workingpressure.mbar = 200000;
cyl.type.size = 3_l;
cyl.type.workingpressure = 200_bar;
cyl.type.description = "3l Mk6";
value = parse_mkvi_value(memtxt.data(), "Helium percentage");
he = atoi(value.c_str());