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

Functions

bool sbufStrIn (StreamBuffer *sb, strref str)
 
bool sbufStrPRegisterPull (StreamBuffer *sb, strref str)
 

Detailed Description

Functions for using strings as stream buffer data sources.

Function Documentation

◆ sbufStrIn()

bool sbufStrIn ( StreamBuffer *  sb,
strref  str 
)

bool sbufStrIn(StreamBuffer *sb, strref str)

Pushes the entire contents of a string into a stream buffer.

Automatically chunks the data based on the stream buffer's target size for efficient operation. The stream buffer is automatically finished after all data is written.

If flow control is active (see sbufSetWatermark()), this waits for the consumer to make room rather than dropping data, so the consumer has to be draining the buffer from another thread.

Parameters
sbThe stream buffer
strString to push into the buffer
Returns
true on success, false on error

Example:

StreamBuffer *sb = sbufCreate(4096);
sbufStrCRegisterPush(sb, &output);
sbufStrIn(sb, _SL("Hello, World!"));
#define sbufCreate(targetsz,...)
Definition streambuf.h:275
bool sbufStrCRegisterPush(StreamBuffer *sb, string *strout)
bool sbufStrIn(StreamBuffer *sb, strref str)
#define _SL(s)
Inline ASCII string literal with compile-time embedded length (STR_LEN8). Content must be < 200 bytes...
Definition strliteral.h:207

◆ sbufStrPRegisterPull()

bool sbufStrPRegisterPull ( StreamBuffer *  sb,
strref  str 
)

bool sbufStrPRegisterPull(StreamBuffer *sb, strref str)

Registers a string as a producer with the stream buffer in pull mode.

In pull mode, the consumer pulls data as needed, and the string provides it in chunks. Use this instead of sbufStrIn() when you need finer control over when data is provided.

Parameters
sbThe stream buffer
strString to use as data source
Returns
true on success, false if registration failed