Skip to content

StrIterLength

Description

Total character length of the region the StrIter covers. Alias- reframe of IterLength in string vocabulary. See IterLength for the full contract.

Parameters

Name Direction Description
mi in Pointer to the StrIter to measure.

Success

Returns the total character length of the covered region.

Failure

Macro cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
        }
        // No digits consumed (cursor at entry) or trailing junk after digits.
        if (StrIterRemainingLength(&si) == StrIterLength(&si) || StrIterRemainingLength(&si) != 0)
            return false;
        if (v > hi)
        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
            StrIter *iter1       = VecPtrAt(&iters, 0);
            char     buffer1[10] = {0};
            MemCopy(buffer1, iter1->data, StrIterLength(iter1));
            result = result && (ZstrCompare(buffer1, "Hello") == 0);
            StrIter *iter2       = VecPtrAt(&iters, 1);
            char     buffer2[10] = {0};
            MemCopy(buffer2, iter2->data, StrIterLength(iter2));
            result = result && (ZstrCompare(buffer2, "World") == 0);
            StrIter *iter3       = VecPtrAt(&iters, 2);
            char     buffer3[10] = {0};
            MemCopy(buffer3, iter3->data, StrIterLength(iter3));
            result = result && (ZstrCompare(buffer3, "Test") == 0);
        }
        bool result = (VecLen(&iters) == 3);
        if (VecLen(&iters) == 3) {
            result = result && (StrIterLength(VecPtrAt(&iters, 0)) == 1);
            result = result && (StrIterLength(VecPtrAt(&iters, 1)) == 1);
            result = result && (StrIterLength(VecPtrAt(&iters, 2)) == 0);
        if (VecLen(&iters) == 3) {
            result = result && (StrIterLength(VecPtrAt(&iters, 0)) == 1);
            result = result && (StrIterLength(VecPtrAt(&iters, 1)) == 1);
            result = result && (StrIterLength(VecPtrAt(&iters, 2)) == 0);
        }
            result = result && (StrIterLength(VecPtrAt(&iters, 0)) == 1);
            result = result && (StrIterLength(VecPtrAt(&iters, 1)) == 1);
            result = result && (StrIterLength(VecPtrAt(&iters, 2)) == 0);
        }
            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;
            success = false;
        }
        if (StrIterIndex(&si) != StrIterLength(&si)) {
            WriteFmtLn(
                "[DEBUG] iterator did not consume whole object: idx={}, len={}",
                "[DEBUG] iterator did not consume whole object: idx={}, len={}",
                StrIterIndex(&si),
                StrIterLength(&si)
            );
            success = false;
        bool             result = true;
    
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 2);
        result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);
        bool    result = true;
    
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 2);
        result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);
        bool             result = true;
    
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 1);
        v      = KvConfigGetPtr(&cfg, "k");
        bool    result = true;
    
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 1);
        v      = KvConfigGetPtr(&cfg, "k");
        bool             result = true;
    
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 1);
        result = result && KvConfigContains(&cfg, "k");
        bool    result = true;
    
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 3);
        result = result && KvConfigContains(&cfg, "host");
        bool    result = true;
    
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 4);
        result = result && path && StrCmp(path, "/srv/my app") == 0;
        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