100#if defined(COMPILER_CLANG) || defined(COMPILER_GCC)
104# define STR8(s) ((String8){.str = (u8 *)(s), .size = sizeof(s) - 1})
106# define STR8(s) ((String8){.str = (u8 *)(s), .size = sizeof(s) - 1})
117#define STR8_FMT(s) (int)(s).size, (char *)(s).str
148 String8 result = {first, (
usize)(one_past_last - first)};
160 if (cstr == NULL)
return (
String8){0};
161 return str8((
u8 *)cstr, strlen(cstr));
174 return str8(str.
str, clamped_size);
187 return str8(str.
str + (str.
size - clamped_size), clamped_size);
200 return str8(str.
str + clamped_amt, str.
size - clamped_amt);
228 if (clamped_opl < clamped_first) clamped_opl = clamped_first;
229 return str8(str.
str + clamped_first, clamped_opl - clamped_first);
260 if (tolower(a.
str[i]) != tolower(b.
str[i])) {
306 for (
usize i = 0; i < str.
size; i += 1) {
307 if (str.
str[i] ==
byte) {
325 if (list->
last != NULL) {
Context detection, compiler abstractions, utility macros, and data structures.
Core fixed-width type aliases and memory size constants.
#define function
File-scoped function (invisible to the linker).
#define C_LINKAGE_END
Closes a C linkage block for C++ compilers (Empty in C).
#define C_LINKAGE_BEGIN
Opens a C linkage block for C++ compilers (Empty in C).
static String8 str8(u8 *str, usize size)
Creates a String8 from a raw pointer and explicit byte length.
static b32 str8_starts_with(String8 str, String8 prefix)
Returns 1 if str begins with prefix.
static String8 str8_cstr(const char *cstr)
Converts a null-terminated C string into a String8.
static String8 str8_suffix(String8 str, usize size)
Returns the last size bytes of str.
static String8 str8_skip(String8 str, usize amt)
Returns str with the first amt bytes removed.
static b32 str8_match_nocase(String8 a, String8 b)
Returns 1 if a and b are equal ignoring ASCII case.
static b32 str8_ends_with(String8 str, String8 suffix)
Returns 1 if str ends with suffix.
static String8 str8_chop(String8 str, usize amt)
Returns str with the last amt bytes removed.
static String8 str8_range(u8 *first, u8 *one_past_last)
Creates a String8 spanning from first to one_past_last.
static String8 str8_substr(String8 str, usize first, usize one_past_last)
Returns the substring from byte index first to one_past_last.
static void str8_list_push(String8List *list, String8Node *node, String8 str)
Appends a String8 to a String8List via a caller-allocated node.
static b32 str8_match(String8 a, String8 b)
Returns 1 if a and b contain identical bytes (case-sensitive).
static String8 str8_prefix(String8 str, usize size)
Returns the first size bytes of str.
static usize str8_find_first(String8 str, u8 byte)
Returns the byte index of the first occurrence of byte in str.
#define MIN(a, b)
Returns the minimum of two values (Standard C fallback).
A sized UTF-8 string slice.
A singly-linked list of String8 slices.
A node for building singly-linked lists of strings.
struct String8Node * next