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

Functions

StreamBuffer * sbufStrCreatePush (string *strout, size_t targetsz)
 

Detailed Description

Convenience functions for common string streaming patterns.

Function Documentation

◆ sbufStrCreatePush()

StreamBuffer * sbufStrCreatePush ( string *  strout,
size_t  targetsz 
)

StreamBuffer *sbufStrCreatePush(string *strout, size_t targetsz)

Creates a stream buffer configured for string output in push mode.

This is a convenience function for the common pattern of creating a stream buffer where the caller acts as a producer in push mode and output goes to a string.

Parameters
stroutString to append output data to
targetszTarget buffer size in bytes
Returns
New configured stream buffer, or NULL on failure

Example:

string output = 0;
StreamBuffer *sb = sbufStrCreatePush(&output, 4096);
sbufPWrite(sb, data, size);
// output now contains the data
strDestroy(&output);
void sbufPFinish(StreamBuffer *sb)
bool sbufPWrite(StreamBuffer *sb, const uint8 *buf, size_t sz)
StreamBuffer * sbufStrCreatePush(string *strout, size_t targetsz)
void strDestroy(strhandle ps)