StrIterFromZstr
Description
Construct a forward-walking StrIter over a NUL-terminated Zstr. Alias-reframe of the IterInitFromVec shape: length is taken from ZstrLen(s), alignment is fixed at 1. See IterInitFromVec for the overall borrowed-data semantics.
Parameters
| Name | Direction | Description |
|---|---|---|
s |
in | NUL-terminated string. Must outlive the iterator. |
Success
Returns a compound-literal StrIter covering [s, s + ZstrLen(s)) with pos = 0, dir = 1. The NUL terminator is not part of the iterated range.
Failure
Macro cannot fail. Passing a non-NUL-terminated buffer is a usage error – ZstrLen would run past the end.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ArgParse.c:80:
if (!s || !*s)
return false;
StrIter si = StrIterFromZstr(s);
u64 v = 0;
char c;- In
Io.c:819:
BufIter start = *iter;
u64 arg_index = 0;
StrIter fsi = StrIterFromZstr(fmtstr);
char fc = 0;- In
Io.c:1023:
static bool render_binary_fmt(Str *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
u64 arg_index = 0;
StrIter fsi = StrIterFromZstr(fmtstr);
char fc = 0;
while (StrIterPeek(&fsi, &fc)) {- In
Io.c:2655:
}
StrIter si = StrIterFromZstr(i);
char c = 0;- In
Io.c:2768:
}
StrIter si = StrIterFromZstr(i);
char c = 0;- In
Io.c:2887:
} \
\
StrIter si = StrIterFromZstr(i); \
char c = 0; \
\
- In
Io.c:3185:
ValidateBitVec(bv);
StrIter si = StrIterFromZstr(i);
char c = 0;- In
Io.c:3321:
ValidateInt(value);
StrIter si = StrIterFromZstr(i);
char c = 0;- In
Io.c:3418:
ValidateFloat(value);
StrIter si = StrIterFromZstr(i);
char c = 0;- In
Io.c:3474:
}
StrIter si = StrIterFromZstr(i);
char c = 0;- In
Dns.c:26:
return false;
}
StrIter si = StrIterFromZstr(name);
u64 total_bytes = 0;
char c; size aug_end_pos = IterIndex(body) + aug_len;
StrIter aug_it = StrIterFromZstr(augmentation + 1);
char a;
while (StrIterRead(&aug_it, &a)) {- In
StrIter.c:10:
// the iterator walks exactly the visible characters, alignment 1, forward.
bool test_striter_from_zstr_length_and_read(void) {
StrIter si = StrIterFromZstr("abc");
if (StrIterRemainingLength(&si) != 3) {
return false;- In
StrIter.c:48:
// StrIterPeek reads the current character without advancing the cursor.
bool test_striter_peek_does_not_advance(void) {
StrIter si = StrIterFromZstr("xy");
char c = 0;
if (!StrIterPeek(&si, &c) || c != 'x') {- In
StrIter.c:59:
// advancing. On a forward iter that is the byte after the cursor.
bool test_striter_peek_next_forward(void) {
StrIter si = StrIterFromZstr("abc");
char c = 0;
if (!StrIterPeekNext(&si, &c) || c != 'b') {- In
StrIter.c:69:
// StrIterPeekPrev looks one character behind in iteration order.
bool test_striter_peek_prev_forward(void) {
StrIter si = StrIterFromZstr("abc");
StrIterMustNext(&si); // -> 'b'
char c = 0;- In
StrIter.c:81:
// *out untouched.
bool test_striter_peek_next_at_last_fails(void) {
StrIter si = StrIterFromZstr("ab");
StrIterMustNext(&si); // -> 'b' (last)
char c = 0x7F;- In
StrIter.c:93:
// *out untouched.
bool test_striter_peek_prev_at_first_fails(void) {
StrIter si = StrIterFromZstr("ab");
char c = 0x7F;
if (StrIterPeekPrev(&si, &c)) {- In
StrIter.c:104:
// advancing the cursor.
bool test_striter_peek_at_offset(void) {
StrIter si = StrIterFromZstr("abcd");
char c = 0;
if (!StrIterPeekAt(&si, 2, &c) || c != 'c') {- In
StrIter.c:114:
// StrIterDataAt is index-addressed and well-defined one past the end.
bool test_striter_data_at_bounds(void) {
StrIter si = StrIterFromZstr("abc");
if (*StrIterDataAt(&si, 0) != 'a') {
return false;
Last updated on