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.
Parameters
| Name | Direction | Description |
|---|---|---|
mi |
in | Pointer to the StrIter whose backing region is addressed. |
idx |
in | Absolute index into the backing region; idx == length yields the well-defined one-past-end pointer. |
Success
Returns a pointer to the character at absolute index idx.
Failure
Macro cannot fail. Passing idx > length addresses past the end of the region (a usage error).
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:2665:
LOG_ERROR("Failed to parse f64: empty input");
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:2675:
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);- In
Io.c:2688:
StrDeinit(&temp);
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}
StrDeinit(&temp);- In
Io.c:2736:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2778:
LOG_ERROR("Failed to parse u8: empty input");
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:2782:
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;- In
Io.c:2797:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2897:
LOG_ERROR("Failed to parse " #NAME ": empty input"); \
DefaultAllocatorDeinit(&scratch); \
return StrIterDataAt(&si, StrIterIndex(&si)); \
} \
\
- In
Io.c:2908:
} \
\
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved)); \
size pos = StrIterIndex(&si) - StrIterIndex(&saved); \
Str temp = StrInitFromCstr(start, pos, &scratch); \
- In
Io.c:3194:
if (!StrIterRemainingLength(&si)) {
LOG_ERROR("Empty input string");
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3197:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
char c0 = 0;- In
Io.c:3221:
Str hex_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&hex_saved)),
StrIterIndex(&si) - StrIterIndex(&hex_saved),
BitVecAllocator(bv)- In
Io.c:3242:
*bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
StrDeinit(&hex_str);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3262:
Str oct_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&oct_saved)),
StrIterIndex(&si) - StrIterIndex(&oct_saved),
BitVecAllocator(bv)- In
Io.c:3280:
*bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
StrDeinit(&oct_str);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3296:
Str bin_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&bin_saved)),
StrIterIndex(&si) - StrIterIndex(&bin_saved),
BitVecAllocator(bv)- In
Io.c:3304:
StrDeinit(&bin_str);
return StrIterDataAt(&si, StrIterIndex(&si));
}
#endif // FEATURE_BITVEC
- In
Io.c:3330:
if (!StrIterRemainingLength(&si)) {
LOG_ERROR("Failed to parse Int: empty input");
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3335:
StrIter saved = si;
StrIter digits_saved = si;
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
u8 radix = int_fmt_radix_from_flags(fmt_info);- In
Io.c:3391:
StrDeinit(&temp);
return StrIterDataAt(&si, StrIterIndex(&si));
}
#endif // FEATURE_INT
- In
Io.c:3429:
StrDeinit(&temp);
FloatDeinit(&parsed);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3432:
}
start = StrIterDataAt(&si, StrIterIndex(&si));
token_len = float_fmt_token_length(start);- In
Io.c:3484:
LOG_ERROR("Failed to parse f32: empty input");
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3494:
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);- In
Io.c:3509:
StrDeinit(&temp);
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}
StrDeinit(&temp);- In
Io.c:3554:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Dns.c:188:
// 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) {- In
Dns.c:217:
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) {- In
Dns.c:274:
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);- In
Dns.c:286:
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};- In
Dns.c:54:
return false;
}
if (!BufPushBytes(out, (const u8 *)StrIterDataAt(&si, seg_start), seg_len)) {
return false;
}- In
ProcMaps.c:152:
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') {- In
ProcMaps.c:154:
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
- In
ProcMaps.c:159:
// `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);
}- In
JSON.c:400:
if (!StrLen(&ns)) {
LOG_ERROR("Failed to parse number. '{.8}'", LVAL(StrIterDataAt(&saved_si, StrIterIndex(&saved_si))));
StrDeinit(&ns);
DefaultAllocatorDeinit(&scratch);- In
StrIter.c:115:
bool test_striter_data_at_bounds(void) {
StrIter si = StrIterFromZstr("abc");
if (*StrIterDataAt(&si, 0) != 'a') {
return false;
}- In
StrIter.c:118:
return false;
}
if (*StrIterDataAt(&si, 2) != 'c') {
return false;
}- In
StrIter.c:122:
}
// The one-past-end pointer equals begin + length.
return StrIterDataAt(&si, 3) == StrIterDataAt(&si, 0) + 3;
}
Last updated on