System.Classes.LineStart

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function LineStart(const Buffer: TBytes; BufPos: NativeInt): NativeInt;
function LineStart(Buffer, BufPos: PAnsiChar): PAnsiChar;
function LineStart(Buffer, BufPos: PChar): PChar;

C++

extern DELPHI_PACKAGE NativeInt __fastcall LineStart(const System::DynamicArray<System::Byte> Buffer, NativeInt BufPos)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.Classes.pas
System.Classes.hpp
System.Classes System.Classes

Description

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

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.