cbase 1.50.0
C/C++ Static Template
Loading...
Searching...
No Matches
String Operations

Functions

static String8 str8 (u8 *str, usize size)
 Creates a String8 from a raw pointer and explicit byte length.
static String8 str8_range (u8 *first, u8 *one_past_last)
 Creates a String8 spanning from first to one_past_last.
static String8 str8_cstr (const char *cstr)
 Converts a null-terminated C string into a String8.
static String8 str8_prefix (String8 str, usize size)
 Returns the first size bytes of str.
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 String8 str8_chop (String8 str, usize amt)
 Returns str with the last amt bytes removed.
static String8 str8_substr (String8 str, usize first, usize one_past_last)
 Returns the substring from byte index first to one_past_last.
static b32 str8_match (String8 a, String8 b)
 Returns 1 if a and b contain identical bytes (case-sensitive).
static b32 str8_match_nocase (String8 a, String8 b)
 Returns 1 if a and b are equal ignoring ASCII case.
static b32 str8_starts_with (String8 str, String8 prefix)
 Returns 1 if str begins with prefix.
static b32 str8_ends_with (String8 str, String8 suffix)
 Returns 1 if str ends with suffix.
static usize str8_find_first (String8 str, u8 byte)
 Returns the byte index of the first occurrence of byte in str.
static void str8_list_push (String8List *list, String8Node *node, String8 str)
 Appends a String8 to a String8List via a caller-allocated node.

Detailed Description

Function Documentation

◆ str8()

String8 str8 ( u8 * str,
usize size )
inlinestatic

Creates a String8 from a raw pointer and explicit byte length.

Parameters
strPointer to the start of the string data.
sizeLength in bytes.
Returns
A String8 view over the given range.

Definition at line 133 of file base_strings.h.

Here is the caller graph for this function:

◆ str8_chop()

String8 str8_chop ( String8 str,
usize amt )
inlinestatic

Returns str with the last amt bytes removed.

Parameters
strThe source string.
amtNumber of bytes to remove from the back.
Returns
A String8 ending amt bytes before the original end.

Definition at line 210 of file base_strings.h.

Here is the call graph for this function:

◆ str8_cstr()

String8 str8_cstr ( const char * cstr)
inlinestatic

Converts a null-terminated C string into a String8.

Parameters
cstrNull-terminated C string, or NULL.
Returns
A String8 view over the C string data.

Definition at line 158 of file base_strings.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str8_ends_with()

b32 str8_ends_with ( String8 str,
String8 suffix )
inlinestatic

Returns 1 if str ends with suffix.

Parameters
strThe string to test.
suffixThe suffix to look for.
Returns
1 if str ends with suffix, 0 otherwise.

Definition at line 289 of file base_strings.h.

Here is the call graph for this function:

◆ str8_find_first()

usize str8_find_first ( String8 str,
u8 byte )
inlinestatic

Returns the byte index of the first occurrence of byte in str.

Parameters
strThe string to search.
byteThe byte value to find.
Returns
Index of the first match, or str.size if not found.

Definition at line 304 of file base_strings.h.

◆ str8_list_push()

void str8_list_push ( String8List * list,
String8Node * node,
String8 str )
inlinestatic

Appends a String8 to a String8List via a caller-allocated node.

Parameters
listThe list to append to.
nodeA caller-allocated node to link into the list.
strThe string slice to store in the node.

Definition at line 321 of file base_strings.h.

◆ str8_match()

b32 str8_match ( String8 a,
String8 b )
inlinestatic

Returns 1 if a and b contain identical bytes (case-sensitive).

Parameters
aFirst string.
bSecond string.
Returns
1 if equal, 0 if not.

Definition at line 239 of file base_strings.h.

Here is the caller graph for this function:

◆ str8_match_nocase()

b32 str8_match_nocase ( String8 a,
String8 b )
inlinestatic

Returns 1 if a and b are equal ignoring ASCII case.

Parameters
aFirst string.
bSecond string.
Returns
1 if equal ignoring ASCII case, 0 if not.

Definition at line 254 of file base_strings.h.

◆ str8_prefix()

String8 str8_prefix ( String8 str,
usize size )
inlinestatic

Returns the first size bytes of str.

Parameters
strThe source string.
sizeNumber of bytes to keep from the front.
Returns
A String8 slice of at most size bytes.

Definition at line 171 of file base_strings.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str8_range()

String8 str8_range ( u8 * first,
u8 * one_past_last )
inlinestatic

Creates a String8 spanning from first to one_past_last.

Parameters
firstPointer to the first byte of the slice.
one_past_lastPointer one byte past the last byte of the slice.
Returns
A String8 covering [first, one_past_last).

Definition at line 146 of file base_strings.h.

◆ str8_skip()

String8 str8_skip ( String8 str,
usize amt )
inlinestatic

Returns str with the first amt bytes removed.

Parameters
strThe source string.
amtNumber of bytes to skip from the front.
Returns
A String8 starting amt bytes into str.

Definition at line 197 of file base_strings.h.

Here is the call graph for this function:

◆ str8_starts_with()

b32 str8_starts_with ( String8 str,
String8 prefix )
inlinestatic

Returns 1 if str begins with prefix.

Parameters
strThe string to test.
prefixThe prefix to look for.
Returns
1 if str starts with prefix, 0 otherwise.

Definition at line 274 of file base_strings.h.

Here is the call graph for this function:

◆ str8_substr()

String8 str8_substr ( String8 str,
usize first,
usize one_past_last )
inlinestatic

Returns the substring from byte index first to one_past_last.

Parameters
strThe source string.
firstIndex of the first byte to include.
one_past_lastIndex one past the last byte to include.
Returns
A String8 slice covering [first, one_past_last).

Definition at line 224 of file base_strings.h.

Here is the call graph for this function:

◆ str8_suffix()

String8 str8_suffix ( String8 str,
usize size )
inlinestatic

Returns the last size bytes of str.

Parameters
strThe source string.
sizeNumber of bytes to keep from the back.
Returns
A String8 slice of at most size bytes from the end.

Definition at line 184 of file base_strings.h.

Here is the call graph for this function:
Here is the caller graph for this function: