Class LineStream
Support reading of file (or string in memory) by lines.
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
Name | Description |
this
(stream, filename, encoding, buf, offset, len)
|
Open file with known encoding
|
this
()
|
This constructor was created for unittests only
|
Properties
Type | Name | Description |
|
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
Name | Description |
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
Name | Description |
create
(stream, filename, autodetectUTFIfNoBOM)
|
Factory for InputStream parser
|
create
(code, filename)
|
Factory method for string parser
|