Struct Parser
A quantity parser.
struct Parser(N, alias numberParser)
if (isNumeric!N);
Methods
Name | Description |
parse
|
Parses a QVariant from str.
|
Parameters
Name | Description |
N | The numeric type of the quantities. |
numberParser | a function that takes a reference to any kind of string and
returns the parsed number. |
Example
// From http://en.wikipedia.org/wiki/List_of_humorous_units_of_measurement
import std.conv : parse;
auto century = unit!real("T");
alias LectureLength = typeof(century);
auto symbolList = SymbolList!real().addUnit("Cy", century).addPrefix("µ", 1e-6L);
alias numberParser = (ref s) => parse!real(s);
auto parser = Parser!(real, numberParser)(symbolList);
auto timing = 1e-6L * century;
assert(timing == parser.parse("1 µCy"));