skipWhite in conv.parse #827

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@monarchdodra
Collaborator

Spliced from pull 817
#817

This is the developement discussed in 817: It adds a "skipWhite" function in std.conv that works on anything Range!Character, and operates by reference.

This "fixes" the leading ws "problem" in parse.

This was referenced Oct 1, 2012
@9rnsr 9rnsr and 1 other commented on an outdated diff Oct 2, 2012
@@ -2902,6 +2905,74 @@ unittest
assert(aa3 == ["aaa":[1], "bbb":[2,3], "ccc":[4,5,6]]);
}
+/**
+ * Strips the leading white spaces off of the Source $(D s).
+ * Unlike $(D std.string.stripLeft), $(D skipWhite) will work on any range of
+ * characters, and takes its arguments and returns by reference.
+ * It is meant as a
+ * convenient way to strip leading white spaces before calling another
+ * $(D parse).
+ *
+ * Example:
+ * string ss = "123 12.5";
+ * int i = parse!int(ss);
+ * skipWhite(s);
@9rnsr
9rnsr Oct 2, 2012 Member

s/skipWhite(s)/skipWhite(ss)/;

@monarchdodra
monarchdodra Oct 2, 2012 Collaborator

Done. TY.

@9rnsr
Member
9rnsr commented Oct 2, 2012

I think this is a good addition to std.conv.
@jmdavis and @andralex , I'd to expect that you agree with this.

@monarchdodra
Collaborator

Closing until we decide where to go with parse.

@monarchdodra monarchdodra deleted the monarchdodra:skipwhite branch Apr 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment