Component index
Section index

Component streamp


Search

Type

Function

Summary

Extract records out of a byte stream

Description

streamp uses a fill() functag to read bytes and a process() functag to extract records (chunks) out of those bytes. It may combined several small read yielding large records or large reads, yielding many smaller records.

Records may be of different sizes during the sesssion. The process() functag decides what is a valid record and how long it is.

The component is built using the STREAMP object.

int fill (void *buf, int size, bool &end)
int process (const void *buf, int len, bool &end, bool nomore)

Examples

sample / streamp component
sample / STREAMP object

Prototypes

void streamp ()

Loop until there is no bytes left or until one functag request the end of the loop

Functags

int fill (void *buf, int size, bool &end) Mandatory

Reads some bytes in the buffer

This is called until there is enough bytes to please the process functag

int process (const void *buf, int len, bool &end, bool nomore) Mandatory

Process one record if there is enough bytes

The functag must check for record. For example, if the function process text line, it will make sure there is an end of line character in the buffer. The function returns the number of bytes used in the buffer or 0 if there were not enough bytes (incomplete record).