Config

Configuration of size format.

Members

Variables

prefixUse
PrefixUse prefixUse;

The type of prefix used along with the symbol.

spacing
string spacing;

The spacing between the value and the unit.

symbol
string symbol;

The symbol of the size unit.

unitName
string unitName;

The name of the size unit (singular).

unitNamePlural
string unitNamePlural;

The name of the size unit (plural).

useNameIfNoPrefix
bool useNameIfNoPrefix;

Whether to use the name of the symbol if there is no prefix.

Examples

    enum Config config = {
        symbol: "O",
        unitName: "octet",
        unitNamePlural: "octets",
        prefixUse: PrefixUse.IEC,
        useNameIfNoPrefix: true
    };

	alias MySize = SizeBase!config;
    
    assert("%4.1f".format(MySize(0))         == "   0 octet");
    assert("%4.1f".format(MySize(1))         == "   1 octet");
    assert("%4.1f".format(MySize(42))        == "  42 octets");
    assert("%4.1f".format(MySize(1024))      == " 1.0 KiO");
    assert("%4.1f".format(MySize(2_590_000)) == " 2.5 MiO");

Meta