Skip to content

StrIterDataAt

Description

Pointer to the character at absolute index idx in the StrIter’s backing region. Alias-reframe of IterDataAt in string vocabulary; the one-past-end pointer at idx == length is the standard half-open-range upper bound and is well-defined. See IterDataAt for the full contract.

Usage example (Cross-references)

Usage examples (Cross-references)
            LOG_ERROR("Failed to parse f64: empty input");
            DefaultAllocatorDeinit(&scratch);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
        if ((c == 'i' || c == 'I' || c == 'n' || c == 'N') || (c == '-' && (c1 == 'i' || c1 == 'I'))) {
            StrIter saved = si;
            Zstr    start = StrIterDataAt(&si, StrIterIndex(&si));
            while (StrIterPeek(&si, &c) && !IS_SPACE(c)) {
                StrIterMustNext(&si);
                StrDeinit(&temp);
                DefaultAllocatorDeinit(&scratch);
                return StrIterDataAt(&si, StrIterIndex(&si));
            }
            StrDeinit(&temp);
        }
    
        Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
        size pos   = StrIterIndex(&si) - StrIterIndex(&saved);
            LOG_ERROR("Failed to parse u8: empty input");
            DefaultAllocatorDeinit(&scratch);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
    
        if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) {
            Zstr next = read_chars_internal(StrIterDataAt(&si, StrIterIndex(&si)), (u8 *)v, sizeof(*v), fmt_info);
            DefaultAllocatorDeinit(&scratch);
            return next;
        }
    
        Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
        size pos   = StrIterIndex(&si) - StrIterIndex(&saved);
                LOG_ERROR("Failed to parse " #NAME ": empty input");                                                       \
                DefaultAllocatorDeinit(&scratch);                                                                          \
                return StrIterDataAt(&si, StrIterIndex(&si));                                                              \
            }                                                                                                              \
                                                                                                                           \
            }                                                                                                              \
                                                                                                                           \
            Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));                                                         \
            size pos   = StrIterIndex(&si) - StrIterIndex(&saved);                                                         \
            Str  temp  = StrInitFromCstr(start, pos, &scratch);                                                            \
        if (!StrIterRemainingLength(&si)) {
            LOG_ERROR("Empty input string");
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
        }
    
        Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
    
        char c0 = 0;
    
            Str hex_str = StrInitFromCstr(
                StrIterDataAt(&si, StrIterIndex(&hex_saved)),
                StrIterIndex(&si) - StrIterIndex(&hex_saved),
                BitVecAllocator(bv)
            *bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
            StrDeinit(&hex_str);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
    
            Str oct_str = StrInitFromCstr(
                StrIterDataAt(&si, StrIterIndex(&oct_saved)),
                StrIterIndex(&si) - StrIterIndex(&oct_saved),
                BitVecAllocator(bv)
            *bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
            StrDeinit(&oct_str);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
    
        Str bin_str = StrInitFromCstr(
            StrIterDataAt(&si, StrIterIndex(&bin_saved)),
            StrIterIndex(&si) - StrIterIndex(&bin_saved),
            BitVecAllocator(bv)
    
        StrDeinit(&bin_str);
        return StrIterDataAt(&si, StrIterIndex(&si));
    }
    #endif // FEATURE_BITVEC
        if (!StrIterRemainingLength(&si)) {
            LOG_ERROR("Failed to parse Int: empty input");
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
        StrIter saved        = si;
        StrIter digits_saved = si;
        Zstr    start        = StrIterDataAt(&si, StrIterIndex(&saved));
        u8      radix        = int_fmt_radix_from_flags(fmt_info);
    
        StrDeinit(&temp);
        return StrIterDataAt(&si, StrIterIndex(&si));
    }
    #endif // FEATURE_INT
            StrDeinit(&temp);
            FloatDeinit(&parsed);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
        }
    
        start     = StrIterDataAt(&si, StrIterIndex(&si));
        token_len = float_fmt_token_length(start);
            LOG_ERROR("Failed to parse f32: empty input");
            DefaultAllocatorDeinit(&scratch);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
        if ((c == 'i' || c == 'I' || c == 'n' || c == 'N') || (c == '-' && (c1 == 'i' || c1 == 'I'))) {
            StrIter saved = si;
            Zstr    start = StrIterDataAt(&si, StrIterIndex(&si));
            while (StrIterPeek(&si, &c) && !IS_SPACE(c)) {
                StrIterMustNext(&si);
                StrDeinit(&temp);
                DefaultAllocatorDeinit(&scratch);
                return StrIterDataAt(&si, StrIterIndex(&si));
            }
            StrDeinit(&temp);
        }
    
        Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
        size pos   = StrIterIndex(&si) - StrIterIndex(&saved);
        out->perms       = perms;
        out->file_offset = offset;
        out->path        = (Zstr)StrIterDataAt(si, path_start_pos); // may be empty if anonymous
    
        if (line_terminator_pos < StrIterLength(si) && *StrIterDataAt(si, line_terminator_pos) == '\n') {
        out->path        = (Zstr)StrIterDataAt(si, path_start_pos); // may be empty if anonymous
    
        if (line_terminator_pos < StrIterLength(si) && *StrIterDataAt(si, line_terminator_pos) == '\n') {
            // intentional bypass: in-place mutation of the iter's backing
            // buffer to NUL-terminate the path slice we just exposed via
            // `out->path`. Iter accessors are read-only; no public mutator
            // covers single-byte writes to the underlying storage.
            *StrIterDataAt(si, line_terminator_pos) = '\0';
            StrIterMustNext(si);
        }
                // the longest reasonable IPv6-with-zone-id literal.
                StrInitStack(ip_buf, 64) {
                    StrPushBackMany(&ip_buf, (Zstr)StrIterDataAt(&si, ip_start), ip_len);
                    got_v4 = parse_ipv4(StrBegin(&ip_buf), v4);
                    if (!got_v4) {
    
                HostsEntry e = {0};
                e.name       = StrInitFromCstr((Zstr)StrIterDataAt(&si, nm_start), nm_len, alloc);
                ascii_lower((u8 *)StrBegin(&e.name), StrLen(&e.name));
                if (got_v4) {
            char sep;
            if (StrIterRemainingLength(&si) > kw_len &&
                MemCompare(StrIterDataAt(&si, StrIterIndex(&si)), NS_KEYWORD, kw_len) == 0 &&
                StrIterPeekAt(&si, (i64)kw_len, &sep) && (sep == ' ' || sep == '\t')) {
                StrIterMustMove(&si, (i64)kw_len);
                if (ip_len > 0 && ip_len < 64) {
                    StrInitStack(ip_buf, 64) {
                        StrPushBackMany(&ip_buf, (Zstr)StrIterDataAt(&si, ip_start), ip_len);
                        u8 v4[4]  = {0};
                        u8 v6[16] = {0};
                                LOG_ERROR(
                                    "No unicode support '{.6}'. Unicode sequence will be skipped.",
                                    LVAL(StrIterDataAt(&si, StrIterIndex(&si) - 1))
                                );
                                StrIterMustMove(&si, 5);
    
        if (!StrLen(&ns)) {
            LOG_ERROR("Failed to parse number. '{.8}'", LVAL(StrIterDataAt(&saved_si, StrIterIndex(&saved_si))));
            StrDeinit(&ns);
            DefaultAllocatorDeinit(&scratch);
                return false;
            }
            if (!BufPushBytes(out, (const u8 *)StrIterDataAt(&si, seg_start), seg_len)) {
                return false;
            }
Last updated on