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

Functions

bool conWrite (ConStream *con, const void *buf, size_t sz)
 
bool conPuts (ConStream *con, strref s)
 
bool conPutsz (ConStream *con, const char *sz)
 
bool conPutc (ConStream *con, int32 codepoint)
 
bool conNL (ConStream *con)
 
bool conFlush (ConStream *con)
 
bool _conFmt (ConStream *con, strref fmt, int n, stvar *args)
 

Detailed Description

Function Documentation

◆ _conFmt()

bool _conFmt ( ConStream *  con,
strref  fmt,
int  n,
stvar args 
)

bool conFmt(ConStream *con, strref fmt, ...);

Formats arguments with cx's type-safe formatter (see Formatting) and writes the result, exactly as if by strFormat() into a temporary string followed by conPuts().

Parameters
conDestination stream
fmtFormat string
Returns
true if formatting and the write both succeeded

Example:

conFmt(conOut(), _SL("Hello ${string}, you have ${int} messages"),
stvar(string, name), stvar(int32, count));
ConStream * conOut(void)
#define _SL(s)
Inline ASCII string literal with compile-time embedded length (STR_LEN8). Content must be < 200 bytes...
Definition strliteral.h:207
#define stvar(typen, val)
Definition stvar.h:162

◆ conFlush()

bool conFlush ( ConStream *  con)

Forces any output buffered by this module to reach the underlying stream immediately.

Parameters
conStream to flush
Returns
true on success

◆ conNL()

bool conNL ( ConStream *  con)

Writes a platform-appropriate newline ("\n" on unix/wasm, "\r\n" on Windows) and flushes if the stream is line-buffered. A conCreateMem() stream always gets a bare "\n" on every platform, since it exists to give tests byte-identical output.

Parameters
conDestination stream
Returns
true on success

◆ conPutc()

bool conPutc ( ConStream *  con,
int32  codepoint 
)

Writes a single Unicode code point, UTF-8 encoded. An invalid code point is replaced with U+FFFD.

Parameters
conDestination stream
codepointUnicode code point to write
Returns
true on success

◆ conPuts()

bool conPuts ( ConStream *  con,
strref  s 
)

Writes a cx string to a stream. Rope-shaped strings are walked chunk by chunk with no flattening allocation.

Parameters
conDestination stream
sString to write (NULL or empty writes nothing and returns true)
Returns
true on success

◆ conPutsz()

bool conPutsz ( ConStream *  con,
const char *  sz 
)

Writes a NUL-terminated C string to a stream.

Parameters
conDestination stream
szString to write (NULL or empty writes nothing and returns true)
Returns
true on success

◆ conWrite()

bool conWrite ( ConStream *  con,
const void *  buf,
size_t  sz 
)

Writes raw bytes to a stream exactly as given – no encoding, no line-ending translation, no buffering policy beyond the stream's own.

Parameters
conDestination stream
bufBytes to write
szNumber of bytes
Returns
true if the bytes were accepted (buffered or written); false on a write error