tango.text.convert.Integer

Members

Functions

atoi
uint atoi(T[] s, int radix)

quick & dirty text-to-unsigned int converter. Use only when you know what the content is, or use parse() or convert() instead.

consume
T[] consume(T[] src, bool fp)

Consume a number from the input without converting it. Argument 'fp' enables floating-point consumption. Supports hex input for numbers which are prefixed appropriately

convert
ulong convert(const(T[]) digits, uint radix, size_t* ate)

Convert the provided 'digits' into an integer value, without checking for a sign or radix. The radix defaults to decimal (10).

format
T[] format(T[] dst, long i, const(T[]) fmt)

Supports format specifications via an array, where format follows the notation given below:

formatter
T[] formatter(T[] dst, long i, char type, char pre, int width)
Undocumented in source. Be warned that the author may not have intended to support it.
itoa
T[] itoa(T[] output, uint value, int radix)

quick & dirty unsigned to text converter, where the provided output must be large enough to house the result (10 digits in the largest case). For mainstream use, consider utilizing format() instead.

main
void main()
parse
long parse(T[] digits, uint radix, size_t* ate)

Parse an integer value from the provided 'digits' string.

toInt
int toInt(const(T[]) digits, uint radix)

Parse an integer value from the provided 'digits' string.

toLong
long toLong(const(T[]) digits, uint radix)

Parse an integer value from the provided 'digits' string.

toString
char[] toString(long i, const(char[]) fmt)

Wrapper to make life simpler. Returns a text version of the provided value.

toString16
wchar[] toString16(long i, const(wchar[]) fmt)

Wrapper to make life simpler. Returns a text version of the provided value.

toString32
dchar[] toString32(long i, const(dchar[]) fmt)

Wrapper to make life simpler. Returns a text version of the provided value.

toUlong
ulong toUlong(const(T[]) digits, uint radix)

Parse an unsignedinteger value from the provided 'digits' string.

trim
size_t trim(const(T[]) digits, bool sign, uint radix)

Strip leading whitespace, extract an optional +/- sign, and an optional radix prefix. If the radix value matches an optional prefix, or the radix is zero, the prefix will be consumed and assigned. Where the radix is non zero and does not match an explicit prefix, the latter will remain unconsumed. Otherwise, radix will default to 10.

Meta

License

BSD style: $(LICENSE)

Version

Initial release: Nov 2005

Authors

Kris

A set of functions for converting between string and integer values.

Applying the D "import alias" mechanism to this module is highly recommended, in order to limit namespace pollution:

import Integer = tango.text.convert.Integer;

auto i = Integer.parse ("32767");