StrForeachInRange
Description
Walk characters of str in the half-open range [start, end), binding chr to the current character value. Convenience wrapper around StrForeachInRangeIdx with an internally-managed index. See VecForeachInRange for the full SUCCESS/FAILURE contract.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:1815:
}
} else {
StrForeachInRange(s, c, 0, len) {
if (IS_PRINTABLE(c)) {
if (!StrPushBackR(o, c)) {- In
Foreach.c:314:
// Test StrForeachInRange macro
bool test_str_foreach_in_range(void) {
WriteFmt("Testing StrForeachInRange\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Foreach.c:322:
// Build a new string by iterating through a range of characters
Str result = StrInit(&alloc);
StrForeachInRange(&s, chr, 0, 5) {
// Append the character to the result string
StrPushBackR(&result, chr);- In
Foreach.c:332:
// Test with range at the end of the string
Str end_result = StrInit(&alloc);
StrForeachInRange(&s, chr, 6, 11) {
// Append the character to the result string
StrPushBackR(&end_result, chr);
Last updated on