Format a printf‐style message into the specified buffer.

Synopsis

Declared in <ball_log.h>

static
int
format(
    char* buffer,
    std::size_t numBytes,
    char const* format, ...);

Description

Fill the specified buffer with at most the specified numBytes characters produced by formatting the variable argument list according to the specified printf‐style format argument; return the number of characters in the resulting formatted string. The last character placed into buffer is always a null terminator (leaving at most numBytes ‐ 1 bytes of formatted data). If numBytes is insufficient for the entire formatted string, this method fills buffer with the initial numBytes ‐ 1 bytes of formatted data followed by a null terminator and returns ‐1. Note that with the exception of the return value, the behavior of this function exactly matches that of the C99 function snprintf. Also note that snprintf is not part of standard C++‐98, so its functionality is provided here.

Return Value

number of characters in the formatted string, or ‐1 if truncated

Parameters

Name

Description

buffer

destination buffer for the formatted string

numBytes

capacity of buffer in bytes

format

printf‐style format string

Created with MrDocs