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

TypeNameDescription
immutable(uint)
LINE_POSITION_UNDEFINED Unknown line position
immutable(int)
BYTE_BUFFER_SIZE
bool
invalidCharFlag
immutable(int)
QUARTER_BYTE_BUFFER_SIZE
immutable(int)
TEXT_BUFFER_SIZE

Properties

TypeNameDescription
encoding[get] Returns file encoding
int
errorCode[get] Returns error code
int
errorLine[get] Returns line where error is found
string
errorMessage[get] Returns error message
int
errorPos[get] Returns line position (number of character in line) where error is found
string
filename[get] Returns file name
uint
line[get] Returns current line number
textFormat[get]

Methods

NameDescription
readLine () Read line from stream. Returns null on end of file or read error
appendedText (len)
consumedBytes (count) When bytes consumed from byte buffer, call this method to update position
decodeText ()
invalidCharError ()
readBytes () Returns slice of bytes available in buffer
reserveTextBuf (len) Reserve text buffer for specified number of characters, and return pointer to first free character in buffer
setError (code, message, errorLine, errorPos)

Static methods

NameDescription
create (stream, filename, autodetectUTFIfNoBOM) Factory for InputStream parser
create (code, filename) Factory method for string parser

Enums

NameDescription
ErrorCodes Error codes