StrIterIndex
Description
Absolute cursor index within the StrIter’s backing region. Alias- reframe of IterIndex in string vocabulary. See IterIndex for the full contract.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:2531:
LOG_ERROR("Failed to parse f64: empty input");
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:2541:
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:2546:
}
Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
// Special-value tokens (`inf`, `nan`, ...) carry through the
- In
Io.c:2554:
StrDeinit(&temp);
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}
StrDeinit(&temp);- In
Io.c:2577:
// least one digit, otherwise rewind so the 'e' is left to the
// caller's tail (e.g. a unit suffix).
if ((c == 'e' || c == 'E') && StrIterIndex(&si) > StrIterIndex(&saved)) {
StrIterMustNext(&si);- In
Io.c:2595:
}
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), true)) {
break;
}- In
Io.c:2602:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2603:
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);- In
Io.c:2644:
LOG_ERROR("Failed to parse u8: empty input");
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:2648:
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:2656:
while (StrIterPeek(&si, &c)) {
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), false)) {
break;
}- In
Io.c:2663:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2664:
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);- In
Io.c:2763:
LOG_ERROR("Failed to parse " #NAME ": empty input"); \
DefaultAllocatorDeinit(&scratch); \
return StrIterDataAt(&si, StrIterIndex(&si)); \
} \
\
- In
Io.c:2768:
StrIter saved = si; \
while (StrIterPeek(&si, &c)) { \
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), false)) { \
break; \
} \
- In
Io.c:2774:
} \
\
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved)); \
size pos = StrIterIndex(&si) - StrIterIndex(&saved); \
Str temp = StrInitFromCstr(start, pos, &scratch); \
- In
Io.c:2775:
\
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved)); \
size pos = StrIterIndex(&si) - StrIterIndex(&saved); \
Str temp = StrInitFromCstr(start, pos, &scratch); \
\
- In
Io.c:3060:
if (!StrIterRemainingLength(&si)) {
LOG_ERROR("Empty input string");
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3063:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
char c0 = 0;- In
Io.c:3081:
}
if (StrIterIndex(&si) == StrIterIndex(&hex_saved)) {
LOG_ERROR("Invalid hex format - no digits after 0x");
return start;- In
Io.c:3087:
Str hex_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&hex_saved)),
StrIterIndex(&si) - StrIterIndex(&hex_saved),
BitVecAllocator(bv)- In
Io.c:3088:
Str hex_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&hex_saved)),
StrIterIndex(&si) - StrIterIndex(&hex_saved),
BitVecAllocator(bv)
);- In
Io.c:3108:
*bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
StrDeinit(&hex_str);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3122:
}
if (StrIterIndex(&si) == StrIterIndex(&oct_saved)) {
LOG_ERROR("Invalid octal format - no digits after 0o");
return start;- In
Io.c:3128:
Str oct_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&oct_saved)),
StrIterIndex(&si) - StrIterIndex(&oct_saved),
BitVecAllocator(bv)- In
Io.c:3129:
Str oct_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&oct_saved)),
StrIterIndex(&si) - StrIterIndex(&oct_saved),
BitVecAllocator(bv)
);- In
Io.c:3146:
*bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
StrDeinit(&oct_str);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3156:
}
if (StrIterIndex(&si) == StrIterIndex(&bin_saved)) {
LOG_ERROR("Invalid binary format - expected 0s and 1s");
return start;- In
Io.c:3162:
Str bin_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&bin_saved)),
StrIterIndex(&si) - StrIterIndex(&bin_saved),
BitVecAllocator(bv)- In
Io.c:3163:
Str bin_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&bin_saved)),
StrIterIndex(&si) - StrIterIndex(&bin_saved),
BitVecAllocator(bv)
);- In
Io.c:3170:
StrDeinit(&bin_str);
return StrIterDataAt(&si, StrIterIndex(&si));
}
#endif // FEATURE_BITVEC
- In
Io.c:3196:
if (!StrIterRemainingLength(&si)) {
LOG_ERROR("Failed to parse Int: empty input");
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3201:
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:3233:
}
if (StrIterIndex(&si) == StrIterIndex(&digits_saved)) {
LOG_ERROR("Failed to parse Int");
return start;- In
Io.c:3244:
}
Str temp = StrInitFromCstr(start, StrIterIndex(&si) - StrIterIndex(&saved), IntAllocator(value));
Int parsed = IntInit(IntAllocator(value));
bool ok = IntTryFromStrRadix(&parsed, StrBegin(&temp), radix);- In
Io.c:3257:
StrDeinit(&temp);
return StrIterDataAt(&si, StrIterIndex(&si));
}
#endif // FEATURE_INT
- In
Io.c:3295:
StrDeinit(&temp);
FloatDeinit(&parsed);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3298:
}
start = StrIterDataAt(&si, StrIterIndex(&si));
token_len = float_fmt_token_length(start);- In
Io.c:3350:
LOG_ERROR("Failed to parse f32: empty input");
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3360:
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:3365:
}
Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
// Special-value tokens (`inf`, `nan`, ...) carry through the
- In
Io.c:3375:
StrDeinit(&temp);
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}
StrDeinit(&temp);- In
Io.c:3395:
// least one digit, otherwise rewind so the 'e' is left to the
// caller's tail.
if ((c == 'e' || c == 'E') && StrIterIndex(&si) > StrIterIndex(&saved)) {
StrIterMustNext(&si);- In
Io.c:3413:
}
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), true)) {
break;
}- In
Io.c:3420:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:3421:
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);- In
ProcMaps.c:141:
// with \0 in place so the path is a usable C string aliasing the
// iter's backing buffer.
size path_start_pos = StrIterIndex(si);
char c;
while (StrIterPeek(si, &c) && c != '\n') {- In
ProcMaps.c:146:
StrIterMustNext(si);
}
size line_terminator_pos = StrIterIndex(si);
out->start = start;- In
Dns.c:295:
// First token: IP literal.
size ip_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n') {
StrIterMustNext(&si);- In
Dns.c:299:
StrIterMustNext(&si);
}
u64 ip_len = (u64)(StrIterIndex(&si) - ip_start);
bool got_v4 = false;- In
Dns.c:329:
break;
}
size nm_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n' && c != '#') {
StrIterMustNext(&si);- In
Dns.c:333:
StrIterMustNext(&si);
}
u64 nm_len = (u64)(StrIterIndex(&si) - nm_start);
if (nm_len == 0) {
break;- In
Dns.c:396:
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:401:
skip_hspace_iter(&si);
size ip_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n' && c != '#') {
StrIterMustNext(&si);- In
Dns.c:405:
StrIterMustNext(&si);
}
u64 ip_len = (u64)(StrIterIndex(&si) - ip_start);
if (ip_len > 0 && ip_len < 64) {
StrInitStack(ip_buf, 64) {- In
KvConfig.c:231:
si = KvConfigReadKey(si, key);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
return saved_si;
}- In
KvConfig.c:248:
si = KvConfigReadValue(si, value);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
StrClear(key);
StrClear(value);- In
KvConfig.c:320:
read_si = KvConfigReadPair(si, &key, &value);
if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
StrDeinit(&key);
StrDeinit(&value);- In
JSON.c:58:
// key start
read_si = JReadString(si, &key);
if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
LOG_ERROR("Failed to read string key in object. Invalid JSON");
StrDeinit(&key);- In
JSON.c:80:
// if still no advancement in read position
if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
LOG_ERROR("Failed to parse value. Invalid JSON.");
StrDeinit(&key);- In
JSON.c:142:
// if no advancement in read position
if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
LOG_ERROR("Failed to parse value. Invalid JSON.");
return saved_si;- In
JSON.c:275:
LOG_ERROR(
"No unicode support '{.6}'. Unicode sequence will be skipped.",
LVAL(StrIterDataAt(&si, StrIterIndex(&si) - 1))
);
StrIterMustMove(&si, 5);- In
JSON.c:403:
if (!StrLen(&ns)) {
LOG_ERROR("Failed to parse number. '{.8}'", LVAL(StrIterDataAt(&saved_si, StrIterIndex(&saved_si))));
StrDeinit(&ns);
DefaultAllocatorDeinit(&scratch);- In
JSON.c:457:
si = JReadNumber(si, &num);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
LOG_ERROR("Failed to parse integer number.");
return saved_si;- In
JSON.c:485:
si = JReadNumber(si, &num);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
LOG_ERROR("Failed to parse floating point number");
return saved_si;- In
JSON.c:604:
si = JReadBool(si, &b);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR(
"Failed to read boolean value. Expected true/false. Invalid "- In
JSON.c:621:
si = JReadNull(si, &n);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR(
"Failed to read boolean value. Expected true/false. Invalid "- In
JSON.c:645:
DefaultAllocatorDeinit(&scratch);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR("Failed to read string value. Expected string. Invalid JSON.");
return saved_si;- In
JSON.c:659:
si = JReadNumber(si, &num);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR("Failed to read number value. Expected a number. Invalid JSON.");
return saved_si;- In
JSON.c:672:
si = JSkipObject(si);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR("Failed to read object. Expected an object. Invalid JSON.");
return saved_si;- In
JSON.c:685:
si = JSkipArray(si);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR("Failed to read array. Expected an array. Invalid JSON.");
return saved_si;- In
Dns.c:31:
while (StrIterPeek(&si, &c)) {
// Find next dot or end-of-string.
size seg_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && c != '.') {
StrIterMustNext(&si);- In
Dns.c:35:
StrIterMustNext(&si);
}
u64 seg_len = (u64)(StrIterIndex(&si) - seg_start);
if (seg_len == 0) {
// Trailing dot at the end is valid (means root); leading or
Str key = StrInit(&alloc); \
UNPL(read_si) = JReadString(si, &key); \
if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) { \
LOG_ERROR("Failed to read string key in object. Invalid JSON"); \
StrDeinit(&key); \
StrIter UNPL(si_before_read) = si; \
{ reader } \
if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) { \
StrIter UNPL(skip_si) = JSkipValue(si); \
if (StrIterIndex(&UNPL(skip_si)) == StrIterIndex(&si)) { \
if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) { \
StrIter UNPL(skip_si) = JSkipValue(si); \
if (StrIterIndex(&UNPL(skip_si)) == StrIterIndex(&si)) { \
LOG_ERROR("Failed to parse value. Invalid JSON."); \
StrDeinit(&key); \
- In
Parse.c:23:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 3);
result = result && KvConfigContains(&cfg, "host");- In
Parse.c:57:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 4);
result = result && path && StrCmp(path, "/srv/my app") == 0;- In
Parse.c:151:
bool result = true;
result = result && (StrIterIndex(&si) == 0);
result = result && KvConfigGetBool(&cfg, "valid", &enabled) && enabled;
result = result && !KvConfigContains(&cfg, "later");- In
JSON.h:477:
\
/* if no advancement in read position */ \
if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) { \
/* skip the value */ \
StrIter UNPL(read_si) = JSkipValue(si); \
- In
JSON.h:482:
\
/* if still no advancement in read position */ \
if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) { \
LOG_ERROR("Failed to parse value. Invalid JSON."); \
UNPL(failed) = true; \
- In
JSON.h:574:
/* key start */ \
UNPL(read_si) = JReadString(si, &key); \
if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) { \
LOG_ERROR("Failed to read string key in object. Invalid JSON"); \
StrDeinit(&key); \
- In
JSON.h:602:
\
/* if no advancement in read position */ \
if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) { \
/* skip the value */ \
UNPL(read_si) = JSkipValue(si); \
- In
JSON.h:608:
\
/* if still no advancement in read position */ \
if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) { \
LOG_ERROR("Failed to parse value. Invalid JSON."); \
StrDeinit(&key); \
Last updated on