Defines functions for interacting with c-style strings.
Compares two strings, ignoring differences in case. The return value is:
< 0
if string1
is ASCII-betically lower than string2
.
0
if the two strings are equal.
> 0
if string1
is ASCII-betically higher than string2
.
This function is meant to be a drop-in replacement for strcasecmp
.
string1
: The first string to compare. string2
: The second string to compare.
int SbStringCompareNoCase(const char *string1, const char *string2)
Compares the first count
characters of two strings, ignoring differences in case. The return value is:
< 0
if string1
is ASCII-betically lower than string2
.
0
if the two strings are equal.
> 0
if string1
is ASCII-betically higher than string2
.
This function is meant to be a drop-in replacement for strncasecmp
.
string1
: The first string to compare. string2
: The second string to compare. count
: The number of characters to compare.
int SbStringCompareNoCaseN(const char *string1, const char *string2, size_t count)
Copies source
into a buffer that is allocated by this function and that can be freed with SbMemoryDeallocate. This function is meant to be a drop-in replacement for strdup
.
source
: The string to be copied.
char* SbStringDuplicate(const char *source)
Produces a string formatted with format
and arguments
, placing as much of the result that will fit into out_buffer
. The return value specifies the number of characters that the format would produce if buffer_size
were infinite.
This function is meant to be a drop-in replacement for vsnprintf
.
out_buffer
: The location where the formatted string is stored. buffer_size
: The size of out_buffer
. format
: A string that specifies how the data should be formatted. arguments
: Variable arguments used in the string.
int SbStringFormat(char *out_buffer, size_t buffer_size, const char *format, va_list arguments) SB_PRINTF_FORMAT(3
An inline wrapper of SbStringFormat that converts from ellipsis to va_args. This function is meant to be a drop-in replacement for snprintf
.
out_buffer
: The location where the formatted string is stored. buffer_size
: The size of out_buffer
. format
: A string that specifies how the data should be formatted. ...
: Arguments used in the string.
int static int static int SbStringFormatF(char *out_buffer, size_t buffer_size, const char *format,...) SB_PRINTF_FORMAT(3
An inline wrapper of SbStringFormat that is meant to be a drop-in replacement for the unsafe but commonly used sprintf
.
out_buffer
: The location where the formatted string is stored. format
: A string that specifies how the data should be formatted. ...
: Arguments used in the string.
static int static int SbStringFormatUnsafeF(char *out_buffer, const char *format,...) SB_PRINTF_FORMAT(2
This function is identical to SbStringFormat, but is for wide characters. It is meant to be a drop-in replacement for vswprintf
.
out_buffer
: The location where the formatted string is stored. buffer_size
: The size of out_buffer
. format
: A string that specifies how the data should be formatted. arguments
: Variable arguments used in the string.
int SbStringFormatWide(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format, va_list arguments)
An inline wrapper of SbStringFormatWide that converts from ellipsis to va_args
.
out_buffer
: The location where the formatted string is stored. buffer_size
: The size of out_buffer
. format
: A string that specifies how the data should be formatted. ...
: Arguments used in the string.
static int SbStringFormatWideF(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format,...)
Scans buffer
for pattern
, placing the extracted values in arguments
. The return value specifies the number of successfully matched items, which may be 0
.
This function is meant to be a drop-in replacement for vsscanf
.
buffer
: The string to scan for the pattern. pattern
: The string to search for in buffer
. arguments
: Values matching pattern
that were extracted from buffer
.
int SbStringScan(const char *buffer, const char *pattern, va_list arguments)
An inline wrapper of SbStringScan that converts from ellipsis to va_args
. This function is meant to be a drop-in replacement for sscanf
. buffer
: The string to scan for the pattern. pattern
: The string to search for in buffer
. ...
: Values matching pattern
that were extracted from buffer
.
static int SbStringScanF(const char *buffer, const char *pattern,...)