dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
dimval::UnitDescriptor Struct Reference

Runtime metadata for a unit. More...

#include <descriptor.hpp>

Public Attributes

std::string_view id
 Stable identifier (e.g. "m"). Unique per registry.
 
std::string_view symbol
 Display symbol (e.g. "m"). Often equal to id.
 
std::string_view short_name
 Short human-readable name (e.g. "m").
 
std::string_view long_name
 Full human-readable name (e.g. "meter").
 
std::string_view kind
 Compatibility group (e.g. "length"). Two units convert if kinds match.
 
double factor {1.0}
 Linear conversion: canonical = factor * v + offset.
 
double offset {0.0}
 Additive offset for affine conversions (e.g. Celsius/Kelvin).
 
std::string_view formatter {"default"}
 Formatter id; consumed by std::formatter.
 
int default_precision {-1}
 Default numeric precision; -1 = unset.
 
bool no_space_before_symbol {false}
 Render flush, e.g. "100%" instead of "100 %".
 
std::optional< comms::Icon > icon {}
 NOLINT(readability-redundant-member-init) Optional UI icon (Iconify set:name); nullopt = unset.
 
std::optional< comms::Color > color {}
 NOLINT(readability-redundant-member-init) Optional UI accent (RGBA); nullopt = unset.
 

Detailed Description

Runtime metadata for a unit.

All string_views are expected to refer to storage that outlives any registration. For built-in units this is satisfied because the strings are literals; for runtime-registered descriptors (see UnitRegistry) the caller must guarantee the lifetime.


The documentation for this struct was generated from the following file: