Skip to content
StrSplitToIters

StrSplitToIters

Description

Split s into a vector of StrIter views over the original s buffer, delimited by key. No new strings are allocated – each iterator borrows a slice of s. Best used when the caller only needs to iterate the pieces without mutating them.

Two call shapes via _Generic on key: StrSplitToIters(s, key)key is Str * or Zstr.

Parameters

Name Direction Description
s in Str to split.
key in Delimiter (Str * / Zstr).

Success

Returns a non-empty StrIters vector whose entries view slices of s. Caller owns the vector and must VecDeinit it. s is not modified.

Failure

Returns a zero-length StrIters vector. s is not modified.

Usage example (Cross-references)

Usage examples (Cross-references)
    // Test string split functions
    bool test_str_split(void) {
        WriteFmt("Testing StrSplit and StrSplitToIters\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        // Test StrSplitToIters
        StrIters iters = StrSplitToIters(&s, ",");
        result         = result && (VecLen(&iters) == 3);
Last updated on