Parser

A quantity parser

Members

Functions

parse
Q parse(string str)

Parses a quantity of a known type Q from a string.

parseVariant
QVariant!N parseVariant(string str)

Parses a QVariant from a string.

Variables

numberParser
NumberParser!N numberParser;

A function that can parse a string for a numeric value of type N.

symbolList
SymbolList!N symbolList;

A list of registered symbols for units and prefixes.

Examples

// From http://en.wikipedia.org/wiki/List_of_humorous_units_of_measurement

auto century = unit!(real, "century");
alias LectureLength = typeof(century);

auto symbolList = SymbolList!real()
    .addUnit("Cy", century)
    .addPrefix("µ", 1e-6L);

import std.conv;
auto parser = Parser!real(symbolList, &std.conv.parse!(real, string));

auto timing = 1e-6L * century;
assert(timing == parser.parse!LectureLength("1 µCy"));
assert(timing == parser.parseVariant("1 µCy"));

Meta