StrIterIndex
Description
Absolute cursor index within the StrIter’s backing region. Alias- reframe of IterIndex in string vocabulary. See IterIndex for the full contract.
Parameters
| Name | Direction | Description |
|---|---|---|
mi |
in | Pointer to the StrIter to query. |
Success
Returns the absolute cursor index within the backing region.
Failure
Macro cannot fail.
Usage example (Cross-references)
Usage examples (Cross-references)
- 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); \
- 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:2680:
}
Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
// Special-value tokens (`inf`, `nan`, ...) carry through the
- In
Io.c:2688:
StrDeinit(&temp);
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}
StrDeinit(&temp);- In
Io.c:2711:
// 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:2729:
}
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), true)) {
break;
}- In
Io.c:2736:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2737:
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);- 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:2790:
while (StrIterPeek(&si, &c)) {
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), false)) {
break;
}- In
Io.c:2797:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2798:
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);- In
Io.c:2897:
LOG_ERROR("Failed to parse " #NAME ": empty input"); \
DefaultAllocatorDeinit(&scratch); \
return StrIterDataAt(&si, StrIterIndex(&si)); \
} \
\
- In
Io.c:2902:
StrIter saved = si; \
while (StrIterPeek(&si, &c)) { \
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), false)) { \
break; \
} \
- 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:2909:
\
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:3215:
}
if (StrIterIndex(&si) == StrIterIndex(&hex_saved)) {
LOG_ERROR("Invalid hex format - no digits after 0x");
return start;- In
Io.c:3221:
Str hex_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&hex_saved)),
StrIterIndex(&si) - StrIterIndex(&hex_saved),
BitVecAllocator(bv)- In
Io.c:3222:
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:3256:
}
if (StrIterIndex(&si) == StrIterIndex(&oct_saved)) {
LOG_ERROR("Invalid octal format - no digits after 0o");
return start;- In
Io.c:3262:
Str oct_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&oct_saved)),
StrIterIndex(&si) - StrIterIndex(&oct_saved),
BitVecAllocator(bv)- In
Io.c:3263:
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:3290:
}
if (StrIterIndex(&si) == StrIterIndex(&bin_saved)) {
LOG_ERROR("Invalid binary format - expected 0s and 1s");
return start;- In
Io.c:3296:
Str bin_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&bin_saved)),
StrIterIndex(&si) - StrIterIndex(&bin_saved),
BitVecAllocator(bv)- In
Io.c:3297:
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:3367:
}
if (StrIterIndex(&si) == StrIterIndex(&digits_saved)) {
LOG_ERROR("Failed to parse Int");
return start;- In
Io.c:3378:
}
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: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:3499:
}
Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
// Special-value tokens (`inf`, `nan`, ...) carry through the
- In
Io.c:3509:
StrDeinit(&temp);
DefaultAllocatorDeinit(&scratch);
return StrIterDataAt(&si, StrIterIndex(&si));
}
StrDeinit(&temp);- In
Io.c:3529:
// 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:3547:
}
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), true)) {
break;
}- In
Io.c:3554:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:3555:
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);- In
Dns.c:173:
// First token: IP literal.
size ip_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n') {
StrIterMustNext(&si);- In
Dns.c:177:
StrIterMustNext(&si);
}
u64 ip_len = (u64)(StrIterIndex(&si) - ip_start);
bool got_v4 = false;- In
Dns.c:207:
break;
}
size nm_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n' && c != '#') {
StrIterMustNext(&si);- In
Dns.c:211:
StrIterMustNext(&si);
}
u64 nm_len = (u64)(StrIterIndex(&si) - nm_start);
if (nm_len == 0) {
break;- 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:279:
skip_hspace_iter(&si);
size ip_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n' && c != '#') {
StrIterMustNext(&si);- In
Dns.c:283:
StrIterMustNext(&si);
}
u64 ip_len = (u64)(StrIterIndex(&si) - ip_start);
if (ip_len > 0 && ip_len < 64) {
StrInitStack(ip_buf, 64) {- 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
- In
KvConfig.c:230:
si = KvConfigReadKey(si, key);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
return saved_si;
}- In
KvConfig.c:247:
si = KvConfigReadValue(si, value);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
StrClear(key);
StrClear(value);- In
KvConfig.c:319:
read_si = KvConfigReadPair(si, &key, &value);
if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
StrDeinit(&key);
StrDeinit(&value);- 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
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:400:
if (!StrLen(&ns)) {
LOG_ERROR("Failed to parse number. '{.8}'", LVAL(StrIterDataAt(&saved_si, StrIterIndex(&saved_si))));
StrDeinit(&ns);
DefaultAllocatorDeinit(&scratch);- In
JSON.c:454:
si = JReadNumber(si, &num);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
LOG_ERROR("Failed to parse integer number.");
return saved_si;- In
JSON.c:482:
si = JReadNumber(si, &num);
if (StrIterIndex(&si) == StrIterIndex(&saved_si)) {
LOG_ERROR("Failed to parse floating point number");
return saved_si;- In
JSON.c:601:
si = JReadBool(si, &b);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR(
"Failed to read boolean value. Expected true/false. Invalid "- In
JSON.c:618:
si = JReadNull(si, &n);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR(
"Failed to read boolean value. Expected true/false. Invalid "- In
JSON.c:642:
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:656:
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:669:
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:682:
si = JSkipArray(si);
if (StrIterIndex(&si) == StrIterIndex(&before_si)) {
LOG_ERROR("Failed to read array. Expected an array. Invalid JSON.");
return saved_si;- In
StrIter.c:53:
return false;
}
return StrIterIndex(&si) == 0;
}- In
StrIter.c:64:
return false;
}
return StrIterIndex(&si) == 0;
}- In
StrIter.c:75:
return false;
}
return StrIterIndex(&si) == 1;
}- In
StrIter.c:109:
return false;
}
return StrIterIndex(&si) == 0;
} 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); \
bool b = true;
StrIter out = JReadBool(si, &b);
if (StrIterIndex(&out) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadBool advanced on malformed 'tru3'");
success = false; bool b = true;
StrIter out = JReadBool(si, &b);
if (StrIterIndex(&out) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadBool advanced on malformed 'fXlse'");
success = false; bool b = true;
StrIter out = JReadBool(si, &b);
if (StrIterIndex(&out) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadBool advanced on too-short 'tr'");
success = false; bool is_null = true;
StrIter out = JReadNull(si, &is_null);
if (StrIterIndex(&out) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadNull advanced on malformed 'nuXX'");
success = false; StrIter out = JReadBool(si, &b);
// value correct and exactly 4 bytes consumed
if (!(b == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadBool 'true' value/advance wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false; // value correct and exactly 4 bytes consumed
if (!(b == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadBool 'true' value/advance wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false;
} bool b = true;
StrIter out = JReadBool(si, &b);
if (!(b == false && StrIterIndex(&out) == 5)) {
WriteFmtLn("[DEBUG] JReadBool 'false' value/advance wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false; StrIter out = JReadBool(si, &b);
if (!(b == false && StrIterIndex(&out) == 5)) {
WriteFmtLn("[DEBUG] JReadBool 'false' value/advance wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false;
} bool is_null = false;
StrIter out = JReadNull(si, &is_null);
if (!(is_null == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadNull 'null' value/advance wrong: n={}, idx={}", is_null, StrIterIndex(&out));
success = false; StrIter out = JReadNull(si, &is_null);
if (!(is_null == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadNull 'null' value/advance wrong: n={}, idx={}", is_null, StrIterIndex(&out));
success = false;
} bool b = false;
StrIter out = JReadBool(si, &b);
if (!(b == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadBool exact 'true' wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false; StrIter out = JReadBool(si, &b);
if (!(b == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadBool exact 'true' wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false;
} bool b = true;
StrIter out = JReadBool(si, &b);
if (!(b == false && StrIterIndex(&out) == 5)) {
WriteFmtLn("[DEBUG] JReadBool exact 'false' wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false; StrIter out = JReadBool(si, &b);
if (!(b == false && StrIterIndex(&out) == 5)) {
WriteFmtLn("[DEBUG] JReadBool exact 'false' wrong: b={}, idx={}", b, StrIterIndex(&out));
success = false;
} bool is_null = false;
StrIter out = JReadNull(si, &is_null);
if (!(is_null == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadNull exact 'null' wrong: n={}, idx={}", is_null, StrIterIndex(&out));
success = false; StrIter out = JReadNull(si, &is_null);
if (!(is_null == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadNull exact 'null' wrong: n={}, idx={}", is_null, StrIterIndex(&out));
success = false;
} StrIter r = JReadString(si, &out);
// Truncated escape -> failure -> iterator unchanged.
if (StrIterIndex(&r) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadString advanced on truncated escape case {}", i);
success = false; Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadString accepted a complete \\u escape (should reject): idx={}", StrIterIndex(&r));
success = false; StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadString accepted a complete \\u escape (should reject): idx={}", StrIterIndex(&r));
success = false;
} Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) == StrIterIndex(&si) || StrIterIndex(&r) != StrIterLength(&r)) {
WriteFmtLn("[DEBUG] JReadString failed on a plain string: idx={}", StrIterIndex(&r));
success = false; StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) == StrIterIndex(&si) || StrIterIndex(&r) != StrIterLength(&r)) {
WriteFmtLn("[DEBUG] JReadString failed on a plain string: idx={}", StrIterIndex(&r));
success = false;
} success = false;
}
if (StrIterIndex(&si) != StrIterLength(&si)) {
WriteFmtLn(
"[DEBUG] iterator did not consume whole object: idx={}, len={}", WriteFmtLn(
"[DEBUG] iterator did not consume whole object: idx={}, len={}",
StrIterIndex(&si),
StrIterLength(&si)
);
// On structural failure the macro restores si to its start.
if (StrIterIndex(&si) != 0) {
WriteFmtLn("[DEBUG] malformed object case {} did not rewind: idx={}", i, StrIterIndex(&si));
success = false; // On structural failure the macro restores si to its start.
if (StrIterIndex(&si) != 0) {
WriteFmtLn("[DEBUG] malformed object case {} did not rewind: idx={}", i, StrIterIndex(&si));
success = false;
} i64 v = 0;
StrIter out = JReadInteger(si, &v);
if (!(StrIterIndex(&out) != StrIterIndex(&si) && v == -12345)) {
WriteFmtLn("[DEBUG] JReadInteger '-12345' -> {}", v);
success = false; i64 v = 0;
StrIter out = JReadInteger(si, &v);
if (!(StrIterIndex(&out) != StrIterIndex(&si) && v == 12345)) {
WriteFmtLn("[DEBUG] JReadInteger '12345' -> {}", v);
success = false; f64 v = 0.0;
StrIter out = JReadFloat(si, &v);
if (!(StrIterIndex(&out) != StrIterIndex(&si) && v == -2.5)) {
WriteFmtLn("[DEBUG] JReadFloat '-2.5' -> {}", v);
success = false;
// Must advance (token consumed) and yield exactly 7.0 -- not 42.0.
if (StrIterIndex(&out) == StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadFloat did not advance on integer '7'");
success = false; StrIter out = JReadFloat(si, &val);
if (StrIterIndex(&out) == StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadFloat did not advance on integer '13'");
success = false;
// Malformed -> iterator rewinds (no advance).
if (StrIterIndex(&out) != StrIterIndex(&si)) {
WriteFmtLn("[DEBUG] JReadNull advanced on malformed 'nuII'");
success = false; StrIter out = JReadNull(si, &is_null);
if (!(is_null == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadNull 'null' value/advance wrong: n={}, idx={}", is_null, StrIterIndex(&out));
success = false;
if (!(is_null == true && StrIterIndex(&out) == 4)) {
WriteFmtLn("[DEBUG] JReadNull 'null' value/advance wrong: n={}, idx={}", is_null, StrIterIndex(&out));
success = false;
}- In
Parse.c:71:
// After skipping "xy" and the LF, the iterator sits on 'Z' at index 3.
result = result && (StrIterIndex(&si) == 3);
result = result && StrIterPeek(&si, &c) && (c == 'Z');- In
Parse.c:93:
// "a" then one LF consumed -> index 2, sitting on the second LF.
result = result && (StrIterIndex(&si) == 2);
result = result && StrIterPeek(&si, &c) && (c == '\n');- In
Parse.c:114:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 2);
result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);- In
Parse.c:205:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 2);
result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);- In
Parse.c:230:
// Parse must fail on the bad line -> iterator stays at origin and the
// key is not stored.
result = result && (StrIterIndex(&si) == 0);
result = result && !KvConfigContains(&cfg, "k");- In
Parse.c:252:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 1);
v = KvConfigGetPtr(&cfg, "k");- In
Parse.c:277:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 1);
v = KvConfigGetPtr(&cfg, "k");- In
Parse.c:299:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 1);
result = result && KvConfigContains(&cfg, "k");- In
Parse.c:325:
bool result = true;
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 3);
result = result && KvConfigContains(&cfg, "host");- In
Parse.c:359:
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:453:
bool result = true;
result = result && (StrIterIndex(&si) == 0);
result = result && KvConfigGetBool(&cfg, "valid", &enabled) && enabled;
result = result && !KvConfigContains(&cfg, "later");- In
Parse.c:612:
name = KvConfigGetPtr(&cfg, "name");
result = result && (StrIterIndex(&si) == StrIterLength(&si));
result = result && (MapPairCount(&cfg) == 3);
// The CR must not survive in the parsed value.
Last updated on