CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches

Functions

bool lparseRegisterPull (StreamBuffer *sb, uint32 flags)
 
bool lparseLine (StreamBuffer *sb, string *out)
 

Detailed Description

Pull-mode line parsing where the consumer explicitly requests each line.

Function Documentation

◆ lparseLine()

bool lparseLine ( StreamBuffer *  sb,
string *  out 
)

bool lparseLine(StreamBuffer *sb, string *out)

Retrieves the next line from the stream buffer.

Call this function repeatedly after lparseRegisterPull() to process lines one at a time. The function returns false when there are no more lines to read.

IMPORTANT: The stream buffer is invalidated when this function returns false.

Parameters
sbThe stream buffer (invalidated when returning false)
outString to receive the line content (cleared and populated)
Returns
true if a line was read, false when no more lines are available

◆ lparseRegisterPull()

bool lparseRegisterPull ( StreamBuffer *  sb,
uint32  flags 
)

bool lparseRegisterPull(StreamBuffer *sb, uint32 flags)

Registers the line parser as a consumer with the stream buffer in pull mode.

After registration, repeatedly call lparseLine() to retrieve each line from the stream buffer. This mode gives you explicit control over when lines are processed.

Parameters
sbThe stream buffer
flagsConfiguration flags from LINEPARSER_FLAGS_ENUM
Returns
true on success, false if registration failed

Example:

StreamBuffer *sb = sbufCreate(4096);
sbufFilePRegisterPull(sb, file, true);
string line = 0;
while (lparseLine(sb, &line)) {
// Process each line
printf("Line: %s\n", strZ(line));
}
strDestroy(&line);
bool sbufFilePRegisterPull(StreamBuffer *sb, VFSFile *file, bool close)
@ LPARSE_Auto
Auto-detect line ending style from first line found.
Definition lineparse.h:66
bool lparseLine(StreamBuffer *sb, string *out)
bool lparseRegisterPull(StreamBuffer *sb, uint32 flags)
StreamBuffer * sbufCreate(size_t targetsz)
void strDestroy(strhandle ps)