Skip to content

units.cpp should be refactored to avoid large switch statements #2708

@chriadam

Description

@chriadam

Could define the appropriate values in a lookup table:

static constexpr UnitMetadata UnitTable[] {
    // unit                                         label    defaultPrec scalable  veUnit
    { Enums::Units_None,                           "",        0,        false,    Unit::Default },

    { Enums::Units_Watt,                           "W",       0,        true,     Unit::Watt },
    { Enums::Units_Volt_DC,                        "V",       2,        true,     Unit::Volt },
    { Enums::Units_Volt_AC,                        "V",       0,        true,     Unit::Volt },
    ...
};

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions