1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

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

@ -328,7 +328,7 @@ static void temperature(const char *buffer, temperature_t *temperature, struct p
/* temperatures outside -40C .. +70C should be ignored */
if (temperature->mkelvin < ZERO_C_IN_MKELVIN - 40000 ||
temperature->mkelvin > ZERO_C_IN_MKELVIN + 70000)
temperature->mkelvin = 0;
*temperature = 0_K;
}
static void sampletime(const char *buffer, duration_t *time)
@ -351,7 +351,7 @@ static void sampletime(const char *buffer, duration_t *time)
time->seconds = (hr * 60 + min) * 60 + sec;
break;
default:
time->seconds = 0;
*time = 0_sec;
report_info("Strange sample time reading %s", buffer);
}
}
@ -715,7 +715,7 @@ static void parse_libdc_deco(const char *buffer, struct sample *s)
s->in_deco = false;
// The time wasn't stoptime, it was ndl
s->ndl = s->stoptime;
s->stoptime.seconds = 0;
s->stoptime = 0_sec;
}
}