Struct in stdx_string.h

XSlice

typedef struct{
  const char *ptr;
  size_t length;
}XSlice;
Macro in stdx_string.h

X_STRVIEW

Creates a compile-time string view from a string literal.

#define X_STRVIEW(s) ((XSlice){(s), sizeof(s)-1u})

Parameters

s
String literal.

Returns

XSlice representing the literal contents, excluding the null terminator.

Function in stdx_string.h

x_slice_cmp

Lexicographically compares two string views.

X_STRING_API int32_t x_slice_cmp(
 XSlice a,
 XSlice b
);

Parameters

XSlice a
First input view or string.
XSlice b
Second input view or string.

Returns

Negative, zero, or positive according to lexicographic order.

Function in stdx_string.h

x_slice_cmp_ci

Lexicographically compares two string views case-insensitively.

X_STRING_API int32_t x_slice_cmp_ci(
 XSlice a,
 XSlice b
);

Parameters

XSlice a
First input view or string.
XSlice b
Second input view or string.

Returns

Function-specific integer result.

Function in stdx_string.h

x_slice_contains_char

Checks whether a string view contains the specified character.

X_STRING_API bool x_slice_contains_char(
 XSlice sv,
 char c
);

Parameters

XSlice sv
Input string view.
char c
Character to search for.

Returns

true if the character is found; false otherwise.

Function in stdx_string.h

x_slice_contains_utf8

Checks whether a string view contains the specified UTF-8 codepoint.

X_STRING_API bool x_slice_contains_utf8(
 XSlice sv,
 uint32_t codepoint
);

Parameters

XSlice sv
Input string view.
uint32_t codepoint
Unicode codepoint to search for.

Returns

true if the codepoint is found; false otherwise.

Function in stdx_string.h

x_slice_ends_with_cstr

Checks whether a string view ends with the given C-string suffix.

X_STRING_API bool x_slice_ends_with_cstr(
 XSlice sv,
 const char *prefix
);

Parameters

XSlice sv
String view input.
const char *prefix
Prefix to match.

Returns

true if the condition holds; false otherwise.

Function in stdx_string.h

x_slice_eq

Compares two string views for equality.

X_STRING_API bool x_slice_eq(
 XSlice a,
 XSlice b
);

Parameters

XSlice a
First input view or string.
XSlice b
Second input view or string.

Returns

true if the condition holds; false otherwise.

Function in stdx_string.h

x_slice_eq_ci

Compares two string views case-insensitively.

X_STRING_API bool x_slice_eq_ci(
 XSlice a,
 XSlice b
);

Parameters

XSlice a
First input view or string.
XSlice b
Second input view or string.

Returns

true if the condition holds; false otherwise.

Function in stdx_string.h

x_slice_eq_cstr

Compares a string view with a C-string for equality.

X_STRING_API bool x_slice_eq_cstr(
 XSlice a,
 const char *b
);

Parameters

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

Returns

Function-specific result.

Function in stdx_string.h

x_slice_find

Finds the first occurrence of a character in a string view.

X_STRING_API int32_t x_slice_find(
 XSlice sv,
 char c
);

Parameters

XSlice sv
String view input.
char c
Character value.

Returns

Index on success, or -1 if not found.

Function in stdx_string.h

x_slice_find_white_space

Finds the next ASCII whitespace in a string view.

X_STRING_API int32_t x_slice_find_white_space(XSlice sv);

Parameters

XSlice sv
String view input.

Returns

Index on success, or -1 if not found.

Function in stdx_string.h

x_slice_from_cstr

Creates a non-owning string view from a null-terminated C-string.

X_STRING_API XSlice x_slice_from_cstr(const char *s);

Parameters

const char *s
Source null-terminated C-string (may be NULL).

Returns

XSlice pointing to the provided string, or an empty view if s is NULL.

Function in stdx_string.h

x_slice_from_smallstr

Creates a non-owning string view from a fixed-capacity small string.

X_STRING_API XSlice x_slice_from_smallstr(const XSmallstr *s);

Parameters

const XSmallstr *s
Source small string (may be NULL).

Returns

XSlice referencing the contents of the small string, or an empty view if s is NULL.

Function in stdx_string.h

x_slice_hash

Computes a 32-bit FNV hash for a XSlice

X_STRING_API uint32_t x_slice_hash(XSlice slice);

Parameters

XSlice slice
Input Slice

Returns

32 bit FNV hash

Macro in stdx_string.h

x_slice_init

#define x_slice_init(cstr, len) ((XSlice){.ptr=(cstr), .length=(len)})
Function in stdx_string.h

x_slice_next_token

Extracts the next token delimited by a character.

X_STRING_API bool x_slice_next_token(
 XSlice *input,
 char delim,
 XSlice *token
);

Parameters

XSlice *input
Parameter.
char delim
Delimiter character or codepoint.
XSlice *token
Output: extracted token.

Returns

Function-specific result.

Function in stdx_string.h

x_slice_next_token_white_space

Extracts the next token delimited by ASCII whitespace.

X_STRING_API bool x_slice_next_token_white_space(
 XSlice *input,
 XSlice *token
);

Parameters

XSlice *input
Parameter.
XSlice *token
Output: extracted token.

Returns

Function-specific result.

Function in stdx_string.h

x_slice_rfind

Finds the last occurrence of a character in a string view.

X_STRING_API int32_t x_slice_rfind(
 XSlice sv,
 char c
);

Parameters

XSlice sv
String view input.
char c
Character value.

Returns

Index on success, or -1 if not found.

Function in stdx_string.h

x_slice_split_at

Splits a string view at the first occurrence of a delimiter.

X_STRING_API bool x_slice_split_at(
 XSlice sv,
 char delim,
 XSlice *left,
 XSlice *right
);

Parameters

XSlice sv
String view input.
char delim
Delimiter character or codepoint.
XSlice *left
Output: left side view.
XSlice *right
Output: right side view.

Returns

Function-specific result.

Function in stdx_string.h

x_slice_split_at_white_space

Splits a string view at the first ASCII whitespace.

X_STRING_API bool x_slice_split_at_white_space(
 XSlice sv,
 XSlice *left,
 XSlice *right
);

Parameters

XSlice sv
String view input.
XSlice *left
Output: left side view.
XSlice *right
Output: right side view.

Returns

Function-specific result.

Function in stdx_string.h

x_slice_starts_with_cstr

Checks whether a string view starts with the given C-string prefix.

X_STRING_API bool x_slice_starts_with_cstr(
 XSlice sv,
 const char *prefix
);

Parameters

XSlice sv
String view input.
const char *prefix
Prefix to match.

Returns

true if the condition holds; false otherwise.

Function in stdx_string.h

x_slice_substr

Creates a sub-view by byte range from a string view.

X_STRING_API XSlice x_slice_substr(
 XSlice sv,
 size_t start,
 size_t len
);

Parameters

XSlice sv
String view input.
size_t start
Starting offset (0-based).
size_t len
Number of units to copy or inspect.

Returns

Resulting view after the operation.

Function in stdx_string.h

x_slice_trim

Removes leading and trailing ASCII whitespace from a string view.

X_STRING_API XSlice x_slice_trim(XSlice sv);

Parameters

XSlice sv
String view input.

Returns

Function-specific result.

Function in stdx_string.h

x_slice_trim_left

Removes leading ASCII whitespace from a string view.

X_STRING_API XSlice x_slice_trim_left(XSlice sv);

Parameters

XSlice sv
String view input.

Returns

Function-specific result.

Function in stdx_string.h

x_slice_trim_right

Removes trailing ASCII whitespace from a string view.

X_STRING_API XSlice x_slice_trim_right(XSlice sv);

Parameters

XSlice sv
String view input.

Returns

Resulting view after the operation.