> home > Custom Layer Boundary API

buffer_seek_string

January 19th 2020
Scan a buffer from a point to the first occurence of a string

Signature

C++
String_Match
buffer_seek_string(Application_Links* app,
                   Buffer_ID buffer,
                   String_Const_u8 needle,
                   Scan_Direction direction,
                   i64 start_pos);

Parameters

app

the standard custom layer context pointer

buffer

the id of the buffer who's contents to seek

needle

the string to match against the contents of the buffer

direction

the scan direction of the scan from the start point

start_pos

the start point of the scan

Return

a single string match containing the range of the match and 'match type' flags on success, when the buffer exists and a match is found, otherwise cleared to zero; one can easily determine whether there was a match by the buffer member of the result
The returned range is left inclusive right exclusive, so that range.max - range.min is the size of the match, and range.min is the first index of the matching string.
Non-case sensitive matches are reported, but if the match that was found is case sensitive the StringMatch_CaseSensitive flag is set on the result.

Details

The match is never permitted to be found at start_pos, thus to search the whole buffer from the beginning start_pos should be -1 and to search backward from the end start_pos should be the size of the buffer.

Related

Scan_Direction
String_Match