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.

IMPORTANT: The stream buffer is invalidated after this call.

Parameters
sbThe stream buffer (invalidated after call)
strString to push into the buffer
Returns
true on success, false on error

Example:

StreamBuffer *sb = sbufCreate(4096);
sbufStrCRegisterPush(sb, &output);
sbufStrIn(sb, _S"Hello, World!");
StreamBuffer * sbufCreate(size_t targetsz)
bool sbufStrCRegisterPush(StreamBuffer *sb, string *strout)
bool sbufStrIn(StreamBuffer *sb, strref str)
#define _S
Creates a static ASCII string from a string literal.
Definition strbase.h:392

◆ 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