RAD Studio VCL Reference
Classes.LineStart Function

Finds the end of the last whole line in a buffer.

function LineStart(Buffer: PAnsiChar; BufPos: PAnsiChar): PAnsiChar; overload;
function LineStart(Buffer: PWideChar; BufPos: PWideChar): PWideChar; overload;
function LineStart(const Buffer: TBytes; BufPos: Integer): Integer; overload;
PAnsiChar LineStart(PAnsiChar Buffer, PAnsiChar BufPos);
PWideChar LineStart(PWideChar Buffer, PWideChar BufPos);
int LineStart(const TBytes Buffer, int BufPos);

Use LineStart to find the start of the last partial line in the buffer. LineStart starts at BufPos and scans backwards for a line-feed character (\n). It returns a pointer to that character. If no line-feed char is found, it returns the Buffer pointer. Buffer should point to the beginning of a block of memory and BufPos to the end of the block you want to scan.

Note: The undocumented TParser class uses LineStart to locate line-endings in chunks of text read into a fixed-size buffer. When the last full line of text is parsed, the parser moves the last partial line of text from the end of the buffer to the front and fills the rest of the buffer with new data from disk.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!