Lines Matching refs:parse

13         $(LREF parse)
123 return new ConvException(text("Can't parse string: ", msg), fn, ln);
1983 !isExactSomeString!T && is(typeof(parse!T(value))) &&
1994 return parse!T(value);
2000 isIntegral!T && is(typeof(parse!T(value, radix))))
2009 return parse!T(value, radix);
2054 supported by parse parses the first dchar of the source.
2064 if (isSomeChar!T && !is(typeof(parse!T(value))) &&
2065 is(typeof(parse!dchar(value))))
2069 immutable dchar codepoint = parse!dchar(value);
2259 The `parse` family of functions works quite like the `to`
2285 to `parse` and do not require lvalues.
2287 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source)
2342 bool b = parse!bool(s);
2345 bool b2 = parse!(bool, string, No.doCount)(s2);
2348 auto b3 = parse!(bool, string, Yes.doCount)(s3);
2351 auto b4 = parse!(bool, string, Yes.doCount)(s4);
2368 assert(parse!bool(s) == true);
2370 assert(parse!bool(s) == false);
2372 assert(parse!bool(s) == true);
2374 assert(parse!bool(s) == false);
2376 assert(parse!bool(s) == true);
2378 assert(parse!bool(s) == false);
2384 assertThrown!ConvException(parse!bool(s));
2406 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref scope Source s)
2413 auto v = .parse!(Select!(Target.min < 0, int, uint), Source, Yes.doCount)(s);
2535 auto a = parse!int(s);
2539 auto a1 = parse!(int, string, Yes.doCount)(s1);
2542 // parse only accepts lvalues
2543 static assert(!__traits(compiles, parse!int("123")));
2552 auto a = parse!uint(test);
2554 assert(test == " \t 76.14"); // parse bumps string
2557 auto b = parse!double(test);
2562 auto a2 = parse!(uint, string, Yes.doCount)(test2);
2564 assert(test2 == " \t 76.14");// parse bumps string
2567 auto b2 = parse!(double, string, Yes.doCount)(test2);
2702 // parse!SomeUnsigned cannot parse head sign.
2776 assertCTFEable!({ string s = "1234abc"; assert(parse! int(s) == 1234 && s == "abc"); });
2777 assertCTFEable!({ string s = "-1234abc"; assert(parse! int(s) == -1234 && s == "abc"); });
2778 assertCTFEable!({ string s = "1234abc"; assert(parse!uint(s) == 1234 && s == "abc"); });
2780 assertCTFEable!({ string s = "1234abc"; assert(parse!( int, string, Yes.doCount)(s) ==
2782 assertCTFEable!({ string s = "-1234abc"; assert(parse!( int, string, Yes.doCount)(s) ==
2784 assertCTFEable!({ string s = "1234abc"; assert(parse!(uint, string, Yes.doCount)(s) ==
2810 assert(parse!int(input) == 777);
2813 assert(parse!(int, StrInputRange, Yes.doCount)(input2) == tuple(777, 3));
2820 assert(parse!(string[])(s1) == ["a", "\0", "!", "!8"]);
2824 assert(parse!(string[], string, Yes.doCount)(s1) == tuple(["a", "\0", "!", "!8"], len));
2828 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source, uint radix)
2842 return parse!(Target, Source, doCount)(source);
2845 enforce!ConvException(!source.empty, "s must not be empty in integral parse");
2915 string s; // parse doesn't accept rvalues
2918 assert(parse!int(s = "0", i) == 0);
2919 assert(parse!int(s = "1", i) == 1);
2920 assert(parse!byte(s = "10", i) == i);
2921 assert(parse!(int, string, Yes.doCount)(s = "0", i) == tuple(0, 1));
2922 assert(parse!(int, string, Yes.doCount)(s = "1", i) == tuple(1, 1));
2923 assert(parse!(byte, string, Yes.doCount)(s = "10", i) == tuple(i, 2));
2926 assert(parse!int(s = "0011001101101", 2) == 0b0011001101101);
2927 assert(parse!int(s = "765", 8) == octal!765);
2928 assert(parse!int(s = "000135", 8) == octal!"135");
2929 assert(parse!int(s = "fCDe", 16) == 0xfcde);
2932 assert(parse!int(s = "-42", 10) == -42);
2934 assert(parse!ubyte(s = "ff", 16) == 0xFF);
2942 auto u = parse!uint(r, 16);
2947 auto u2 = parse!(uint, typeof(r2), Yes.doCount)(r2, 16);
2957 assertThrown!ConvOverflowException(s.parse!ubyte(16));
2964 assert(parse!uint(str) == 0);
2967 assert(parse!(uint, string, Yes.doCount)(str) == tuple(0, 1));
2976 assertThrown(str.parse!uint(16));
2977 assertThrown(str.parse!(uint, string, Yes.doCount)(16));
2997 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s)
3042 assert(parse!EnumType(str) == EnumType.a);
3044 assert(parse!(EnumType, string, No.doCount)(str2) == EnumType.a);
3046 assert(parse!(EnumType, string, Yes.doCount)(str3) == tuple(EnumType.a, 1));
3083 assert(parse!A(s) == A.member111 && s == "1");
3085 assert(parse!(A, string, No.doCount)(s2) == A.member111 && s2 == "1");
3087 assert(parse!(A, string, Yes.doCount)(s3) == tuple(A.member111, 9) && s3 == "1");
3108 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source)
3444 assert(parse!double(str).isClose(123.456));
3446 assert(parse!(double, string, No.doCount)(str2).isClose(123.456));
3448 auto r = parse!(double, string, Yes.doCount)(str3);
3452 r = parse!(double, string, Yes.doCount)(str4);
3456 r = parse!(double, string, Yes.doCount)(str5);
3460 r = parse!(double, string, Yes.doCount)(str6);
3463 auto r2 = parse!(float, string, Yes.doCount)(str7);
3466 auto r3 = parse!(real, string, Yes.doCount)(str8);
3567 assert(feq(parse!real(fullPrecision), pi, 2*real.epsilon));
3569 assert(feq(parse!(real, string, No.doCount)(fullPrecision2), pi, 2*real.epsilon));
3572 auto res = parse!(real, string, Yes.doCount)(fullPrecision3);
3578 assert(parse!real(full) == x);
3580 assert(parse!(real, string, No.doCount)(full2) == x);
3583 assert(parse!(real, string, Yes.doCount)(full3) == tuple(x, len2));
3598 auto x = parse!real(s);
3606 assert(parse!(real, string, Yes.doCount)(s) == tuple(x, len));
3610 x = parse!real(s);
3618 x = parse!real(s);
3626 x = parse!real(s);
3634 x = parse!real(s);
3642 x = parse!real(s);
3650 x = parse!real(s);
3655 assertThrown!ConvException(x = parse!real(s));
3660 x = parse!real(s);
3666 assert(parse!(real, string, Yes.doCount)(s) == tuple(x, len));
3714 ld = parse!real(s2);
3736 ld = parse!real(s2);
3750 auto x = parse!double(s);
3756 auto x = parse!(double, string, Yes.doCount)(s);
3783 parse!double(s);
3785 assertThrown!ConvException(parse!double(s));
3804 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s)
3826 // Special case: okay so parse a Char off a Char[]
3850 assert(parse!Char(s) == 'a');
3852 assert(parse!(Char, typeof(s), No.doCount)(s) == 'a');
3854 assert(parse!(Char, typeof(s), Yes.doCount)(s) == tuple('a', 1) && s == "");
3861 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s)
3884 char first = parse!char(s);
3887 char second = parse!(char, string, No.doCount)(s);
3890 auto third = parse!(char, string, Yes.doCount)(s);
3897 Tests for to!bool and parse!bool
3908 assert(parse!bool(t) == true);
3912 assert(parse!bool(f) == false);
3916 assert(parse!(bool, dstring, Yes.doCount)(f) == tuple(false, 5));
3920 assertThrown!ConvException(parse!bool(m));
3921 assertThrown!ConvException(parse!(bool, string, Yes.doCount)(m));
3925 auto b = parse!(const(bool))(s);
3946 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s)
3976 assert(parse!NullType(s1) is null);
3980 assert(parse!NullType(s2) is null);
3984 assert(parse!(NullType, string, No.doCount)(s3) is null);
3985 auto r = parse!(NullType, string, Yes.doCount)(s3);
3989 assertThrown!ConvException(parse!NullType(m));
3990 assertThrown!ConvException(parse!(NullType, string, Yes.doCount)(m));
3994 assert(parse!(const NullType)(s) is null);
3997 //Used internally by parse Array/AA, to remove ascii whites
4048 * s = The string to parse
4059 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s, dchar lbracket = '[',
4112 auto a1 = parse!(string[])(s1);
4116 auto a2 = parse!(string[])(s2);
4121 auto a3 = parse!(string[], string, Yes.doCount)(s3);
4133 assert(s0.parse!(int[]) == [1,2]);
4134 assert(s1.parse!(int[]) == [1,2]);
4135 assert(s2.parse!(int[]) == [1,2]);
4143 assert(s0.parse!(int[], string, Yes.doCount) == tuple([1,2], len0));
4144 assert(s1.parse!(int[], string, Yes.doCount) == tuple([1,2], len1));
4145 assert(s2.parse!(int[], string, Yes.doCount) == tuple([1,2], len2));
4149 assert(s3.parse!(string[]) == ["a","b"]);
4150 assert(s4.parse!(string[]) == ["a","b"]);
4154 assert(s3.parse!(string[], string, Yes.doCount) == tuple(["a","b"], len3));
4157 assert(tuple([], s3.length) == s3.parse!(string[], string, Yes.doCount));
4162 assertThrown!ConvException(parse!(string[])(s5));
4163 assertThrown!ConvException(parse!(int[])(s6));
4167 assertThrown!ConvException(parse!(string[], string, Yes.doCount)(s5));
4168 assertThrown!ConvException(parse!(string[], string, Yes.doCount)(s6));
4207 assertThrown!ConvException(parse!(int[])(ss));
4208 assertThrown!ConvException(parse!(int[], string, Yes.doCount)(ss));
4210 int[] arr = parse!(int[])(s);
4211 auto arr2 = parse!(int[], string, Yes.doCount)(s2);
4240 assert(s2 == parse!(string[])(s1));
4242 assert(tuple(s2, s3.length) == parse!(string[], string, Yes.doCount)(s3));
4246 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s, dchar lbracket = '[',
4316 auto sa1 = parse!(int[4])(s1);
4319 assert(tuple([1,2,3,4], s1.length) == parse!(int[4], string, Yes.doCount)(s1));
4322 auto sa2 = parse!(int[][3])(s2);
4325 assert(tuple([[1],[2,3],[4]], s2.length) == parse!(int[][3], string, Yes.doCount)(s2));
4328 assertThrown!ConvException(parse!(int[4])(s3));
4329 assertThrown!ConvException(parse!(int[4], string, Yes.doCount)(s3));
4332 assertThrown!ConvException(parse!(int[4])(s4));
4333 assertThrown!ConvException(parse!(int[4], string, Yes.doCount)(s4));
4342 * s = the string to parse
4355 auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s, dchar lbracket = '[',
4414 auto aa1 = parse!(int[int])(s1);
4416 assert(tuple([1:10, 2:20, 3:30], copyS1.length) == parse!(int[int], string, Yes.doCount)(copyS1));
4420 auto aa2 = parse!(int[string])(s2);
4423 parse!(int[string], string, Yes.doCount)(copyS2));
4427 auto aa3 = parse!(int[][string])(s3);
4430 parse!(int[][string], string, Yes.doCount)(copyS3));
4434 assert(tuple(emptyAA, s4.length) == parse!(int[int], string, Yes.doCount)(s4));
4447 assertThrown!ConvException(parse!(int[int])(ss));
4448 assertThrown!ConvException(parse!(int[int], string, Yes.doCount)(ss));
4450 int[int] aa = parse!(int[int])(s);
4451 auto aa2 = parse!(int[int], string, Yes.doCount)(s2);
4658 // parse array of chars
4663 return parse!(Target, Source, doCount)(s);
4749 return parse!(Target, Source, doCount)(s);
4863 $(LREF parse) for parsing octal strings at runtime.