Class LineStream

Support reading of file (or string in memory) by lines

class LineStream;

Support utf8, utf16, utf32 be and le encodings, and line endings - according to D language source file specification.

Low resource consuming. Doesn't flood with GC allocations. Dup line if you want to store it somewhere.

Tracks line number.

Constructors

NameDescription
this (stream, filename, encoding, buf, offset, len) Open file with known encoding
this () this constructor was created for unittests only

Fields

NameTypeDescription
LINE_POSITION_UNDEFINED immutable(uint)Unknown line position
_bomDetected bool
_crCount int
_crlfCount int
_lfCount int
BYTE_BUFFER_SIZE immutable(int)
invalidCharFlag bool
QUARTER_BYTE_BUFFER_SIZE immutable(int)
TEXT_BUFFER_SIZE immutable(int)

Properties

NameTypeDescription
encoding[get] EncodingTypeReturns file encoding EncodingType
errorCode[get] intReturns error code
errorLine[get] intReturns line where error is found
errorMessage[get] stringReturns error message
errorPos[get] intReturns line position (number of character in line) where error is found
filename[get] stringReturns file name
line[get] uintReturns current line number
textFormat[get] TextFileFormat

Methods

NameDescription
create (stream, filename, autodetectUTFIfNoBOM) Factory for InputStream parser
create (code, filename) Factory method for string parser
readLine () Read line from stream
appendedText (len)
consumedBytes (count)
decodeText ()
invalidCharError ()
readBytes () returns slice of bytes available in buffer
reserveTextBuf (len)
setError (code, message, errorLine, errorPos)

Enums

NameDescription
ErrorCodes Error codes