From e38120c6db9d0bae9a2473656430a746d38fa470 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Sat, 26 Jul 2014 02:27:11 +0200 Subject: [PATCH] A version of scanToNextBreak that reads to a slice. --- source/dyaml/scanner.d | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index 3760fe5..0f74318 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -866,6 +866,20 @@ final class Scanner return reader_.get(length); } + /// Scan all characters until next line break. + /// + /// Assumes that the caller is building a slice in Reader, and puts the scanned + /// characters into that slice. + void scanToNextBreakToSlice() @system pure nothrow @nogc + { + uint length = 0; + while(!"\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(length))) + { + ++length; + } + reader_.sliceBuilder.write(reader_.get(length)); + } + /** * Move to next token in the file/stream. *