Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
mir.parse
@nogc and nothrow Parsing Utilities
License:
Authors:
Ilia Ki
- struct
ParsePosition; - Parsing position
- string
file; - uint
line; - 0 is for unknown
- uint
column; - 0 is for unknown
- const void
toString(W)(ref scope Ww) scope;
- enum
DecimalExponentKey: int; -
noneinfinitynandotdeDE
- struct
DecimalExponentInfo; - Examples:mir.conv: to extension.
import mir.test: should; import mir.conv: to; "123.0".to!double.should == 123; "123".to!int.should == 123; "123".to!byte.should == 123; import mir.small_string; alias S = SmallString!32; "123.0".SmallString!32.to!double.should == 123;
- long
exponent; - DecimalExponentKey
key;
- template
fromString(T) if (isMutable!T) - Performs nothrow and @nogc string to native type conversion.Returns:parsed valueThrows:nogc Exception in case of parse error or non-empty remaining input.
Floating point Mir parsing supports up-to quadruple precision. The conversion error is 0 ULP for normal numbers. Subnormal numbers with an exponent greater than or equal to -512 have upper error bound equal to 1 ULP.
- T
fromString(C)(scope const(C)[]str)
if (isSomeChar!C);
- @trusted bool
fromString(T, C)(scope const(C)[]str, ref Tvalue)
if (isSomeChar!C && isFloatingPoint!T);
boolfromString(T, C)(scope const(C)[]str, ref Tvalue)
if (isSomeChar!C && !isFloatingPoint!T); - Performs nothrow and @nogc string to native type conversion.
Rseturns true if success and false otherwise.
Examples:int value; assert("123".fromString(value) && value == 123);
Examples:double value = 0; assert("+Inf".fromString(value) && value == double.infinity); assert("-nan".fromString(value) && value != value);
- bool
parse(T, C)(ref scope inout(C)[]str, ref scope Tvalue)
if (isSomeChar!C && isSomeChar!T && (T.sizeof == C.sizeof)); - Single character parsing utilities.Returns:true if success and false otherwise.Examples:
auto s = "str"; char c; assert(parse(s, c)); assert(c == 's'); assert(s == "tr");
- bool
parse(T, C)(ref scope inout(C)[]str, out scope Tvalue)
if ((is(T == byte) || is(T == short)) && isSomeChar!C); - Integer parsing utilities.Returns:true if success and false otherwise.
Copyright © 2016-2026 by Ilya Yaroshenko | Page generated by
Ddoc on Wed Apr 8 13:47:04 2026