59#define STR8(s) ((String8){.str = (u8 *)(s), .size = sizeof(s) - 1})
69#define STR8_FMT(s) (int)(s).size, (char *)(s).str
94 String8 result = {first, (
usize)(one_past_last - first)};
107 result.
str = (
u8 *)cstr;
108 while (cstr[result.
size] !=
'\0') {
122 return str8(str.
str, clamped_size);
132 return str8(str.
str + clamped_amt, str.
size - clamped_amt);
143 usize final_first =
MIN(clamped_first, clamped_opl);
144 return str8(str.
str + final_first, clamped_opl - final_first);
Context detection, utilities, compiler abstractions, and data structures.
Core type definitions and fixed-width aliases.
#define function
File-scoped function (invisible to the linker).
static String8 str8(u8 *str, usize size)
Creates a String8 from a raw pointer and size.
static String8 str8_cstr(const char *cstr)
Converts a standard null-terminated C string into a String8.
static String8 str8_skip(String8 str, usize amt)
Returns a substring by skipping the first amt bytes of the input string.
static String8 str8_range(u8 *first, u8 *one_past_last)
Creates a String8 spanning from the first pointer to the one_past_last pointer.
static String8 str8_substr(String8 str, usize first, usize one_past_last)
Returns a substring spanning from first to one_past_last indices.
static b32 str8_match(String8 a, String8 b)
Checks if two String8s are exactly equal (case-sensitive).
static String8 str8_prefix(String8 str, usize size)
Returns a substring containing the first size bytes of the input string.
#define MIN(a, b)
Returns the minimum of two values (Standard C fallback).
A sized UTF-8 string slice.
A linked list of strings, useful for concatenating text without reallocation.
A node for a linked list of strings (String Builder).
struct String8Node * next