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

this
this(InputStream stream, string filename, EncodingType encoding, ubyte[] buf, uint offset, uint len)

Open file with known encoding

this
this()

this constructor was created for unittests only

Members

Enums

ErrorCodes
enum ErrorCodes

Error codes

Functions

appendedText
void appendedText(uint len)
Undocumented in source. Be warned that the author may not have intended to support it.
consumedBytes
void consumedBytes(uint count)
Undocumented in source. Be warned that the author may not have intended to support it.
decodeText
uint decodeText()
Undocumented in source.
invalidCharError
void invalidCharError()
Undocumented in source. Be warned that the author may not have intended to support it.
readBytes
uint readBytes()

returns slice of bytes available in buffer

readLine
dchar[] readLine()

Read line from stream

reserveTextBuf
dchar* reserveTextBuf(uint len)
Undocumented in source. Be warned that the author may not have intended to support it.
setError
void setError(int code, string message, uint errorLine, uint errorPos)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

encoding
EncodingType encoding [@property getter]

Returns file encoding EncodingType

errorCode
int errorCode [@property getter]

Returns error code

errorLine
int errorLine [@property getter]

Returns line where error is found

errorMessage
string errorMessage [@property getter]

Returns error message

errorPos
int errorPos [@property getter]

Returns line position (number of character in line) where error is found

filename
string filename [@property getter]

Returns file name

line
uint line [@property getter]

Returns current line number

textFormat
TextFileFormat textFormat [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

create
LineStream create(string code, string filename)

Factory method for string parser

create
LineStream create(InputStream stream, string filename, bool autodetectUTFIfNoBOM)

Factory for InputStream parser

Static variables

BYTE_BUFFER_SIZE
int BYTE_BUFFER_SIZE;
Undocumented in source.
LINE_POSITION_UNDEFINED
uint LINE_POSITION_UNDEFINED;

Unknown line position

QUARTER_BYTE_BUFFER_SIZE
int QUARTER_BYTE_BUFFER_SIZE;
Undocumented in source.
TEXT_BUFFER_SIZE
int TEXT_BUFFER_SIZE;
Undocumented in source.

Variables

_bomDetected
bool _bomDetected;
Undocumented in source.
_crCount
int _crCount;
Undocumented in source.
_crlfCount
int _crlfCount;
Undocumented in source.
_lfCount
int _lfCount;
Undocumented in source.
invalidCharFlag
bool invalidCharFlag;
Undocumented in source.

Meta