TSubstringListLinguistic.LoadFromStream Method

Overload List

#SignatureDescription
1procedure LoadFromStream(const Stream: TStream); overload;Replaces the items with the lines of Stream from its position to its end, in the encoding its byte order mark names (UTF-8, UTF-16 or UTF-16 big-endian), else DefaultEncoding.
2procedure LoadFromStream(const Stream: TStream; const Encoding: TEncoding); overload;Replaces the items with the lines of Stream from its position to its end in Encoding, skipping its byte order mark; nil reads in the encoding the byte order mark names, else DefaultEncoding.

Overload 1: procedure LoadFromStream(const Stream: TStream); overload;

Replaces the items with the lines of Stream from its position to its end, in the encoding its byte order mark names (UTF-8, UTF-16 or UTF-16 big-endian), else DefaultEncoding.

#NameDescription
1Stream

The stream, read from its position to its end.

Result: stored in self (calling object)

Remarks:

The lines are cut as Text cuts them, and Encoding becomes the encoding read; as LoadFromStream(Stream, Encoding) otherwise.

Examples
var b: Matrix;
    AStream: TFileStream;
begin
    b := [[0,0,1,3,2]];
    AStream := TFileStream.Create('C:\test.Vec',fmCreate);
    try
        b.LoadFromStream(AStream); // Read info and header for b
    finally
        AStream.Free;
    end;
end;

Overload 2: procedure LoadFromStream(const Stream: TStream; const Encoding: TEncoding); overload;

Replaces the items with the lines of Stream from its position to its end in Encoding, skipping its byte order mark; nil reads in the encoding the byte order mark names, else DefaultEncoding.

#NameDescription
1Stream

The stream, read from its position to its end.

2Encoding

The encoding to read the stream in; nil as LoadFromStream(Stream).

Result: stored in self (calling object)

Remarks:

The lines are cut as Text cuts them, and Encoding becomes the list's Encoding (a copy, when it is not a standard encoding such as TEncoding.UTF8). For UTF-8, UTF-16, and TEncoding.ANSI or TEncoding.ASCII on a single-byte code page, the bytes are converted ChunkSize at a time, in memory of about three times ChunkSize, whatever the number of lines, and a long line's own. Any other encoding converts the stream at once; a stream of more than MaxInt bytes in it raises ESubstringRangeError. The list keeps that memory for its next load or save, which takes more only for more text, until Compact. Bytes the encoding cannot read raise EEncodingError and a position past the stream's end ERangeError, as TStringList; more lines than free rows grow the list, as Text does. After an exception the list is empty.