lu.conv

This module contains functions that in one way or another converts its arguments into something else.

Credit for Enum goes to Stephan Koch (https://github.com/UplinkCoder).

Members

Aliases

enumToString
deprecated alias enumToString = toString

Deprecated alias of toString.

Functions

numFromHex
auto numFromHex(string hex, bool acceptLowercase)

Returns the decimal value of a hex number in string form.

rgbFromHex
auto rgbFromHex(string hexString, bool acceptLowercase)

Convenience wrapper that takes a hex string and populates a Voldemort struct with its integer RR, GG and BB components.

toAlpha
string toAlpha(Num num)

Translates an integer into an alphanumeric string. Overload that returns the string.

toAlphaInto
void toAlphaInto(Num num, Sink sink)

Translates an integer into an alphanumeric string. Overload that takes an output range sink.

toString
auto toString(E value)

Convenience wrapper around Enum.toString that infers the type to instantiate it with from the passed enum member.

Templates

Enum
template Enum(E)

Template housing optimised functions to get the string name of an enum member, or the enum member of a name string.

Examples

enum SomeEnum { one, two, three };

SomeEnum foo = Enum!SomeEnum.fromString("one");
SomeEnum bar = Enum!SomeEnum.fromString("three");

assert(foo == SomeEnum.one);
assert(bar == SomeEnum.three);

assert(Enum!SomeEnum.toString(SomeEnum.one) == "one");
assert(Enum!SomeEnum.toString(SomeEnum.two) == "two");
assert(SomeEnum.three.toString() == "three");

Meta