StrSplitToIters

Table of Contents

StrSplitToIters

Description

Split given string into multiple StrIter into the same string. This way the split operation can be performed without creating new strings, but instead just having an iterated view into the Str object. This is best used when user never needs to make modifications and save the modifications. In other words, best used when only need iteration over string with some delimiters.

Parameters

NameDirectionDescription
strinStr object to split
keyinZero-terminated char pointer value to split based on

Success

StrIters vector of non-zero length

Failure

StrIters vector of zero-length

Usage example (Cross-references)

    }
    
    StrIters StrSplitToIters(Str* s, const char* key) {
    ValidateStr(s);
    // Test string split functions
    bool test_str_split(void) {
    printf("Testing StrSplit and StrSplitToIters\n");
    
    // Test StrSplit
    
    // Test StrSplitToIters
    StrIters iters = StrSplitToIters(&s, ",");
    result         = result && (iters.length == 3);

Share :