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
| Name | Description |
|---|---|
this
(stream, filename, encoding, buf, offset, len)
|
Open file with known encoding |
this
()
|
this constructor was created for unittests only |
Fields
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
encoding[get]
|
EncodingType | Returns file encoding EncodingType |
errorCode[get]
|
int | Returns error code |
errorLine[get]
|
int | Returns line where error is found |
errorMessage[get]
|
string | Returns error message |
errorPos[get]
|
int | Returns line position (number of character in line) where error is found |
filename[get]
|
string | Returns file name |
line[get]
|
uint | Returns current line number |
textFormat[get]
|
TextFileFormat |
Methods
| Name | Description |
|---|---|
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
| Name | Description |
|---|---|
ErrorCodes
|
Error codes |