@@ -40,6 +40,7 @@ TStdBase = class(TInterfacedObject)
40
40
TStdReader = class (TStdBase, IStdReader)
41
41
protected
42
42
InternalBuffer: TBytes;
43
+ FLinesBuffer: string;
43
44
protected
44
45
function PullMessage (out AByteCount: integer): PBytes; virtual ;
45
46
function IsAlive : boolean; virtual ; abstract ;
@@ -52,6 +53,8 @@ TStdReader = class(TStdBase, IStdReader)
52
53
53
54
function ReadNext (const AEncoding: TEncoding): string; overload;
54
55
function ReadNext (): string; overload;
56
+ function ReadNextLine (const AEncoding: TEncoding): string; overload;
57
+ function ReadNextLine (): string; overload;
55
58
function ReadAll (const AEncoding: TEncoding): string; overload;
56
59
function ReadAll (): string; overload;
57
60
function ReadAll (out AValue: string; const ATimeout: cardinal; const AEncoding: TEncoding): boolean; overload;
@@ -207,6 +210,28 @@ function TStdReader.ReadNext: string;
207
210
Result := ReadNext(GetEncoding());
208
211
end ;
209
212
213
+ function TStdReader.ReadNextLine (const AEncoding: TEncoding): string;
214
+ begin
215
+ FLinesBuffer := FLinesBuffer + ReadNext(AEncoding);
216
+
217
+ if FLinesBuffer.IsEmpty() then
218
+ Exit(String.Empty);
219
+
220
+ var LLineEnd := FLinesBuffer.IndexOf(sLineBreak);
221
+ if LLineEnd > -1 then begin
222
+ LLineEnd := LLineEnd + Length(sLineBreak);
223
+
224
+ Result := FLinesBuffer.Substring(0 , LLineEnd);
225
+ FLinesBuffer := FLinesBuffer.Remove(0 , LLineEnd);
226
+ end else
227
+ Result := String.Empty;
228
+ end ;
229
+
230
+ function TStdReader.ReadNextLine : string;
231
+ begin
232
+ Result := ReadNextLine(GetEncoding());
233
+ end ;
234
+
210
235
function TStdReader.ReadAll (out AValue: string;
211
236
const ATimeout: cardinal; const AEncoding: TEncoding): boolean;
212
237
var
0 commit comments