Function in stdx_string.h

x_smallstr_append_char

Appends a single character if space allows.

X_STRING_API size_t x_smallstr_append_char(
 XSmallstr *s,
 char c
);

Parameters

XSmallstr *s
Destination small string.
char c
Character value.

Returns

Number of units written or measured (excluding the final terminator, if any).

Function in stdx_string.h

x_smallstr_append_cstr

Appends a null-terminated C-string if space allows.

X_STRING_API size_t x_smallstr_append_cstr(
 XSmallstr *s,
 const char *cstr
);

Parameters

XSmallstr *s
Destination small string.
const char *cstr
Source null-terminated C-string.

Returns

Number of units written or measured (excluding the final terminator, if any).

Function in stdx_string.h

x_smallstr_append_n

Appends a fixed-length portion of a C-string to a small string.

X_STRING_API size_t x_smallstr_append_n(
 XSmallstr *s,
 const char *cstr,
 size_t n
);

Parameters

XSmallstr *s
Destination small string.
const char *cstr
Source C-string (may be NULL).
size_t n
Number of bytes to append from cstr.

Returns

New length of the small string in bytes after the operation.

Function in stdx_string.h

x_smallstr_append_slice

Appends the contents of a string view to a small string.

X_STRING_API size_t x_smallstr_append_slice(
 XSmallstr *s,
 XSlice sv
);

Parameters

XSmallstr *s
Destination small string.
XSlice sv
Source string view to append.

Returns

New length of the small string in bytes after the operation (null-terminated).

Function in stdx_string.h

x_smallstr_appendf

Appends formatted text to a small string.

X_STRING_API size_t x_smallstr_appendf(
 XSmallstr *s,
 const char *fmt,
 ...
);

Parameters

XSmallstr *s
Destination small string.
const char *fmt
printf-style format string.
...
Additional arguments for formatting.

Returns

New length of the small string in bytes after the operation.

Function in stdx_string.h

x_smallstr_capacity

Returns the maximum number of bytes (excluding terminator) a small string can hold.

X_STRING_API size_t x_smallstr_capacity(void);

Returns

The compile-time capacity constant X_SMALLSTR_MAX_LENGTH.

Function in stdx_string.h

x_smallstr_clear

Clears the small string to empty.

X_STRING_API void x_smallstr_clear(XSmallstr *s);

Parameters

XSmallstr *s
Destination small string.

Returns

No return value.

Function in stdx_string.h

x_smallstr_cmp

Compares two small strings.

X_STRING_API int32_t x_smallstr_cmp(
 const XSmallstr *a,
 const XSmallstr *b
);

Parameters

const XSmallstr *a
First input view or string.
const XSmallstr *b
Second input view or string.

Returns

Negative, zero, or positive according to lexicographic order.

Function in stdx_string.h

x_smallstr_cmp_ci

Compares two small strings case-insensitively.

X_STRING_API int32_t x_smallstr_cmp_ci(
 const XSmallstr *a,
 const XSmallstr *b
);

Parameters

const XSmallstr *a
First input view or string.
const XSmallstr *b
Second input view or string.

Returns

Negative, zero, or positive according to lexicographic order.

Function in stdx_string.h

x_smallstr_cmp_cstr

Compares a small string with a null-terminated C-string.

X_STRING_API int32_t x_smallstr_cmp_cstr(
 const XSmallstr *a,
 const char *b
);

Parameters

const XSmallstr *a
First input view or string.
const char *b
Second input view or string.

Returns

Negative, zero, or positive according to lexicographic order.

Function in stdx_string.h

x_smallstr_contains_char

Checks whether a small string contains the specified character.

X_STRING_API bool x_smallstr_contains_char(
 const XSmallstr *s,
 char c
);

Parameters

const XSmallstr *s
Input small string.
char c
Character to search for.

Returns

true if the character is found; false otherwise.

Function in stdx_string.h

x_smallstr_cstr

Returns a pointer to the small string's null-terminated buffer.

X_STRING_API const char * x_smallstr_cstr(const XSmallstr *s);

Parameters

const XSmallstr *s
Destination small string.

Returns

Function-specific result.

Function in stdx_string.h

x_smallstr_format

Formats text into a small string; truncates if necessary.

X_STRING_API size_t x_smallstr_format(
 XSmallstr *s,
 const char *fmt,
 ...
);

Parameters

XSmallstr *s
Destination small string.
const char *fmt
printf-style format string.
param
Variadic arguments list.

Returns

Number of units written or measured (excluding the final terminator, if any).

Function in stdx_string.h

x_smallstr_from_cstr

Copies a null-terminated C-string into a small string.

X_STRING_API size_t x_smallstr_from_cstr(
 XSmallstr *s,
 const char *cstr
);

Parameters

XSmallstr *s
Destination small string.
const char *cstr
Source null-terminated C-string.

Returns

Number of units written or measured (excluding the final terminator, if any).

Function in stdx_string.h

x_smallstr_from_slice

Copies a string view into a small string.

X_STRING_API size_t x_smallstr_from_slice(
 XSlice sv,
 XSmallstr *out
);

Parameters

XSlice sv
String view input.
XSmallstr *out
Parameter.

Returns

Number of units written or measured (excluding the final terminator, if any).

Function in stdx_string.h

x_smallstr_init

Initializes a fixed-capacity small string from a source C-string.

X_STRING_API int32_t x_smallstr_init(
 XSmallstr *s,
 const char *str
);

Parameters

XSmallstr *s
Destination small string.
const char *str
Input C-string.

Returns

Function-specific integer result.

Function in stdx_string.h

x_smallstr_is_empty

Tests whether a small string is empty.

X_STRING_API bool x_smallstr_is_empty(const XSmallstr *s);

Parameters

const XSmallstr *s
Input small string.

Returns

true if the small string has zero length or is NULL; false otherwise.

Function in stdx_string.h

x_smallstr_join

Concatenates multiple string views into a small string, inserting a separator between them.

X_STRING_API size_t x_smallstr_join(
 XSmallstr *dst,
 const XSlice *parts,
 size_t count,
 XSlice sep
);

Parameters

XSmallstr *dst
Destination small string.
const XSlice *parts
Array of string views to join.
size_t count
Number of elements in the parts array.
XSlice sep
Separator view inserted between joined elements.

Returns

New length of the small string after concatenation.

Function in stdx_string.h

x_smallstr_length

Returns the current byte length of the small string.

X_STRING_API size_t x_smallstr_length(const XSmallstr *s);

Parameters

const XSmallstr *s
Destination small string.

Returns

Number of elements in the string (excluding the final terminator).

Function in stdx_string.h

x_smallstr_replace_all

Replaces all occurrences of a substring in a small string.

X_STRING_API int32_t x_smallstr_replace_all(
 XSmallstr *s,
 const char *find,
 const char *replace
);

Parameters

XSmallstr *s
Destination small string.
const char *find
Substring to be replaced.
const char *replace
Replacement substring.

Returns

Function-specific integer result.

Function in stdx_string.h

x_smallstr_substring

Copies a byte-range substring into a small string.

X_STRING_API size_t x_smallstr_substring(
 const XSmallstr *s,
 size_t start,
 size_t len,
 XSmallstr *out
);

Parameters

const XSmallstr *s
Destination small string.
size_t start
Starting offset (0-based).
size_t len
Number of units to copy or inspect.
XSmallstr *out
Parameter.

Returns

Number of units written or measured (excluding the final terminator, if any).

Function in stdx_string.h

x_smallstr_to_slice

Creates a non-owning view over a small string's contents.

X_STRING_API XSlice x_smallstr_to_slice(const XSmallstr *s);

Parameters

const XSmallstr *s
Destination small string.

Returns

Resulting view after the operation.

Function in stdx_string.h

x_smallstr_trim

Trims leading and trailing ASCII whitespace in a small string.

X_STRING_API void x_smallstr_trim(XSmallstr *s);

Parameters

XSmallstr *s
Destination small string.

Returns

Resulting view after the operation.

Function in stdx_string.h

x_smallstr_trim_left

Trims leading ASCII whitespace in a small string.

X_STRING_API void x_smallstr_trim_left(XSmallstr *s);

Parameters

XSmallstr *s
Destination small string.

Returns

Resulting view after the operation.

Function in stdx_string.h

x_smallstr_trim_right

Trims trailing ASCII whitespace in a small string.

X_STRING_API void x_smallstr_trim_right(XSmallstr *s);

Parameters

XSmallstr *s
Destination small string.

Returns

No return value.

Function in stdx_string.h

x_smallstr_try_append_cstr

Attempts to append a C-string to a small string up to its capacity.

X_STRING_API bool x_smallstr_try_append_cstr(
 XSmallstr *s,
 const char *cstr,
 size_t *out_appended
);

Parameters

XSmallstr *s
Destination small string.
const char *cstr
Source null-terminated C-string.
size_t *out_appended
Optional pointer to receive bytes actually appended.

Returns

true if any bytes were appended; false if none or on error.

Function in stdx_string.h

x_smallstr_vappendf

Appends formatted text to a small string using a va_list.

X_STRING_API size_t x_smallstr_vappendf(
 XSmallstr *s,
 const char *fmt,
 va_list args
);

Parameters

XSmallstr *s
Destination small string.
const char *fmt
printf-style format string.
va_list args
va_list argument list.

Returns

New length of the small string in bytes after the operation.