Skip to content

Str

Description

The Str type is a specialization of Vec for characters

Usage example (Cross-references)

Usage examples (Cross-references)
    // in the `_write_*` family (fall through to a default allocator when
    // `o`'s allocator is NULL), not here.
    Str *StrError(i32 eno, Str *err_str) {
        ValidateStr(err_str);
        Allocator *alloc = StrAllocator(err_str);
        ValidateStr(err_str);
        Allocator *alloc = StrAllocator(err_str);
        Str        out   = StrInit(alloc);
        StrAppendFmt(&out, "{} (errno {})", errno_description(eno), eno);
        StrDeinit(err_str);
    
    #include <Misra/Std/Allocator/Heap.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/File.h>
    #include <Misra/Std/Io.h>
    
        HeapAllocator h    = HeapAllocatorInit();
        Str           full = StrInit(&h);
        StrAppendFmt(&full, "[{}] [{}:{}] {}\n", (Zstr)NAMES[type], (Zstr)tag, line, (Zstr)msg);
            StackFrame frames[32];
            size       n     = CaptureStackTrace(frames, 32, 1);
            Str        trace = StrInit(&h);
            // FormatStackTrace takes `Allocator *` -- legitimate erasure
            // boundary; pass at the call site, no intermediate variable.
    
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/File.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/File.h>
    #include <Misra/Std/Io.h>
    }
    
    static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
    static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    
    static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
    static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
    static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
    static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
    static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
    
    static Zstr _read_r8(Zstr i, FmtInfo *fmt_info, u8 *v);
    // first digit, producing e.g. "-0000042" rather than "0000-0042".
    // width and content_len are measured in chars (sign counts as content).
    static bool pad_numeric_zeros(Str *o, size content_start, size width, size content_len) {
        if (content_len >= width) {
            return true;
    }
    
    bool StrPad(Str *o, size width, Alignment align, size content_len) {
        if (content_len >= width)
            return true;
    }
    
    bool str_append_fmt(Str *o, Zstr fmt, TypeSpecificIO *args, u64 argc) {
        if (!o || !fmt) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool str_write_fmt(Str *o, Zstr fmt, TypeSpecificIO *args, u64 argc) {
        if (!o || !fmt) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool str_patch_fmt(Str *o, size offset, Zstr fmt, TypeSpecificIO *args, u64 argc) {
        if (!o || !fmt) {
            LOG_FATAL("Invalid arguments");
        // sense. Library-internal scratch keeps the debug-build instrumentation.
        DefaultAllocator scratch = DefaultAllocatorInit();
        Str              tmp     = StrInit(&scratch);
        bool             ok      = str_append_fmt(&tmp, fmt, args, argc);
        if (ok) {
    
    bool f_write_fmt(File *stream, Zstr fmtstr, TypeSpecificIO *argv, u64 argc, bool append_newline) {
        Str  out;
        bool ok = true;
        // DefaultAllocator: rendered line size is caller-controlled (depends on the
    // raw output. Returns the index of the next byte after the directive,
    // or 0 on a failed write (fmt error / OOM).
    static bool render_one_raw_field(Str *out, FmtInfo *fmt_info, TypeSpecificIO *io, u64 arg_index) {
        if (!io->writer) {
            LOG_FATAL("buf_*_fmt: argument {} has no writer", arg_index);
    // ultimately writes into. Shared between buf_append_fmt and the body
    // rendering done by buf_write_fmt / buf_patch_fmt.
    static bool render_binary_fmt(Str *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
        u64     arg_index = 0;
        StrIter fsi       = StrIterFromZstr(fmtstr);
        // The raw-write helpers (_write_rN) emit into a Str. Buf is Vec(u8)
        // and Str is Vec(char); both have identical layout, so we alias.
        return render_binary_fmt((Str *)out, fmtstr, argv, argc);
    }
        }
        VecClear(out);
        return render_binary_fmt((Str *)out, fmtstr, argv, argc);
    }
        // DefaultAllocator: rendered size is caller-controlled (open-ended).
        DefaultAllocator scratch = DefaultAllocatorInit();
        Str              tmp     = StrInit(&scratch);
        bool             ok      = render_binary_fmt(&tmp, fmtstr, argv, argc);
        if (ok) {
        }
    
        Str buffer = StrInit(&scratch);
        i32 fd     = FileFd(file);
    // characters look identical on LE and BE hosts -- the format spec
    // implies a wire-style representation independent of host endianness.
    static inline bool write_int_as_chars(Str *o, FormatFlags flags, u64 value, size num_bytes) {
        if (!o || !num_bytes || num_bytes > 8) {
            LOG_FATAL("Invalid arguments");
    }
    
    static inline bool write_char_internal(Str *o, FormatFlags flags, Zstr vs, size len) {
        if (!o || !vs || !len) {
            LOG_FATAL("Invalid arguments");
    }
    
    static bool float_fmt_append_exponent(Str *out, i64 exponent, bool uppercase) {
        char sign      = exponent < 0 ? '-' : '+';
        u64  magnitude = exponent < 0 ? (u64)(-(exponent + 1)) + 1 : (u64)exponent;
    }
    
    bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc) {
        Str canonical;
        Str result;
    
    bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc) {
        Str canonical;
        Str result;
    bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc) {
        Str canonical;
        Str result;
    
        if (!out) {
    
    bool float_try_to_scientific_str(
        Str       *out,
        Float     *value,
        u32        precision,
        Allocator *alloc
    ) {
        Str digits;
        Str result;
        u64 frac_digits = 0;
    ) {
        Str digits;
        Str result;
        u64 frac_digits = 0;
        i64 exponent    = 0;
    }
    
    bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s) {
        if (!o || !s || !fmt_info) {
            LOG_FATAL("Invalid arguments");
                        }
                    }
                    Str hex = StrInit(StrAllocator(o));
                    if (!StrFromU64(&hex, c, &config)) {
                        StrDeinit(&hex);
    }
    
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s) {
        if (!o || !s || !*s || !fmt_info) {
            LOG_FATAL("Invalid arguments");
                        }
                    }
                    Str          hex    = StrInit(StrAllocator(o));
                    StrIntFormat config = {.base = 16, .uppercase = (fmt_info->flags & FMT_FLAG_CAPS) != 0};
                    if (!StrFromU64(&hex, (u8)xs[i], &config)) {
    }
    
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg) {
        Zstr *value = NULL;
    }
    
    bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
        // base-prefix / sign / padding logic from having to reach into
        // `o`'s prefix bytes after the fact.
        Str temp = StrInit(StrAllocator(o));
    
        u8 base = 10;
    }
    
    bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
        // base-prefix / sign / padding logic from having to reach into
        // `o`'s prefix bytes after the fact.
        Str temp = StrInit(StrAllocator(o));
    
        u8 base = 10;
    }
    
    bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            // as the integer renderers: padding/sign accounting wants a
            // self-contained slice it can measure.
            Str temp = StrInit(StrAllocator(o));
    
            u8             precision = fmt_info->flags & FMT_FLAG_HAS_PRECISION ? fmt_info->precision : 6;
    }
    
    bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    
    #if FEATURE_FLOAT
    bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
        size start_len = 0;
        Str  temp;
    bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
        size start_len = 0;
        Str  temp;
    
        if (!o || !fmt_info || !value) {
    }
    
    Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s) {
        if (!i || !s)
            LOG_FATAL("Invalid arguments");
    // (when `allow_float` is false) any decimal/exponent residue, before
    // the slice is handed to the typed `StrToU64` / `StrToI64` parser.
    static bool is_valid_numeric_string(const Str *str, bool allow_float) {
        if (!str || !StrBegin(str))
            return false;
            }
    
            Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
    
            // Special-value tokens (`inf`, `nan`, ...) carry through the
        size pos   = StrIterIndex(&si) - StrIterIndex(&saved);
    
        Str temp = StrInitFromCstr(start, pos, &scratch);
    
        if (!is_valid_numeric_string(&temp, true)) {
        size pos   = StrIterIndex(&si) - StrIterIndex(&saved);
    
        Str temp = StrInitFromCstr(start, pos, &scratch);
    
        // A bare base prefix ("0x", "0b", "0o") with no following digits is
            Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));                                                         \
            size pos   = StrIterIndex(&si) - StrIterIndex(&saved);                                                         \
            Str  temp  = StrInitFromCstr(start, pos, &scratch);                                                            \
                                                                                                                           \
            if (StrLen(&temp) == 2 && StrBegin(&temp)[0] == '0' &&                                                         \
        Zstr       next          = NULL;
        Allocator *allocator_ptr = NULL;
        Str        temp;
        FmtInfo    default_fmt;
    
    #if FEATURE_BITVEC
    bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv) {
        if (!o || !fmt_info || !bv) {
            LOG_FATAL("Invalid arguments");
                // requested width below.
            } else {
                Str bit_str;
    
                if (!bitvec_try_to_str(&bit_str, bv, StrAllocator(o))) {
    
    #if FEATURE_INT
    bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value) {
        if (!o || !fmt_info || !value) {
            LOG_FATAL("Invalid arguments");
    
        size start_len = StrLen(o);
        Str  temp;
        u8   radix = int_fmt_radix_from_flags(fmt_info);
            }
    
            Str hex_str = StrInitFromCstr(
                StrIterDataAt(&si, StrIterIndex(&hex_saved)),
                StrIterIndex(&si) - StrIterIndex(&hex_saved),
            }
    
            Str oct_str = StrInitFromCstr(
                StrIterDataAt(&si, StrIterIndex(&oct_saved)),
                StrIterIndex(&si) - StrIterIndex(&oct_saved),
        }
    
        Str bin_str = StrInitFromCstr(
            StrIterDataAt(&si, StrIterIndex(&bin_saved)),
            StrIterIndex(&si) - StrIterIndex(&bin_saved),
        }
    
        Str  temp   = StrInitFromCstr(start, StrIterIndex(&si) - StrIterIndex(&saved), IntAllocator(value));
        Int  parsed = IntInit(IntAllocator(value));
        bool ok     = IntTryFromStrRadix(&parsed, StrBegin(&temp), radix);
        size  token_len = 0;
        Zstr  start     = NULL;
        Str   temp;
        Float parsed;
            }
    
            Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
    
            // Special-value tokens (`inf`, `nan`, ...) carry through the
        size pos   = StrIterIndex(&si) - StrIterIndex(&saved);
    
        Str temp = StrInitFromCstr(start, pos, &scratch);
    
        if (!is_valid_numeric_string(&temp, true)) {
    }
    
    static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            }
            case ARG_KIND_STR : {
                Str *s = (Str *)target;
                StrClear(s);
                StrPushBackMany(s, value);
    // long-flag name upper-cased and hyphens swapped for underscores. For
    // short-only options without a long form we fall back to "VALUE".
    static void append_metavar(Str *out, const ArgSpec *sp) {
        Zstr src = sp->long_name;
        if (!src) {
    // Build the "  -l, --listen <LISTEN>" left column for one spec. Returns
    // the visible width so the caller can pad to a shared right margin.
    static u64 spec_format_left(const ArgSpec *sp, Str *out) {
        u64 start = StrLen(out);
        StrPushBackMany(out, "  ");
    
        // Usage line: "usage: name [OPTIONS] --req <REQ>... <POS>..."
        Str usage = StrInit(self->alloc);
        StrPushBackMany(&usage, "usage: ");
        StrPushBackMany(&usage, self->name);
        // padding. We allocate one Str per spec to remember its left side
        // so we don't have to format it twice.
        Str left_col[64];
        u64 left_w[64];
        u64 max_w   = 0;
            return;
        }
        Str rendered = StrInit(meta);
    #if !defined(LOG_NO_BACKTRACE) || !LOG_NO_BACKTRACE
        FormatStackTrace(&rendered, frames, count, meta);
    }
    
    void DebugAllocatorReportLeaks(DebugAllocator *self, Str *out) {
        if (!self || !out)
            return;
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Log.h>
    }
    
    bool bitvec_try_to_str(Str *out, BitVec *bv, Allocator *alloc) {
        ValidateBitVec(bv);
        if (!out) {
    }
    
    Str bitvec_to_str(BitVec *bv, Allocator *alloc) {
        Str result;
    
    Str bitvec_to_str(BitVec *bv, Allocator *alloc) {
        Str result;
    
        if (!bitvec_try_to_str(&result, bv, alloc)) {
    }
    
    bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc) {
        if (!str) {
            LOG_FATAL("str is NULL");
    }
    
    BitVec bitvec_from_str_str(const Str *str, Allocator *alloc) {
        BitVec result;
        // wanting true regex semantics should feed BitVecToStr to a regex
        // engine themselves.
        Str  bv_str = BitVecToStr(bv);
        bool result = false;
    }
    
    bool bitvec_regex_match_str(BitVec *bv, const Str *pattern) {
        ValidateBitVec(bv);
        if (!pattern) {
        }
    
        Str  bv_str = BitVecToStr(bv);
        bool result = false;
    /// Generic vector implementation
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Log.h>
    static bool float_try_from_str_impl(Float *out, Zstr text, size length) {
        Float result;
        Str   digits;
        size  pos          = 0;
        bool  negative     = false;
    }
    
    bool float_try_from_str_str(Float *out, const Str *text) {
        if (!out || !text) {
            LOG_FATAL("Invalid arguments");
    }
    
    Float float_from_str_str(const Str *text, Allocator *alloc) {
        Float result = FloatInit(alloc);
    }
    
    bool float_try_to_str(Str *out, const Float *value, Allocator *alloc) {
        Str digits;
        Str result;
    
    bool float_try_to_str(Str *out, const Float *value, Allocator *alloc) {
        Str digits;
        Str result;
    bool float_try_to_str(Str *out, const Float *value, Allocator *alloc) {
        Str digits;
        Str result;
    
        ValidateFloat(value);
    }
    
    Str float_to_str(const Float *value, Allocator *alloc) {
        Str result;
    
    Str float_to_str(const Float *value, Allocator *alloc) {
        Str result;
    
        ValidateFloat(value);
    /// Str implementation
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Str/Private.h>
    #include <Misra/Std/Zstr.h>
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Str/Private.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Vec/Private.h>
    }
    
    bool str_try_init_from_cstr(Str *out, Zstr cstr, size len, Allocator *alloc) {
        if (!out || !cstr) {
            LOG_FATAL("Invalid arguments");
    }
    
    Str str_init_from_cstr(Zstr cstr, size len, Allocator *alloc) {
        Str result = StrInit(alloc);
    
    Str str_init_from_cstr(Zstr cstr, size len, Allocator *alloc) {
        Str result = StrInit(alloc);
    
        // Try-form leaves `result` empty-but-valid on OOM, so the caller
    }
    
    bool StrInitCopy(Str *dst, const Str *src) {
        if (!dst || !src) {
            LOG_FATAL("Invalid arguments");
    
    bool str_init_copy(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
        Str       *dst             = (Str *)dst_ptr;
        const Str *src             = (const Str *)src_ptr;
        Allocator *clone_allocator = NULL;
    bool str_init_copy(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
        Str       *dst             = (Str *)dst_ptr;
        const Str *src             = (const Str *)src_ptr;
        Allocator *clone_allocator = NULL;
        clone_allocator = alloc ? (Allocator *)alloc : src->allocator;
    
        MemSet(dst, 0, sizeof(Str));
        *dst             = StrInit(clone_allocator);
        dst->copy_init   = src->copy_init;
    }
    
    void StrDeinit(Str *copy) {
        ValidateStr(copy);
        deinit_vec(GENERIC_VEC(copy), sizeof(char));
    void str_deinit(void *copy, const Allocator *alloc) {
        (void)alloc;
        StrDeinit((Str *)copy);
    }
    // real length lives inside the Str header itself.
    u64 str_hash(const void *data, u32 ignored_size) {
        const Str *str  = (const Str *)data;
        u64        hash = 1469598103934665603ULL;
        size       idx  = 0;
    
    i32 str_compare(const void *lhs, const void *rhs) {
        const Str *a   = (const Str *)lhs;
        const Str *b   = (const Str *)rhs;
        size       min = 0;
    i32 str_compare(const void *lhs, const void *rhs) {
        const Str *a   = (const Str *)lhs;
        const Str *b   = (const Str *)rhs;
        size       min = 0;
        i32        cmp = 0;
    }
    
    i32 str_cmp_str(const Str *s, const Str *other) {
        ValidateStr(s);
        ValidateStr(other);
    }
    
    i32 str_cmp_zstr(const Str *s, Zstr other) {
        ValidateStr(s);
        return ZstrCompare(StrBegin(s), other);
    }
    
    i32 str_cmp_cstr(const Str *s, Zstr other, size other_len) {
        ValidateStr(s);
        return ZstrCompareN(StrBegin(s), other, other_len);
    }
    
    i32 str_cmp_str_ignore_case(const Str *s, const Str *other) {
        ValidateStr(s);
        ValidateStr(other);
    }
    
    i32 str_cmp_zstr_ignore_case(const Str *s, Zstr other) {
        ValidateStr(s);
        return ZstrCompareIgnoreCase(StrBegin(s), other);
    }
    
    i32 str_cmp_cstr_ignore_case(const Str *s, Zstr other, size other_len) {
        ValidateStr(s);
        return ZstrCompareNIgnoreCase(StrBegin(s), other, other_len);
    }
    
    Zstr str_find_cstr(const Str *s, Zstr key, size key_len) {
        ValidateStr(s);
        return ZstrFindSubstringN(StrBegin(s), key, key_len);
    }
    
    Zstr str_find_zstr(const Str *s, Zstr key) {
        ValidateStr(s);
        return ZstrFindSubstring(StrBegin(s), key);
    }
    
    Zstr str_find_str(const Str *s, const Str *key) {
        ValidateStr(s);
        ValidateStr(key);
    }
    
    static StrIters str_split_to_iters_impl(Str *s, Zstr key, size keylen) {
        ValidateStr(s);
    }
    
    StrIters str_split_to_iters_zstr(Str *s, Zstr key) {
        return str_split_to_iters_impl(s, key, ZstrLen(key));
    }
    }
    
    StrIters str_split_to_iters_str(Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    }
    
    static Strs str_split_impl(Str *s, Zstr key, size keylen) {
        ValidateStr(s);
                Zstr next = ZstrFindSubstringN(prev, key, keylen);
                if (next) {
                    Str tmp = StrInitFromCstr(prev, next - prev, s->allocator);
                    VecPushBack(&sv, tmp);
                    prev = next + keylen;
                } else {
                    if (ZstrCompareN(prev, key, end - prev)) {
                        Str tmp = StrInitFromCstr(prev, end - prev, s->allocator);
                        VecPushBack(&sv, tmp);
                    }
    }
    
    Strs str_split_zstr(Str *s, Zstr key) {
        return str_split_impl(s, key, ZstrLen(key));
    }
    }
    
    Strs str_split_str(Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    }
    
    size str_index_of_cstr(const Str *s, Zstr key, size key_len) {
        Zstr found = NULL;
    }
    
    size str_index_of_zstr(const Str *s, Zstr key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    }
    
    size str_index_of_str(const Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool str_contains_cstr(const Str *s, Zstr key, size key_len) {
        return str_index_of_cstr(s, key, key_len) != SIZE_MAX;
    }
    }
    
    bool str_contains_zstr(const Str *s, Zstr key) {
        return str_index_of_zstr(s, key) != SIZE_MAX;
    }
    }
    
    bool str_contains_str(const Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    //                 = -1 means from left
    //                 = 1 means from right
    Str strip_str(Str *s, Zstr chars_to_strip, int split_direction) {
        ValidateStr(s);
    }
    
    bool str_starts_with_zstr(const Str *s, Zstr prefix) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix, ZstrLen(prefix));
    }
    
    bool str_ends_with_zstr(const Str *s, Zstr suffix) {
        ValidateStr(s);
        return ends_with(s->data, s->length, suffix, ZstrLen(suffix));
    }
    
    bool str_starts_with_cstr(const Str *s, Zstr prefix, size prefix_len) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix, prefix_len);
    }
    
    bool str_ends_with_cstr(const Str *s, Zstr suffix, size suffix_len) {
        ValidateStr(s);
        return ends_with(s->data, s->length, suffix, suffix_len);
    }
    
    bool str_starts_with_str(const Str *s, const Str *prefix) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix->data, prefix->length);
    }
    
    bool str_ends_with_str(const Str *s, const Str *suffix) {
        ValidateStr(s);
        return ends_with(s->data, s->length, suffix->data, suffix->length);
    }
    
    void str_replace_cstr(Str *s, Zstr match, size match_len, Zstr replacement, size replacement_len, size count) {
        ValidateStr(s);
        size i        = 0;
    }
    
    void str_replace_zstr(Str *s, Zstr match, Zstr replacement, size count) {
        ValidateStr(s);
        str_replace_cstr(s, match, ZstrLen(match), replacement, ZstrLen(replacement), count);
    }
    
    void str_replace_str(Str *s, const Str *match, const Str *replacement, size count) {
        ValidateStr(s);
        str_replace_cstr(s, match->data, match->length, replacement->data, replacement->length, count);
    }
    
    static inline size skip_prefix(const Str *str, size pos, u8 base) {
        if (pos + 2 > str->length || str->data[pos] != '0') {
            return pos;
    }
    
    Str *StrFromU64(Str *str, u64 value, const StrIntFormat *config) {
        ValidateStr(str);
    }
    
    Str *StrFromI64(Str *str, i64 value, const StrIntFormat *config) {
        ValidateStr(str);
    }
    
    Str *StrFromF64(Str *str, f64 value, const StrFloatFormat *config) {
        ValidateStr(str);
    }
    
    bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config) {
        ValidateStr(str);
    }
    
    bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config) {
        ValidateStr(str);
        // Borrowed substring view: data points into the caller's bytes and
        // capacity stays 0 so StrToU64 never tries to grow it.
        Str temp_str      = StrInit(str->allocator);
        temp_str.data     = str->data + pos;
        temp_str.length   = str->length - pos;
    }
    
    bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config) {
        ValidateStr(str);
    }
    
    void ValidateStr(const Str *s) {
        return ValidateVec(s);
    }
    }
    
    bool int_try_from_str_str(Int *out, const Str *decimal) {
        u64 start = 0;
    }
    
    Int int_from_str_str(const Str *decimal, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    bool int_try_to_str(Str *out, const Int *value, Allocator *alloc) {
        return int_try_to_str_radix(out, value, 10, false, alloc);
    }
    }
    
    Str int_to_str(const Int *value, Allocator *alloc) {
        Str result;
    
    Str int_to_str(const Int *value, Allocator *alloc) {
        Str result;
    
        ValidateInt(value);
    }
    
    bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix) {
        u64 start = 0;
    }
    
    Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
        Int current;
        Str result;
    bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
        Int current;
        Str result;
    
        ValidateInt(value);
    }
    
    Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
        Str result;
    
    Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
        Str result;
    
        ValidateInt(value);
    }
    
    bool int_try_from_binary_str(Int *out, const Str *binary) {
        u64 start = 0;
    }
    
    Int int_from_binary_str(const Str *binary, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    Str IntToBinary(const Int *value) {
        return IntToStrRadix(value, 2, false);
    }
    }
    
    bool int_try_from_oct_str_str(Int *out, const Str *octal) {
        u64 start = 0;
    }
    
    Int int_from_oct_str_str(const Str *octal, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    Str IntToOctStr(const Int *value) {
        return IntToStrRadix(value, 8, false);
    }
    }
    
    bool int_try_from_hex_str_str(Int *out, const Str *hex) {
        if (!out || !hex) {
            LOG_FATAL("Invalid arguments");
    }
    
    Int int_from_hex_str_str(const Str *hex, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    Str IntToHexStr(const Int *value) {
        return IntToStrRadix(value, 16, false);
    }
    
    #include <Misra/Std.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/File.h>
    #include <Misra/Std/Log.h>
    //
    // On success populates `out_path` (an owned Str the caller frees).
    static bool find_pdb(const Pe *pe, Zstr pe_path, Str *out_path) {
        const PeCodeViewInfo *cv = PeCodeView(pe);
        if (!cv->present || !cv->pdb_path)
            return true;
    
        Str pdb_path = StrInit(alloc);
        if (!find_pdb(&entry->pe, StrBegin(&entry->module_path), &pdb_path)) {
            StrDeinit(&pdb_path);
    bool pdb_cache_resolve_str(
        PdbCache  *self,
        const Str *module_path,
        u64        module_base,
        u64        runtime_ip,
    
    // Shared formatter body (raw view: pointer + length).
    static void format_walk_win(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        ensure_dbghelp();
        HANDLE proc = GetCurrentProcess();
    }
    
    void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        if (!out || !frames)
            return;
    }
    
    void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc) {
        if (!out || !frames)
            return;
    #    endif
    
    static void format_walk_mac(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
    #    if FEATURE_PARSER_MACHO
        bool       cache_ok = (alloc != NULL);
    }
    
    void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        if (!out || !frames || !alloc)
            return;
    }
    
    void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc) {
        if (!out || !frames || !alloc)
            return;
    }
    
    static void emit_resolved_line(Str *out, u32 idx, const ResolvedSymbol *r, void *ip) {
        if (r->symbol_name) {
            Zstr mod = sys_basename_of(r->module_path);
    }
    
    static void format_walk_with(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver) {
        for (size i = 0; i < count; ++i) {
            ResolvedSymbol r;
    }
    
    static void format_walk_alloc(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        SymbolResolver res;
        if (!SymbolResolverInit(&res, alloc)) {
    }
    
    void format_stack_trace_with_raw(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver) {
        if (!out || !frames || !resolver)
            return;
    }
    
    void format_stack_trace_with_vec(Str *out, const StackFrames *frames, SymbolResolver *resolver) {
        if (!out || !frames || !resolver)
            return;
    }
    
    void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        if (!out || !frames || !alloc)
            return;
    }
    
    void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc) {
        if (!out || !frames || !alloc)
            return;
    // Format the build-id bytes as `aa/bbbb...` (first byte separator,
    // rest concatenated, lowercase hex). Caller provides the Str.
    static void append_build_id_path(Str *out, const u8 *id, u32 n) {
        static const char hex[] = "0123456789abcdef";
        if (n == 0)
    // Returns true on success; `out` is populated with an opened Elf.
    static bool try_open_sidecar(Zstr main_path, const Elf *main, Elf *out, Allocator *alloc) {
        Str path = StrInit(alloc);
    
        // (1) Build-ID
    }
    
    bool socket_addr_parse_str(SocketAddr *out, const Str *spec, SocketKind kind) {
        if (!out) {
            LOG_FATAL("SocketAddrParse: out is NULL");
    }
    
    Str socket_addr_format(const SocketAddr *addr, Allocator *alloc) {
        Str out = StrInit(alloc);
        if (!addr || addr->length == 0) {
    
    Str socket_addr_format(const SocketAddr *addr, Allocator *alloc) {
        Str out = StrInit(alloc);
        if (!addr || addr->length == 0) {
            return out;
        PROCESS_INFORMATION pi = {0};
    
        Str cmdline = StrInit(alloc);
        StrPushBackMany(&cmdline, filepath);
        for (char **arg = argv + 1; *arg; ++arg) {
    }
    
    i32 ProcWriteToStdin(Proc *proc, const Str *buf) {
        if (!proc || !buf) {
            LOG_FATAL("Invalid arguments");
    }
    
    static i32 proc_read_internal(Proc *proc, Str *buf, bool is_stdout) {
        if (!proc || !buf) {
            LOG_FATAL("Invalid argument");
    }
    
    i32 ProcReadFromStdout(Proc *proc, Str *buf) {
        return proc_read_internal(proc, buf, /* is stdout*/ true);
    }
    }
    
    i32 ProcReadFromStderr(Proc *proc, Str *buf) {
        return proc_read_internal(proc, buf, /* is stdout*/ false);
    }
    }
    
    Str *GetCurrentExecutablePath(Str *exe_path) {
        ValidateStr(exe_path);
        Allocator *alloc = StrAllocator(exe_path);
    
    #include <Misra/Std/File.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
    /// including the last separator) into `out`. No-op on NULL or on paths
    /// with no separator.
    static inline void sys_append_dirname(Str *out, Zstr path) {
        if (!path)
            return;
    
    #include <Misra/Std.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/File.h>
    // Compose the conventional dSYM location for `binary_path`:
    //   <binary_path>.dSYM/Contents/Resources/DWARF/<basename>
    static bool compose_dsym_path(Zstr binary_path, Str *out) {
        if (!binary_path)
            return false;
        }
    
        Str path = StrInit(alloc);
        if (!compose_dsym_path(StrBegin(&e->module_path), &path)) {
            StrDeinit(&path);
    bool macho_cache_resolve_str(
        MachoCache *self,
        const Str  *module_path,
        u64         slide,
        u64         runtime_ip,
    // on the Str. Returns false on read error; missing file returns true
    // with an empty Str.
    static bool slurp_file(Zstr path, Str *out) {
        File f = FileOpen(path, "rb");
        if (!FileIsOpen(&f)) {
    
    static void parse_hosts_table(HostsTable *table, Allocator *alloc) {
        Str buf = StrInit(alloc);
        if (!slurp_file(HOSTS_FILE_PATH, &buf)) {
            StrDeinit(&buf);
    
    static void parse_resolv_conf(DnsAddrs *out, Allocator *alloc) {
        Str buf = StrInit(alloc);
        if (!slurp_file(RESOLV_CONF_FILE_PATH, &buf)) {
            StrDeinit(&buf);
    
    // Strip trailing dot, lowercase, write into `out` (caller-managed Str).
    static void normalize_hostname(Zstr name, Str *out) {
        if (!name) {
            return;
    }
    
    bool dns_resolve_5_str(DnsResolver *self, const Str *hostname, u16 port, SocketKind kind, DnsAddrs *out) {
        if (!self || !hostname || !out) {
            return false;
    }
    
    bool dns_resolve_4_vec_str(DnsResolver *self, const Str *spec, SocketKind kind, DnsAddrs *out) {
        if (!self || !spec || !out) {
            return false;
    }
    
    bool dns_resolve_4_one_str(DnsResolver *self, const Str *spec, SocketKind kind, SocketAddr *out) {
        if (!self || !spec || !out) {
            return false;
    
    void http_header_deinit(void *header_ptr, const Allocator *alloc) {
        (void)alloc; // each Str carries its own allocator handle
        HttpHeader *header = (HttpHeader *)header_ptr;
        StrDeinit(&header->key);
    }
    
    HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key) {
        if (!headers || !key) {
            LOG_FATAL("invalid arguments");
    // ---------------------------------------------------------------------------
    
    static HttpRequestMethod http_request_method_from_str(const Str *mstr) {
        if (!mstr || !StrBegin(mstr)) {
            return HTTP_REQUEST_METHOD_UNKNOWN;
        Allocator *alloc   = req->allocator;
        Zstr       cursor  = in;
        Str        method  = StrInit(alloc);
        Str        version = StrInit(alloc);
        Zstr       cursor  = in;
        Str        method  = StrInit(alloc);
        Str        version = StrInit(alloc);
    
        StrReadFmt(cursor, "{} {} {}\r\n", method, req->url, version);
    }
    
    Zstr http_request_parse_str(HttpRequest *req, const Str *in) {
        if (!req || !in) {
            LOG_FATAL("invalid arguments");
    // ---------------------------------------------------------------------------
    
    HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html) {
        if (!response || !response->allocator || !html) {
            LOG_FATAL("invalid arguments");
        HttpResponseCode status,
        HttpContentType  content_type,
        const Str       *filepath
    ) {
        if (!filepath) {
    #endif
    
    Str http_response_serialize(const HttpResponse *response, Allocator *alloc) {
        Str out = StrInit(alloc);
    
    Str http_response_serialize(const HttpResponse *response, Allocator *alloc) {
        Str out = StrInit(alloc);
    
        if (!response) {
    }
    
    static bool kvconfig_parse_bool_value(const Str *value, bool *out) {
        if (!out) {
            LOG_FATAL("Expected valid bool output pointer");
    }
    
    static bool kvconfig_parse_i64_value(const Str *value, i64 *out) {
        Zstr endptr = NULL;
        i64  parsed;
    }
    
    static bool kvconfig_parse_f64_value(const Str *value, f64 *out) {
        Zstr endptr = NULL;
        f64  parsed;
    }
    
    StrIter KvConfigReadKey(StrIter si, Str *key) {
        StrIter saved_si = si;
    }
    
    StrIter KvConfigReadValue(StrIter si, Str *value) {
        StrIter saved_si = si;
    
        if (StrLen(value) > 0) {
            Str stripped = StrStrip(value, NULL);
            StrDeinit(value);
            *value = stripped;
    }
    
    StrIter KvConfigReadPair(StrIter si, Str *key, Str *value) {
        StrIter saved_si = si;
        char c;
        while (StrIterPeek(&si, &c)) {
            Str     key   = StrInit(MapAllocator(cfg));
            Str     value = StrInit(MapAllocator(cfg));
            StrIter read_si;
        while (StrIterPeek(&si, &c)) {
            Str     key   = StrInit(MapAllocator(cfg));
            Str     value = StrInit(MapAllocator(cfg));
            StrIter read_si;
    }
    
    Str *kvconfig_get_ptr_str(KvConfig *cfg, const Str *key) {
        if (!cfg || !key) {
            return NULL;
    }
    
    Str *kvconfig_get_ptr_zstr(KvConfig *cfg, Zstr key) {
        Str  lookup = {0};
        Str *value  = NULL;
    
    Str *kvconfig_get_ptr_zstr(KvConfig *cfg, Zstr key) {
        Str  lookup = {0};
        Str *value  = NULL;
    Str *kvconfig_get_ptr_zstr(KvConfig *cfg, Zstr key) {
        Str  lookup = {0};
        Str *value  = NULL;
    
        if (!cfg || !key) {
    }
    
    Str kvconfig_get_str(KvConfig *cfg, const Str *key) {
        Str *value = kvconfig_get_ptr_str(cfg, key);
    
    Str kvconfig_get_str(KvConfig *cfg, const Str *key) {
        Str *value = kvconfig_get_ptr_str(cfg, key);
    
        if (!value) {
    }
    
    Str kvconfig_get_zstr(KvConfig *cfg, Zstr key) {
        Str *value = kvconfig_get_ptr_zstr(cfg, key);
    
    Str kvconfig_get_zstr(KvConfig *cfg, Zstr key) {
        Str *value = kvconfig_get_ptr_zstr(cfg, key);
    
        if (!value) {
    }
    
    bool kvconfig_contains_str(KvConfig *cfg, const Str *key) {
        return kvconfig_get_ptr_str(cfg, key) != NULL;
    }
    }
    
    bool kvconfig_get_bool_str(KvConfig *cfg, const Str *key, bool *value) {
        Str *str = kvconfig_get_ptr_str(cfg, key);
    
    bool kvconfig_get_bool_str(KvConfig *cfg, const Str *key, bool *value) {
        Str *str = kvconfig_get_ptr_str(cfg, key);
    
        if (!str) {
    
    bool kvconfig_get_bool_zstr(KvConfig *cfg, Zstr key, bool *value) {
        Str *str = kvconfig_get_ptr_zstr(cfg, key);
    
        if (!str) {
    }
    
    bool kvconfig_get_i64_str(KvConfig *cfg, const Str *key, i64 *value) {
        Str *str = kvconfig_get_ptr_str(cfg, key);
    
    bool kvconfig_get_i64_str(KvConfig *cfg, const Str *key, i64 *value) {
        Str *str = kvconfig_get_ptr_str(cfg, key);
    
        if (!str) {
    
    bool kvconfig_get_i64_zstr(KvConfig *cfg, Zstr key, i64 *value) {
        Str *str = kvconfig_get_ptr_zstr(cfg, key);
    
        if (!str) {
    }
    
    bool kvconfig_get_f64_str(KvConfig *cfg, const Str *key, f64 *value) {
        Str *str = kvconfig_get_ptr_str(cfg, key);
    
    bool kvconfig_get_f64_str(KvConfig *cfg, const Str *key, f64 *value) {
        Str *str = kvconfig_get_ptr_str(cfg, key);
    
        if (!str) {
    
    bool kvconfig_get_f64_zstr(KvConfig *cfg, Zstr key, f64 *value) {
        Str *str = kvconfig_get_ptr_zstr(cfg, key);
    
        if (!str) {
            }
    
            Str key = StrInit(&scratch);
    
            // key start
    }
    
    StrIter JReadString(StrIter si, Str *str) {
        if (!StrIterRemainingLength(&si)) {
            return si;
        // stack-backed buffer is unsafe -- DefaultAllocator is the right fit.
        DefaultAllocator scratch = DefaultAllocatorInit();
        Str              ns      = StrInit(&scratch);
    
        bool is_neg = false;
            // valid input. DefaultAllocator is the right fit here.
            DefaultAllocator scratch = DefaultAllocatorInit();
            Str              s       = StrInit(&scratch);
            si                       = JReadString(si, &s);
            StrDeinit(&s);
    }
    
    const ElfSection *elf_find_section_str(const Elf *self, const Str *name) {
        if (!self || !name)
            return NULL;
    // Append `s` (NUL-terminated) including its terminator into `pool` and
    // return the offset at which it was inserted.
    static bool pool_append(Str *pool, Zstr s, u64 *out_offset) {
        u64 start = StrLen(pool);
        if (!StrPushBackMany(pool, s))
    // to the first byte after the standard_opcode_lengths array; we
    // continue from there.
    static bool collect_cu_strings(BufIter cur, Str *pool, CuStrings *cs) {
        // include_directories
        while (IterIndex(&cur) < IterLength(&cur) && *IterDataAt(&cur, IterIndex(&cur)) != 0) {
    static bool lnp_emit(
        DwarfLines      *out,
        Str             *pool,
        const CuStrings *cs,
        const LnpState  *st,
        const u8          *debug_str,
        u64                debug_str_size,
        Str               *pool,
        PendingFns        *pending
    ) {
    // invalidates earlier pointers -- we resolve to pointers in a second
    // pass after the walk completes.
    static bool pool_append_cstr(Str *pool, Zstr s, u64 *out_offset) {
        *out_offset = StrLen(pool);
        if (!StrPushBackMany(pool, s))
        const SectionRva *sections,
        u32               num_sections,
        Str              *pool,
        PendingPubs      *pending
    ) {
    }
    
    bool dns_build_query_str(DnsWireBuf *out, u16 id, const Str *name, DnsType type) {
        if (!out || !name) {
            return false;
    //
    // Returns false on cycles, oversized names, or out-of-bounds.
    static bool decode_name(BufIter *it, Str *out_name) {
        const u32 MAX_HOPS  = 64;
        u32       hops      = 0;
        // Skip echoed question section: each question is qname + qtype(2) + qclass(2).
        for (u16 i = 0; i < qd; ++i) {
            Str dummy = StrInit(alloc);
            if (!decode_name(&it, &dummy)) {
                StrDeinit(&dummy);
    }
    
    const PeSection *pe_find_section_str(const Pe *self, const Str *name) {
        if (!self || !name)
            return NULL;
    
            VecForeachPtr(&addrs, a) {
                Str s = SocketAddrFormat(a, alloc);
                // Strip the trailing ":0" since we resolve with port=0; keep
                // bracket form on v6 to round-trip through SocketAddrParse.
    static void log_request_summary(Zstr client_addr, Zstr prefix_bytes, size prefix_len) {
        Scope(scope, DefaultAllocator) {
            Str raw = StrInit(scope);
            StrPushBackMany(&raw, prefix_bytes);
    
    static void handle_connection(Allocator *alloc, Socket *client, const SocketAddr *upstream_addr) {
        Str peer_str = SocketAddrFormat(&client->peer, alloc);
    
        Socket upstream;
    
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Types.h>
    
    // Vec(Str) typedef
    typedef Vec(Str) StrVec;
    
    // Vec(Str) function enumeration
    #include "VecStr.h"
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    // `GenericCopyInit` signature `(void *dst, const void *src, const Allocator *)`.
    static bool str_clone_init(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
        const Str *src = (const Str *)src_ptr;
        // StrBegin on an empty Str returns NULL, which str_try_init_from_cstr
        // treats as a fatal arg violation. An empty source clones to an
        // treats as a fatal arg violation. An empty source clones to an
        // empty fresh Str.
        Str copy = (StrLen(src) == 0) ? StrInit((Allocator *)alloc) :
                                        StrInitFromCstr(StrBegin(src), StrLen(src), (Allocator *)alloc);
        *(Str *)dst_ptr = copy;
        Str copy = (StrLen(src) == 0) ? StrInit((Allocator *)alloc) :
                                        StrInitFromCstr(StrBegin(src), StrLen(src), (Allocator *)alloc);
        *(Str *)dst_ptr = copy;
        return true;
    }
    
    // Generate a Str from fuzz input data
    static Str generate_str_from_input(
        const uint8_t    *data,
        size_t           *offset,
    
        // Create Str with capacity
        Str str = StrInit(alloc);
    
        // Fill with data or generate simple pattern if not enough input
        switch (func) {
            case VEC_STR_PUSH_BACK : {
                Str str = generate_str_from_input(data, offset, data_size, 32, alloc);
                VecPushBack(vec, str);
                break;
    
            case VEC_STR_PUSH_FRONT : {
                Str str = generate_str_from_input(data, offset, data_size, 32, alloc);
                VecPushFront(vec, str);
                break;
            case VEC_STR_POP_BACK : {
                if (VecLen(vec) > 0) {
                    Str str;
                    VecPopBack(vec, &str);
                    // StrDeinit is called automatically by the vector
            case VEC_STR_POP_FRONT : {
                if (VecLen(vec) > 0) {
                    Str str;
                    VecPopFront(vec, &str);
                    // StrDeinit is called automatically by the vector
                if (*offset + 4 <= data_size) {
                    size_t index = extract_u32(data, offset, data_size) % (VecLen(vec) + 1);
                    Str    str   = generate_str_from_input(data, offset, data_size, 32, alloc);
                    VecInsert(vec, str, index);
                }
                if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
                    size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
                    Str    str;
                    VecRemove(vec, &str, index);
                    // StrDeinit is called automatically by the vector
                if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
                    size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
                    Str    str   = VecAt(vec, index);
                    (void)str; // Use the result to avoid warnings
                }
            case VEC_STR_FIRST : {
                if (VecLen(vec) > 0) {
                    Str first = VecFirst(vec);
                    (void)first; // Use the result to avoid warnings
                }
            case VEC_STR_LAST : {
                if (VecLen(vec) > 0) {
                    Str last = VecLast(vec);
                    (void)last; // Use the result to avoid warnings
                }
                    if (new_size > old_size) {
                        for (size_t i = old_size; i < new_size; i++) {
                            Str str       = generate_str_from_input(data, offset, data_size, 16, alloc);
                            VecAt(vec, i) = str;
                        }
                    // moves each Str into the vector and zeros the source slot,
                    // so no per-element StrDeinit is needed here.
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);
                    size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
                    size_t count = extract_u32(data, offset, data_size) % (VecLen(vec) - index + 1);
                    VecRemoveRange(vec, (Str *)NULL, index, count);
                }
                break;
                if (*offset + 4 <= data_size) {
                    size_t index = extract_u32(data, offset, data_size) % (VecLen(vec) + 1);
                    Str    str   = generate_str_from_input(data, offset, data_size, 32, alloc);
                    VecInsertFast(vec, str, index);
                }
                if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
                    size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
                    Str    str;
                    VecRemoveFast(vec, &str, index);
                    // StrDeinit is called automatically by the vector
                    size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
                    size_t count = extract_u32(data, offset, data_size) % (VecLen(vec) - index + 1);
                    VecRemoveRangeFast(vec, (Str *)NULL, index, count);
                }
                break;
                    // L-form VecPushBackArr moves each Str into the vector and
                    // zeros the source slot, so no per-element cleanup needed.
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);
                    // L-form VecPushFrontArr moves each Str into the vector and
                    // zeros the source slot, so no per-element cleanup needed.
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);
                    // L-form VecPushFrontArrFast moves each Str into the vector
                    // and zeros the source slot, so no per-element cleanup needed.
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);
            case VEC_STR_BEGIN : {
                if (VecLen(vec) > 0) {
                    Str *begin = VecBegin(vec);
                    (void)begin; // Use the result to avoid warnings
                }
            case VEC_STR_END : {
                if (VecLen(vec) > 0) {
                    Str *end = VecEnd(vec);
                    (void)end; // Use the result to avoid warnings
                }
                if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
                    size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
                    Str   *ptr   = VecPtrAt(vec, index);
                    (void)ptr; // Use the result to avoid warnings
                }
                    size_t count = extract_u32(data, offset, data_size) % 5;
                    for (size_t i = 0; i < count; i++) {
                        Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
                        VecPushBack(&temp, str);
                    }
                    // L-form VecInsertRangeFast moves each Str into the vector and
                    // zeros the source slot, so no per-element cleanup needed.
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);
                    size_t count = extract_u32(data, offset, data_size) % 5;
                    for (size_t i = 0; i < count; i++) {
                        Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
                        VecPushBack(&temp, str);
                        StrDeinit(&str);
                    si = JSkipWhitespace(si);                                                                              \
                }                                                                                                          \
                Str key       = StrInit(&alloc);                                                                           \
                UNPL(read_si) = JReadString(si, &key);                                                                     \
                if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                                   \
    #define JR_STR(si, str)                                                                                                \
        do {                                                                                                               \
            Str UNPL(my_str) = StrInit(&alloc);                                                                            \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        do {                                                                                                               \
            if (!StrCmp(&key, (k))) {                                                                                      \
                Str UNPL(my_str) = StrInit(&alloc);                                                                        \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
    // Test structures for edge cases
    typedef struct EdgeCaseData {
        Str  empty_string;
        i64  negative_int;
        f64  large_float;
        f64  small_float;
        bool is_valid;
        Vec(Str) empty_array;
        Vec(i64) numbers;
    } EdgeCaseData;
    
        // Test completely empty object
        Str     json1 = StrInitFromZstr("{}", &alloc);
        StrIter si1   = StrIterFromStr(json1);
    
        // Test empty object with whitespace
        Str     json2 = StrInitFromZstr("  {   }  ", &alloc);
        StrIter si2   = StrIterFromStr(json2);
    
        // Test completely empty array
        Str     json1 = StrInitFromZstr("{\"items\":[]}", &alloc);
        StrIter si1   = StrIterFromStr(json1);
    
        // Test empty array with whitespace
        Str     json2 = StrInitFromZstr("{\"data\": [  ] }", &alloc);
        StrIter si2   = StrIterFromStr(json2);
        StrIter si2   = StrIterFromStr(json2);
    
        Vec(Str) data = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        JR_OBJ(si2, {
        JR_OBJ(si2, {
            JR_ARR_KV(si2, "data", {
                Str value = StrInit(&alloc);
                JR_STR(si2, value);
                VecPushBack(&data, value);
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"name\":\"\",\"description\":\"\"}", &alloc);
        StrIter si   = StrIterFromStr(json);
    
        struct {
            Str name;
            Str description;
        } obj = {StrInit(&alloc), StrInit(&alloc)};
        struct {
            Str name;
            Str description;
        } obj = {StrInit(&alloc), StrInit(&alloc)};
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"temp\":-25,\"balance\":-1000.50,\"delta\":-0.001}", &alloc);
        StrIter si   = StrIterFromStr(json);
        bool success = true;
    
        Str json = StrInitFromZstr(
            "{\"big_int\":9223372036854775807,\"big_float\":1.7976931348623157e+308,\"small_float\":2.2250738585072014e-"
            "308}",
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"int_zero\":0,\"float_zero\":0.0,\"bool_false\":false}", &alloc);
        StrIter si   = StrIterFromStr(json);
    
        // Test with various special characters that might be problematic
        Str json = StrInitFromZstr(
            "{\"path\":\"C:\\\\Program Files\\\\App\",\"message\":\"Hello, "
            "\\\"World\\\"!\",\"data\":\"line1\\nline2\\ttab\"}",
    
        struct {
            Str path;
            Str message;
            Str data;
        struct {
            Str path;
            Str message;
            Str data;
        } obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
            Str path;
            Str message;
            Str data;
        } obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
        bool success = true;
    
        Str json = StrInitFromZstr(
            "{\"escaped\":\"\\\"quotes\\\"\",\"backslash\":\"\\\\\",\"newline\":\"\\n\",\"tab\":\"\\t\"}",
            &alloc
    
        struct {
            Str escaped;
            Str backslash;
            Str newline;
        struct {
            Str escaped;
            Str backslash;
            Str newline;
            Str tab;
            Str escaped;
            Str backslash;
            Str newline;
            Str tab;
        } obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
            Str backslash;
            Str newline;
            Str tab;
        } obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
    
        // Test with lots of different whitespace patterns
        Str     json = StrInitFromZstr("  {\n\t\"name\"  :  \"test\"  ,\n  \"value\": 42\t,\"flag\"\n:\ntrue\n}\t", &alloc);
        StrIter si   = StrIterFromStr(json);
    
        struct {
            Str  name;
            i32  value;
            bool flag;
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"outer\":{},\"list\":[],\"deep\":{\"inner\":{}}}", &alloc);
        StrIter si   = StrIterFromStr(json);
        bool success = true;
    
        Str json =
            StrInitFromZstr("{\"empty_obj\":{},\"filled_obj\":{\"x\":1},\"empty_arr\":[],\"filled_arr\":[1,2]}", &alloc);
        StrIter si = StrIterFromStr(json);
    
        // Using smaller values that are safer to work with
        Str json   = StrInitFromZstr("{\"max_int\":2147483647,\"min_int\":-2147483648,\"one\":1,\"minus_one\":-1}", &alloc);
        StrIter si = StrIterFromStr(json);
        bool success = true;
    
        Str json =
            StrInitFromZstr("{\"tiny\":0.000001,\"huge\":999999.999999,\"zero\":0.0,\"negative_tiny\":-0.000001}", &alloc);
        StrIter si = StrIterFromStr(json);
        u64  analysis_id;
        u64  binary_id;
        Str  analysis_name;
        Str  function_name;
        Str  sha256;
        u64  binary_id;
        Str  analysis_name;
        Str  function_name;
        Str  sha256;
        bool debug;
        Str  analysis_name;
        Str  function_name;
        Str  sha256;
        bool debug;
        Str  function_mangled_name;
        Str  sha256;
        bool debug;
        Str  function_mangled_name;
    } AnnSymbol;
    typedef struct ApiResponse {
        bool       status;
        Str        message;
        AnnSymbols data;
    } ApiResponse;
    typedef struct FunctionInfo {
        u64 id;
        Str name;
        u64 size;
        u64 vaddr;
    typedef struct SearchResult {
        u64 binary_id;
        Str binary_name;
        u64 analysis_id;
        Str sha256;
        Str binary_name;
        u64 analysis_id;
        Str sha256;
        Vec(Str) tags;
        Str created_at;
        u64 analysis_id;
        Str sha256;
        Vec(Str) tags;
        Str created_at;
        u64 model_id;
        Str sha256;
        Vec(Str) tags;
        Str created_at;
        u64 model_id;
        Str model_name;
        Str created_at;
        u64 model_id;
        Str model_name;
        Str owned_by;
    } SearchResult;
        u64 model_id;
        Str model_name;
        Str owned_by;
    } SearchResult;
    
    // Helper function to compare JSON output (removes whitespace for comparison)
    bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
    // Helper function to compare JSON output (removes whitespace for comparison)
    bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
    bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
    
        // Remove whitespace from both strings for comparison
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        struct {
                u64 id;
                struct {
                    Str name;
                    u64 age;
                } profile;
                } profile;
            } user;
            Str status;
        } data = {
            {123, {StrInitFromZstr("Alice", &alloc), 30}},
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        struct {
                struct {
                    struct {
                        Str head;
                        u64 count;
                        f64 budget;
                    } engineering;
                } departments;
                Str name;
            } company;
        } data = {
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        ApiResponse response = {
            JW_OBJ_KV(json, "data", {
                // Write dynamic key for source function ID
                Str source_key = StrInit(&alloc);
                u64 source_id  = VecLen(&response.data) > 0 ? VecAt(&response.data, 0).source_function_id : 0;
                StrAppendFmt(&source_key, "{}", source_id);
                    if (VecLen(&response.data) > 0) {
                        AnnSymbol *s          = &VecAt(&response.data, 0);
                        Str        target_key = StrInit(&alloc);
                        StrAppendFmt(&target_key, "{}", s->target_function_id);
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Vec(FunctionInfo) functions = VecInitWithDeepCopy(NULL, FunctionInfoDeinit, &alloc);
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        SearchResult result = {0};
    
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("malware", &alloc);
        Str tag2 = StrInitFromZstr("x86", &alloc);
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("malware", &alloc);
        Str tag2 = StrInitFromZstr("x86", &alloc);
    
        VecPushBack(&result.tags, tag1);
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Vec(AnnSymbol) symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc);
            JW_OBJ_KV(json, "functions", {
                VecForeach(&symbols, symbol) {
                    Str source_key = StrInit(&alloc);
                    StrAppendFmt(&source_key, "{}", symbol.source_function_id);
    
                    JW_OBJ_KV(json, StrBegin(&source_key), {
                Str target_key = StrInit(&alloc);
                StrAppendFmt(&target_key, "{}", symbol.target_function_id);
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        // Create strings for the nested structure
    
        // Create strings for the nested structure
        Str deep_message = StrInitFromZstr("deep", &alloc);
        Str test_name    = StrInitFromZstr("test", &alloc);
        // Create strings for the nested structure
        Str deep_message = StrInitFromZstr("deep", &alloc);
        Str test_name    = StrInitFromZstr("test", &alloc);
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Vec(u32) numbers = VecInit(&alloc);
        VecPushBack(&numbers, num3);
    
        Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Create strings and push them properly
    
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("a", &alloc);
        Str str2 = StrInitFromZstr("b", &alloc);
        Str str3 = StrInitFromZstr("c", &alloc);
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("a", &alloc);
        Str str2 = StrInitFromZstr("b", &alloc);
        Str str3 = StrInitFromZstr("c", &alloc);
        Str str1 = StrInitFromZstr("a", &alloc);
        Str str2 = StrInitFromZstr("b", &alloc);
        Str str3 = StrInitFromZstr("c", &alloc);
    
        VecPushBack(&strings, str1);
    typedef struct Person {
        u64  id;
        Str  name;
        u32  age;
        bool is_active;
        bool debug_mode;
        u32  timeout;
        Str  log_level;
    } Config;
    typedef struct SimpleProduct {
        u64 id;
        Str name;
        f64 price;
        Vec(Str) tags;
        Str name;
        f64 price;
        Vec(Str) tags;
    } SimpleProduct;
    
    // Helper function to compare expected JSON strings (removes spaces for comparison)
    bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected, alloc);
    bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
    
        // Remove spaces and newlines from both strings for comparison
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Str name = StrInitFromZstr("Alice", &alloc);
        Str  json    = StrInit(&alloc);
    
        Str name = StrInitFromZstr("Alice", &alloc);
        Str city = StrInitFromZstr("New York", &alloc);
    
        Str name = StrInitFromZstr("Alice", &alloc);
        Str city = StrInitFromZstr("New York", &alloc);
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        u32 count = 42;
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        bool enabled = true;
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Person person = {1001, StrInitFromZstr("Bob", &alloc), 25, true, 50000.0};
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Config config = {false, 30, StrInitFromZstr("INFO", &alloc)};
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
        Str  json    = StrInit(&alloc);
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Create strings and push them properly
    
        // Create strings and push them properly
        Str lang1 = StrInitFromZstr("C", &alloc);
        Str lang2 = StrInitFromZstr("Python", &alloc);
        Str lang3 = StrInitFromZstr("Rust", &alloc);
        // Create strings and push them properly
        Str lang1 = StrInitFromZstr("C", &alloc);
        Str lang2 = StrInitFromZstr("Python", &alloc);
        Str lang3 = StrInitFromZstr("Rust", &alloc);
        Str lang1 = StrInitFromZstr("C", &alloc);
        Str lang2 = StrInitFromZstr("Python", &alloc);
        Str lang3 = StrInitFromZstr("Rust", &alloc);
    
        VecPushBack(&languages, lang1);
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        struct {
        struct {
            struct {
                Str name;
                Str email;
            } user;
            struct {
                Str name;
                Str email;
            } user;
            bool active;
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        SimpleProduct product = {0};
    
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("electronics", &alloc);
        Str tag2 = StrInitFromZstr("computers", &alloc);
        Str tag3 = StrInitFromZstr("portable", &alloc);
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("electronics", &alloc);
        Str tag2 = StrInitFromZstr("computers", &alloc);
        Str tag3 = StrInitFromZstr("portable", &alloc);
        Str tag1 = StrInitFromZstr("electronics", &alloc);
        Str tag2 = StrInitFromZstr("computers", &alloc);
        Str tag3 = StrInitFromZstr("portable", &alloc);
    
        VecPushBack(&product.tags, tag1);
    
    // Helper function to compare JSON output (removes spaces for comparison)
    bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected, alloc);
    bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
        Str expected_str   = StrInitFromZstr(expected, alloc);
        Str output_clean   = StrInit(alloc);
        Str expected_clean = StrInit(alloc);
    
        // Remove spaces and newlines from both strings for comparison
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        // Write completely empty object
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Vec(i32) empty_numbers = VecInit(&alloc);
    
        Vec(i32) empty_numbers = VecInit(&alloc);
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Str empty_name = StrInit(&alloc);
        Str  json    = StrInit(&alloc);
    
        Str empty_name = StrInit(&alloc);
        Str empty_desc = StrInit(&alloc);
    
        Str empty_name = StrInit(&alloc);
        Str empty_desc = StrInit(&alloc);
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        i32 temp    = -25;
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        i64 big_int     = 9223372036854775807LL;
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        i32  int_zero   = 0;
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        // Note: These are the actual characters, not escape sequences
    
        // Note: These are the actual characters, not escape sequences
        Str path    = StrInitFromZstr("C:\\Program Files\\App", &alloc);
        Str message = StrInitFromZstr("Hello, \"World\"!", &alloc);
        Str data    = StrInitFromZstr("line1\nline2\ttab", &alloc);
        // Note: These are the actual characters, not escape sequences
        Str path    = StrInitFromZstr("C:\\Program Files\\App", &alloc);
        Str message = StrInitFromZstr("Hello, \"World\"!", &alloc);
        Str data    = StrInitFromZstr("line1\nline2\ttab", &alloc);
        Str path    = StrInitFromZstr("C:\\Program Files\\App", &alloc);
        Str message = StrInitFromZstr("Hello, \"World\"!", &alloc);
        Str data    = StrInitFromZstr("line1\nline2\ttab", &alloc);
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        // These contain actual special characters that should be escaped
    
        // These contain actual special characters that should be escaped
        Str quotes    = StrInitFromZstr("\"quotes\"", &alloc);
        Str backslash = StrInitFromZstr("\\", &alloc);
        Str newline   = StrInitFromZstr("\n", &alloc);
        // These contain actual special characters that should be escaped
        Str quotes    = StrInitFromZstr("\"quotes\"", &alloc);
        Str backslash = StrInitFromZstr("\\", &alloc);
        Str newline   = StrInitFromZstr("\n", &alloc);
        Str tab       = StrInitFromZstr("\t", &alloc);
        Str quotes    = StrInitFromZstr("\"quotes\"", &alloc);
        Str backslash = StrInitFromZstr("\\", &alloc);
        Str newline   = StrInitFromZstr("\n", &alloc);
        Str tab       = StrInitFromZstr("\t", &alloc);
        Str backslash = StrInitFromZstr("\\", &alloc);
        Str newline   = StrInitFromZstr("\n", &alloc);
        Str tab       = StrInitFromZstr("\t", &alloc);
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Vec(i32) empty_list = VecInit(&alloc);
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        Vec(i32) empty_arr  = VecInit(&alloc);
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        i64 max_int   = 2147483647LL;
    
        bool success = true;
        Str  json    = StrInit(&alloc);
    
        f64 tiny          = 0.000001;
    
        bool success = true;
        Str  json1   = StrInit(&alloc);
        Str  json2   = StrInit(&alloc);
        Str  json3   = StrInit(&alloc);
        bool success = true;
        Str  json1   = StrInit(&alloc);
        Str  json2   = StrInit(&alloc);
        Str  json3   = StrInit(&alloc);
        Str  json4   = StrInit(&alloc);
        Str  json1   = StrInit(&alloc);
        Str  json2   = StrInit(&alloc);
        Str  json3   = StrInit(&alloc);
        Str  json4   = StrInit(&alloc);
        Str  json2   = StrInit(&alloc);
        Str  json3   = StrInit(&alloc);
        Str  json4   = StrInit(&alloc);
    
        // Single integer
    
        // Single string
        Str single_str = StrInitFromZstr("hello", &alloc);
        JW_OBJ(json2, { JW_STR_KV(json2, "text", single_str); });
        u64  analysis_id;
        u64  binary_id;
        Str  analysis_name;
        Str  function_name;
        Str  sha256;
        u64  binary_id;
        Str  analysis_name;
        Str  function_name;
        Str  sha256;
        bool debug;
        Str  analysis_name;
        Str  function_name;
        Str  sha256;
        bool debug;
        Str  function_mangled_name;
        Str  sha256;
        bool debug;
        Str  function_mangled_name;
    } AnnSymbol;
    typedef struct ApiResponse {
        bool       status;
        Str        message;
        AnnSymbols data;
    } ApiResponse;
    typedef struct FunctionInfo {
        u64 id;
        Str name;
        u64 size;
        u64 vaddr;
    typedef struct ModelInfo {
        u64 id;
        Str name;
    } ModelInfo;
    typedef struct SearchResult {
        u64 binary_id;
        Str binary_name;
        u64 analysis_id;
        Str sha256;
        Str binary_name;
        u64 analysis_id;
        Str sha256;
        Vec(Str) tags;
        Str created_at;
        u64 analysis_id;
        Str sha256;
        Vec(Str) tags;
        Str created_at;
        u64 model_id;
        Str sha256;
        Vec(Str) tags;
        Str created_at;
        u64 model_id;
        Str model_name;
        Str created_at;
        u64 model_id;
        Str model_name;
        Str owned_by;
    } SearchResult;
        u64 model_id;
        Str model_name;
        Str owned_by;
    } SearchResult;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str     json = StrInitFromZstr("{\"test\": \"value\"}", &alloc);
        StrIter si   = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"id\": 12345, \"name\": \"test\", \"active\": true, \"score\": 98.5}", &alloc);
        StrIter si      = StrIterFromStr(json);
        struct {
            u64  id;
            Str  name;
            bool active;
            f64  score;
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"user\": {\"id\": 123, \"profile\": {\"name\": \"Alice\", \"age\": 30}}, \"status\": \"active\"}",
            &alloc
                u64 id;
                struct {
                    Str name;
                    u64 age;
                } profile;
                } profile;
            } user;
            Str status;
        } data = {
            {0, {StrInit(&alloc), 0}},
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"company\": {\"departments\": {\"engineering\": {\"head\": \"John\", \"count\": 25, \"budget\": 150000.0}}, "
                "\"name\": \"TechCorp\"}}",
                struct {
                    struct {
                        Str head;
                        u64 count;
                        f64 budget;
                    } engineering;
                } departments;
                Str name;
            } company;
        } data = {
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"functions\": {\"12345\": {\"67890\": {\"distance\": 0.85, \"name\": \"main\"}}, \"54321\": {\"98765\": "
                "{\"distance\": 0.92, \"name\": \"helper\"}}}}",
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"status\": true, \"message\": \"Success\", \"data\": {\"12345\": {\"67890\": {\"distance\": 0.85, "
                "\"nearest_neighbor_analysis_id\": 999, \"nearest_neighbor_binary_id\": 888, "
    
        bool    success = true;
        Str     json = StrInitFromZstr("{\"id\": 12345, \"name\": \"test_func\", \"size\": 1024, \"vaddr\": 4096}", &alloc);
        StrIter si   = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"id\": 54321, \"name\": \"test_model\"}", &alloc);
        StrIter si      = StrIterFromStr(json);
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"binary_id\": 888, \"binary_name\": \"test_binary\", \"analysis_id\": 999, \"sha256\": \"abc123\", "
                "\"created_at\": \"2024-04-01\", \"model_id\": 12345, \"model_name\": \"test_model\", \"owned_by\": \"user1\"}",
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"status\": true, \"message\": \"Success\", \"data\": {\"12345\": {\"67890\": {\"distance\": 0.85, "
                "\"nearest_neighbor_analysis_id\": 999, \"nearest_neighbor_binary_id\": 888, "
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"status\": true, \"message\": \"Success\", \"data\": {\"12345\": {\"67890\": {\"distance\": 0.85, "
                "\"nearest_neighbor_analysis_id\": 999, \"nearest_neighbor_binary_id\": 888, "
    typedef struct Person {
        u64  id;
        Str  name;
        u32  age;
        bool is_active;
        bool debug_mode;
        u32  timeout;
        Str  log_level;
    } Config;
    typedef struct SimpleProduct {
        u64 id;
        Str name;
        f64 price;
        Vec(Str) tags;
        Str name;
        f64 price;
        Vec(Str) tags;
    } SimpleProduct;
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"name\": \"Alice\", \"city\": \"New York\"}", &alloc);
        StrIter si      = StrIterFromStr(json);
        StrIter si      = StrIterFromStr(json);
    
        Str name = StrInit(&alloc);
        Str city = StrInit(&alloc);
    
        Str name = StrInit(&alloc);
        Str city = StrInit(&alloc);
    
        JR_OBJ(si, {
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"count\": 42, \"score\": 95.5, \"year\": 2024}", &alloc);
        StrIter si      = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"enabled\": true, \"visible\": false}", &alloc);
        StrIter si      = StrIterFromStr(json);
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"id\": 1001, \"name\": \"Bob\", \"age\": 25, \"is_active\": true, \"salary\": 50000.0}",
            &alloc
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"debug_mode\": false, \"timeout\": 30, \"log_level\": \"INFO\"}", &alloc);
        StrIter si      = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"languages\": [\"C\", \"Python\", \"Rust\"]}", &alloc);
        StrIter si      = StrIterFromStr(json);
        StrIter si      = StrIterFromStr(json);
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        JR_OBJ(si, {
        JR_OBJ(si, {
            JR_ARR_KV(si, "languages", {
                Str lang = StrInit(&alloc);
                JR_STR(si, lang);
                VecPushBack(&languages, lang);
    
        if (VecLen(&languages) >= 3) {
            Str *lang1 = &VecAt(&languages, 0);
            Str *lang2 = &VecAt(&languages, 1);
            Str *lang3 = &VecAt(&languages, 2);
        if (VecLen(&languages) >= 3) {
            Str *lang1 = &VecAt(&languages, 0);
            Str *lang2 = &VecAt(&languages, 1);
            Str *lang3 = &VecAt(&languages, 2);
            Str *lang1 = &VecAt(&languages, 0);
            Str *lang2 = &VecAt(&languages, 1);
            Str *lang3 = &VecAt(&languages, 2);
    
            if (StrCmp(lang1, "C", 1) != 0) {
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"user\": {\"name\": \"Charlie\", \"email\": \"charlie@example.com\"}, \"active\": true}",
            &alloc
        struct {
            struct {
                Str name;
                Str email;
            } user;
            struct {
                Str name;
                Str email;
            } user;
            bool active;
    
        bool success = true;
        Str  json    = StrInitFromZstr(
            "{\"id\": 12345, \"name\": \"Laptop\", \"price\": 999.99, \"tags\": [\"electronics\", \"computers\", "
                "\"portable\"]}",
            JR_FLT_KV(si, "price", product.price);
            JR_ARR_KV(si, "tags", {
                Str tag = StrInit(&alloc);
                JR_STR(si, tag);
                VecPushBack(&product.tags, tag);
    
        if (VecLen(&product.tags) >= 3) {
            Str *tag1 = &VecAt(&product.tags, 0);
            Str *tag2 = &VecAt(&product.tags, 1);
            Str *tag3 = &VecAt(&product.tags, 2);
        if (VecLen(&product.tags) >= 3) {
            Str *tag1 = &VecAt(&product.tags, 0);
            Str *tag2 = &VecAt(&product.tags, 1);
            Str *tag3 = &VecAt(&product.tags, 2);
            Str *tag1 = &VecAt(&product.tags, 0);
            Str *tag2 = &VecAt(&product.tags, 1);
            Str *tag3 = &VecAt(&product.tags, 2);
    
            if (StrCmp(tag1, "electronics", 11) != 0) {
    typedef struct TestPerson {
        u64  id;
        Str  name;
        u32  age;
        bool is_active;
        bool debug_mode;
        u32  timeout;
        Str  log_level;
        Vec(Str) features;
    } TestConfig;
        u32  timeout;
        Str  log_level;
        Vec(Str) features;
    } TestConfig;
    // Helper function to compare persons
    bool compare_persons(const TestPerson *a, const TestPerson *b) {
        return a->id == b->id && StrCmp((Str *)&a->name, (Str *)&b->name) == 0 && a->age == b->age &&
               a->is_active == b->is_active && a->salary == b->salary;
    }
    bool compare_configs(const TestConfig *a, const TestConfig *b) {
        if (a->debug_mode != b->debug_mode || a->timeout != b->timeout ||
            StrCmp((Str *)&a->log_level, (Str *)&b->log_level) != 0 ||
            VecLen(&a->features) != VecLen(&b->features)) {
            return false;
    
        for (size i = 0; i < VecLen(&a->features); i++) {
            if (StrCmp((Str *)&VecAt(&a->features, i), (Str *)&VecAt(&b->features, i)) != 0) {
                return false;
            }
            f64  temperature;
            bool enabled;
            Str  message;
        } original = {42, 25.5, true, StrInitFromZstr("hello world", &alloc)};
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_INT_KV(json, "count", original.count);
            f64  temperature;
            bool enabled;
            Str  message;
        } parsed = {0, 0.0, false, StrInit(&alloc)};
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_INT_KV(json, "big_int", original.big_int);
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_BOOL_KV(json, "flag1", original.flag1);
        // Original data with various string types
        struct {
            Str empty;
            Str simple;
            Str with_spaces;
        struct {
            Str empty;
            Str simple;
            Str with_spaces;
            Str with_special;
            Str empty;
            Str simple;
            Str with_spaces;
            Str with_special;
        } original = {
            Str simple;
            Str with_spaces;
            Str with_special;
        } original = {
            StrInit(&alloc),
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_STR_KV(json, "empty", original.empty);
        // Read back from JSON
        struct {
            Str empty;
            Str simple;
            Str with_spaces;
        struct {
            Str empty;
            Str simple;
            Str with_spaces;
            Str with_special;
            Str empty;
            Str simple;
            Str with_spaces;
            Str with_special;
        } parsed = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
            Str simple;
            Str with_spaces;
            Str with_special;
        } parsed = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
        // Original data
        Vec(i32) original_numbers = VecInit(&alloc);
        Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Populate arrays
    
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("first", &alloc);
        Str str2 = StrInitFromZstr("second", &alloc);
        Str str3 = StrInitFromZstr("", &alloc);
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("first", &alloc);
        Str str2 = StrInitFromZstr("second", &alloc);
        Str str3 = StrInitFromZstr("", &alloc);
        Str str4 = StrInitFromZstr("last", &alloc);
        Str str1 = StrInitFromZstr("first", &alloc);
        Str str2 = StrInitFromZstr("second", &alloc);
        Str str3 = StrInitFromZstr("", &alloc);
        Str str4 = StrInitFromZstr("last", &alloc);
        Str str2 = StrInitFromZstr("second", &alloc);
        Str str3 = StrInitFromZstr("", &alloc);
        Str str4 = StrInitFromZstr("last", &alloc);
    
        VecPushBack(&original_strings, str1);
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_ARR_KV(json, "numbers", original_numbers, num, { JW_INT(json, num); });
        // Read back from JSON
        Vec(i32) parsed_numbers = VecInit(&alloc);
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        StrIter si = StrIterFromStr(json);
            });
            JR_ARR_KV(si, "strings", {
                Str str = StrInit(&alloc);
                JR_STR(si, str);
                VecPushBack(&parsed_strings, str);
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_OBJ_KV(json, "user", {
    
        // Create strings and push them properly
        Str feature1 = StrInitFromZstr("auth", &alloc);
        Str feature2 = StrInitFromZstr("logging", &alloc);
        // Create strings and push them properly
        Str feature1 = StrInitFromZstr("auth", &alloc);
        Str feature2 = StrInitFromZstr("logging", &alloc);
    
        VecPushBack(&original.config.features, feature1);
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_OBJ_KV(json, "user", {
                JR_STR_KV(si, "log_level", parsed.config.log_level);
                JR_ARR_KV(si, "features", {
                    Str feature = StrInit(&alloc);
                    JR_STR(si, feature);
                    VecPushBack(&parsed.config.features, feature);
        // Original empty data
        Vec(i32) empty_numbers = VecInit(&alloc);
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
        Str empty_str          = StrInit(&alloc);
        Vec(i32) empty_numbers = VecInit(&alloc);
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
        Str empty_str          = StrInit(&alloc);
    
        // Write to JSON
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_STR_KV(json, "empty_string", empty_str);
        // Read back from JSON
        Vec(i32) parsed_numbers = VecInit(&alloc);
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
        Str  parsed_str         = StrInit(&alloc);
        bool found_empty_object = false;
        Vec(i32) parsed_numbers = VecInit(&alloc);
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
        Str  parsed_str         = StrInit(&alloc);
        bool found_empty_object = false;
            });
            JR_ARR_KV(si, "empty_strings", {
                Str str = StrInit(&alloc);
                JR_STR(si, str);
                VecPushBack(&parsed_strings, str);
    
        // Write to JSON
        Str json = StrInit(&alloc);
        JW_OBJ(json, {
            JW_INT_KV(json, "max_int", original.max_int);
        DefaultAllocator alloc = DefaultAllocatorInit();
        KvConfig         cfg   = KvConfigInit(&alloc);
        Str              src   = StrInitFromZstr(
            "host = localhost\n"
                           "port = 8080\n"
        StrIter input  = StrIterFromStr(src);
        StrIter si     = KvConfigParse(input, &cfg);
        Str    *host   = KvConfigGetPtr(&cfg, "host");
        i64     port   = 0;
        bool    debug  = false;
        DefaultAllocator alloc = DefaultAllocatorInit();
        KvConfig         cfg   = KvConfigInit(&alloc);
        Str              src   = StrInitFromZstr(
            "# comment line\n"
                           "path = \"/srv/my app\"   # keep spaces in quotes\n"
        StrIter input  = StrIterFromStr(src);
        StrIter si     = KvConfigParse(input, &cfg);
        Str    *path   = KvConfigGetPtr(&cfg, "path");
        Str    *user   = KvConfigGetPtr(&cfg, "user");
        Str    *greet  = KvConfigGetPtr(&cfg, "greeting");
        StrIter si     = KvConfigParse(input, &cfg);
        Str    *path   = KvConfigGetPtr(&cfg, "path");
        Str    *user   = KvConfigGetPtr(&cfg, "user");
        Str    *greet  = KvConfigGetPtr(&cfg, "greeting");
        Str    *empty  = KvConfigGetPtr(&cfg, "empty");
        Str    *path   = KvConfigGetPtr(&cfg, "path");
        Str    *user   = KvConfigGetPtr(&cfg, "user");
        Str    *greet  = KvConfigGetPtr(&cfg, "greeting");
        Str    *empty  = KvConfigGetPtr(&cfg, "empty");
        bool    result = true;
        Str    *user   = KvConfigGetPtr(&cfg, "user");
        Str    *greet  = KvConfigGetPtr(&cfg, "greeting");
        Str    *empty  = KvConfigGetPtr(&cfg, "empty");
        bool    result = true;
        DefaultAllocator alloc       = DefaultAllocatorInit();
        KvConfig         cfg         = KvConfigInit(&alloc);
        Str              src         = StrInitFromZstr("host = localhost\n", &alloc);
        StrIter          input       = StrIterFromStr(src);
        Str              host_copy   = StrInit(&alloc);
        Str              src         = StrInitFromZstr("host = localhost\n", &alloc);
        StrIter          input       = StrIterFromStr(src);
        Str              host_copy   = StrInit(&alloc);
        Str             *stored_host = NULL;
        bool             result      = true;
        StrIter          input       = StrIterFromStr(src);
        Str              host_copy   = StrInit(&alloc);
        Str             *stored_host = NULL;
        bool             result      = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
        KvConfig         cfg   = KvConfigInit(&alloc);
        Str              src   = StrInitFromZstr(
            "workers = 16\n"
                           "pi = 3.14159\n"
        DefaultAllocator alloc = DefaultAllocatorInit();
        KvConfig         cfg   = KvConfigInit(&alloc);
        Str              src   = StrInitFromZstr(
            "valid = yes\n"
                           "broken line\n"
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Pop a character from the back
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Pop a character from the front
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Remove a character from the middle
    
    
        Str s = StrInitFromZstr("Hello World", &alloc);
    
        // Create a buffer to store the removed characters
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Delete the last character
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Delete a character from the middle
    
    
        Str s = StrInitFromZstr("Hello World", &alloc);
    
        // Delete a range of characters
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Remove tests\n\n");
    
        // Array of test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, NULL, 0, "Str.Remove");
    }
    
        HttpResponse response = HttpResponseInit(alloc_base);
        Str          body     = StrInit(alloc_base);
        StrAppendFmt(&body, "<h1>hi</h1>");
        HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &body);
        StrDeinit(&body);
    
        Str wire = HttpResponseSerialize(&response, alloc_base);
    
        // Spot-check the wire format:
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    
    
        Str s = StrInit(&alloc);
    
        // Reserve more space than needed
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Swap 'H' and 'o'
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Initial length should be 5
    
    
        Str s = StrInit(&alloc);
    
        // Reserve more space
    
    
        Str s = StrInitFromZstr("Hello, World!", &alloc);
    
        // Initial length should be 13
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Reverse the string
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Memory tests\n\n");
    
        // Array of test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, NULL, 0, "Str.Memory");
    }
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr("Hello", &alloc);
        Str s3 = StrInitFromZstr("World", &alloc);
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr("Hello", &alloc);
        Str s3 = StrInitFromZstr("World", &alloc);
        Str s4 = StrInitFromZstr("Hello World", &alloc);
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr("Hello", &alloc);
        Str s3 = StrInitFromZstr("World", &alloc);
        Str s4 = StrInitFromZstr("Hello World", &alloc);
        Str s2 = StrInitFromZstr("Hello", &alloc);
        Str s3 = StrInitFromZstr("World", &alloc);
        Str s4 = StrInitFromZstr("Hello World", &alloc);
    
        // Test StrCmp with equal strings
    
    
        Str haystack = StrInitFromZstr("Hello World", &alloc);
        Str needle1  = StrInitFromZstr("World", &alloc);
        Str needle2  = StrInitFromZstr("Hello", &alloc);
    
        Str haystack = StrInitFromZstr("Hello World", &alloc);
        Str needle1  = StrInitFromZstr("World", &alloc);
        Str needle2  = StrInitFromZstr("Hello", &alloc);
        Str needle3  = StrInitFromZstr("NotFound", &alloc);
        Str haystack = StrInitFromZstr("Hello World", &alloc);
        Str needle1  = StrInitFromZstr("World", &alloc);
        Str needle2  = StrInitFromZstr("Hello", &alloc);
        Str needle3  = StrInitFromZstr("NotFound", &alloc);
        Str needle1  = StrInitFromZstr("World", &alloc);
        Str needle2  = StrInitFromZstr("Hello", &alloc);
        Str needle3  = StrInitFromZstr("NotFound", &alloc);
    
        // Test StrFind (Str * key) with match at end
    
    
        Str haystack = StrInitFromZstr("Hello World", &alloc);
        Str needle   = StrInitFromZstr("World", &alloc);
    
        Str haystack = StrInitFromZstr("Hello World", &alloc);
        Str needle   = StrInitFromZstr("World", &alloc);
    
        bool result = StrContains(&haystack, &needle);
    
    
        Str s      = StrInitFromZstr("Hello World", &alloc);
        Str prefix = StrInitFromZstr("Hello", &alloc);
        Str suffix = StrInitFromZstr("World", &alloc);
    
        Str s      = StrInitFromZstr("Hello World", &alloc);
        Str prefix = StrInitFromZstr("Hello", &alloc);
        Str suffix = StrInitFromZstr("World", &alloc);
        Str s      = StrInitFromZstr("Hello World", &alloc);
        Str prefix = StrInitFromZstr("Hello", &alloc);
        Str suffix = StrInitFromZstr("World", &alloc);
    
        // Test Str-form
    
        // Test Zstr-form (string literals)
        Str s1 = StrInitFromZstr("Hello World", &alloc);
        StrReplace(&s1, "World", "Universe", 1);
        bool result = (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);
        StrDeinit(&s1);
        s1          = StrInitFromZstr("Hello World", &alloc);
        Str find    = StrInitFromZstr("World", &alloc);
        Str replace = StrInitFromZstr("Universe", &alloc);
        StrReplace(&s1, &find, &replace, 1);
        s1          = StrInitFromZstr("Hello World", &alloc);
        Str find    = StrInitFromZstr("World", &alloc);
        Str replace = StrInitFromZstr("Universe", &alloc);
        StrReplace(&s1, &find, &replace, 1);
        result = result && (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);
    
        // Test StrSplit
        Str  s     = StrInitFromZstr("Hello,World,Test", &alloc);
        Strs split = StrSplit(&s, ",");
    
        // Test StrLStrip
        Str  s1       = StrInitFromZstr("  Hello  ", &alloc);
        Str  stripped = StrLStrip(&s1, NULL);
        bool result   = (ZstrCompare(StrBegin(&stripped), "Hello  ") == 0);
        // Test StrLStrip
        Str  s1       = StrInitFromZstr("  Hello  ", &alloc);
        Str  stripped = StrLStrip(&s1, NULL);
        bool result   = (ZstrCompare(StrBegin(&stripped), "Hello  ") == 0);
        StrDeinit(&stripped);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str hello_lc = StrInitFromZstr("hello", &alloc);
        Str hello_uc = StrInitFromZstr("HELLO", &alloc);
        Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
    
        Str hello_lc = StrInitFromZstr("hello", &alloc);
        Str hello_uc = StrInitFromZstr("HELLO", &alloc);
        Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
        Str world    = StrInitFromZstr("world", &alloc);
        Str hello_lc = StrInitFromZstr("hello", &alloc);
        Str hello_uc = StrInitFromZstr("HELLO", &alloc);
        Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
        Str world    = StrInitFromZstr("world", &alloc);
        Str hello_x  = StrInitFromZstr("HelloX", &alloc); // longer
        Str hello_uc = StrInitFromZstr("HELLO", &alloc);
        Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
        Str world    = StrInitFromZstr("world", &alloc);
        Str hello_x  = StrInitFromZstr("HelloX", &alloc); // longer
        Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
        Str world    = StrInitFromZstr("world", &alloc);
        Str hello_x  = StrInitFromZstr("HelloX", &alloc); // longer
    
        // Equal under ASCII case folding.
    
        // Non-ASCII bytes pass through verbatim (no Unicode folding).
        Str non_ascii_a = StrInitFromZstr("ABC\xC0", &alloc);
        Str non_ascii_b = StrInitFromZstr("abc\xC0", &alloc);
        ok              = ok && StrCmpIgnoreCase(&non_ascii_a, &non_ascii_b) == 0;
        // Non-ASCII bytes pass through verbatim (no Unicode folding).
        Str non_ascii_a = StrInitFromZstr("ABC\xC0", &alloc);
        Str non_ascii_b = StrInitFromZstr("abc\xC0", &alloc);
        ok              = ok && StrCmpIgnoreCase(&non_ascii_a, &non_ascii_b) == 0;
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Ops tests\n\n");
    
        // Array of test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, NULL, 0, "Str.Ops");
    }
    
        Int value = IntFrom(13, ALLOCATOR_OF(&alloc));
        Str text  = IntToBinary(&value);
    
        bool result = IntBitLength(&value) == 4;
        Int value   = IntFromBytesLE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
        u64 written = IntToBytesLE(&value, out, sizeof(out));
        Str text    = IntToHexStr(&value);
    
        bool result = written == 4;
        Int value   = IntFromBytesBE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
        u64 written = IntToBytesBE(&value, out, sizeof(out));
        Str text    = IntToHexStr(&value);
    
        bool result = written == 4;
    
        Int value = IntFromBinary("001011", ALLOCATOR_OF(&alloc));
        Str text  = IntToBinary(&value);
    
        bool result = IntToU64(&value) == 11;
        Zstr digits = "123456789012345678901234567890";
        Int  value  = IntFromStr(digits, ALLOCATOR_OF(&alloc));
        Str  text   = IntToStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), digits) == 0;
    
        Int value = IntFromStrRadix("zz", 36, ALLOCATOR_OF(&alloc));
        Str text  = IntToStrRadix(&value, 36, false);
    
        bool result = IntToU64(&value) == 1295;
    
        Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
        Str text  = IntToStrRadix(&value, 16, true);
    
        bool result = ZstrCompare(StrBegin(&text), "BEEF") == 0;
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              text;
        bool             ok;
    
        Int  zero  = IntFromBinary("0", ALLOCATOR_OF(&alloc));
        Str  text  = IntToBinary(&zero);
        bool error = true;
    
        Int value = IntFromOctStr("0o7_55", ALLOCATOR_OF(&alloc));
        Str text  = IntToOctStr(&value);
    
        bool result = IntToU64(&value) == 493;
        Zstr hex   = "deadbeefcafebabe1234";
        Int  value = IntFromHexStr(hex, ALLOCATOR_OF(&alloc));
        Str  text  = IntToHexStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), hex) == 0;
    
        Int value = IntFrom(255, ALLOCATOR_OF(&alloc));
        Str text  = IntToStrRadix(&value, 37, false);
    
        bool result = StrLen(&text) == 0;
        size       n = bt_capture_outer(frames, 32);
    
        Str rendered = StrInit(alloc_base);
        FormatStackTrace(&rendered, frames, n, alloc_base);
        ok                 = ok && VecLen(&frames) >= 2;
    
        Str rendered = StrInit(alloc_base);
        FormatStackTrace(&rendered, &frames, alloc_base);
        size       n = bt_capture_outer(frames, 16);
    
        Str out = StrInit(alloc_base);
        FormatStackTraceWith(&out, frames, n, &res);
        size       n = cfi_capture_outer(&res, frames, 32);
    
        Str rendered = StrInit(alloc_base);
        FormatStackTraceWith(&rendered, frames, n, &res);
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    
    
        Str s = StrInit(&alloc);
    
        // Test decimal conversion
    
    
        Str s = StrInit(&alloc);
    
        // Test positive decimal conversion
    
    
        Str s = StrInit(&alloc);
    
        // Test integer conversion
    
        // Test decimal conversion
        Str  s       = StrInitFromZstr("12345", &alloc);
        u64  value   = 0;
        bool success = StrToU64(&s, &value, NULL);
    
        // Test positive decimal conversion
        Str  s       = StrInitFromZstr("12345", &alloc);
        i64  value   = 0;
        bool success = StrToI64(&s, &value, NULL);
    
        // Test integer conversion
        Str  s       = StrInitFromZstr("123", &alloc);
        f64  value   = 0.0;
        bool success = StrToF64(&s, &value, NULL);
    // Round-trip conversion tests
    bool test_str_round_trip_conversions(void) {
        WriteFmt("Testing Str round-trip conversions\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        for (size i = 0; i < sizeof(u64_values) / sizeof(u64_values[0]); i++) {
            Str s = StrInit(&alloc);
    
            // Test decimal round-trip
    
        for (size i = 0; i < sizeof(i64_values) / sizeof(i64_values[0]); i++) {
            Str s = StrInit(&alloc);
    
            // Test decimal round-trip
        for (size i = 0; i < sizeof(f64_values) / sizeof(f64_values[0]); i++) {
            for (u8 precision = 1; precision <= 6; precision++) {
                Str s = StrInit(&alloc);
    
                StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};
    // Edge case conversion tests
    bool test_str_edge_case_conversions(void) {
        WriteFmt("Testing Str edge case conversions\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Test base boundary conditions
        for (u8 base = 2; base <= 36; base++) {
            Str s = StrInit(&alloc);
    
            // Test with base value itself
    
        // Test extreme values
        Str s = StrInit(&alloc);
    
        // Test maximum u64
    
        for (size i = 0; i < sizeof(prefix_tests) / sizeof(prefix_tests[0]); i++) {
            Str            test_str = StrInitFromZstr(prefix_tests[i].input, &alloc);
            u64            value    = 0;
            StrParseConfig config   = {.base = prefix_tests[i].base};
    // Precision limits testing
    bool test_str_precision_limits(void) {
        WriteFmt("Testing Str precision limits\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        for (u8 precision = 1; precision <= 17; precision++) {
            Str s = StrInit(&alloc);
    
            StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};
    
        for (size i = 0; i < sizeof(sci_values) / sizeof(sci_values[0]); i++) {
            Str s = StrInit(&alloc);
    
            // Force scientific notation
    
        for (u8 base = 2; base <= 36; base++) {
            Str s = StrInit(&alloc);
    
            StrIntFormat config = {.base = base, .uppercase = false};
    // Large-scale conversion tests
    bool test_str_all_base_support(void) {
        WriteFmt("Testing Str all bases 2-36 support\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Test each base from 2 to 36
        for (u8 base = 2; base <= 36; base++) {
            Str s = StrInit(&alloc);
    
            // Test StrFromU64
        // Test uppercase digits for bases that use letters (11-36)
        for (u8 base = 11; base <= 36; base++) {
            Str s = StrInit(&alloc);
    
            StrIntFormat config = {.base = base, .uppercase = true, .use_prefix = false};
        for (size i = 0; i < sizeof(test_values) / sizeof(test_values[0]); i++) {
            for (u8 base = 2; base <= 36; base++) {
                Str s = StrInit(&alloc);
    
                StrIntFormat config = {.base = base, .uppercase = false, .use_prefix = false};
    
    bool test_str_large_scale_conversions(void) {
        WriteFmt("Testing Str large-scale conversions\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
            u64 test_value = i * 1000007; // Large prime multiplier
    
            Str          s      = StrInit(&alloc);
            StrIntFormat config = {.base = 10, .uppercase = false};
            StrFromU64(&s, test_value, &config);
                f64 test_value = mantissa * F64Pow((10.0), (i32)(exp));
    
                Str            s      = StrInit(&alloc);
                StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};
                StrFromF64(&s, test_value, &config);
        MemCopy(long_number, "12345678901234567890123456789012345678901234567890", 51);
    
        Str  long_str   = StrInitFromZstr(long_number, &alloc);
        u64  long_value = 0;
        bool success    = StrToU64(&long_str, &long_value, NULL);
    // Deadend tests for NULL pointer handling
    bool test_str_conversion_null_failures(void) {
        WriteFmt("Testing Str conversion NULL pointer handling\n");
    
        // Test NULL string pointer - should abort
    
    bool test_str_conversion_bounds_failures(void) {
        WriteFmt("Testing Str conversion bounds failures\n");
    
        // Test StrFromI64 with NULL pointer - should abort
    
    bool test_str_conversion_invalid_input_failures(void) {
        WriteFmt("Testing Str conversion invalid input failures\n");
    
        // Test StrFromF64 with NULL pointer - should abort
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Convert tests\n\n");
    
        // Array of normal test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Str.Convert");
    }
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    
    
        Str s = StrInit(&alloc);
    
        bool result = (StrLen(&s) == 0);
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Get the first character
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Get the last character
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Get a pointer to the first character using StrBegin
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Get a pointer to one past the last character using StrEnd
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Access characters at different indices
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Access character pointers at different indices
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Access tests\n\n");
    
        // Array of test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, NULL, 0, "Str.Access");
    }
            return false;
        }
        Str        local_str = SocketAddrFormat(&local, a);
        SocketAddr connect_addr;
        bool       parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);
                return false;
            }
            Str rendered = SocketAddrFormat(&addr, alloc_base);
            ok           = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "127.0.0.1:8080") == 0;
            StrDeinit(&rendered);
                return false;
            }
            Str rendered = SocketAddrFormat(&addr, alloc_base);
            ok           = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "[::1]:8080") == 0;
            StrDeinit(&rendered);
    // seen. Log.h pulls Io.h, so it lives below the include of Io.h.
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
    // nested expansions from inside an outer writer's own body. Pattern A in
    // the extending-io guide.
    bool _write_Point2D(Str *o, FmtInfo *info, Point2D *p);
    Zstr _read_Point2D(Zstr i, FmtInfo *info, Point2D *p);
    bool _write_Bounds(Str *o, FmtInfo *info, Bounds *b);
    bool _write_Point2D(Str *o, FmtInfo *info, Point2D *p);
    Zstr _read_Point2D(Zstr i, FmtInfo *info, Point2D *p);
    bool _write_Bounds(Str *o, FmtInfo *info, Bounds *b);
    Zstr _read_Bounds(Zstr i, FmtInfo *info, Bounds *b);
    bool _write_Region(Str *o, FmtInfo *info, Region *r);
    bool _write_Bounds(Str *o, FmtInfo *info, Bounds *b);
    Zstr _read_Bounds(Zstr i, FmtInfo *info, Bounds *b);
    bool _write_Region(Str *o, FmtInfo *info, Region *r);
    Zstr _read_Region(Zstr i, FmtInfo *info, Region *r);
    Zstr _read_Region(Zstr i, FmtInfo *info, Region *r);
    
    bool _write_Point2D(Str *o, FmtInfo *info, Point2D *p) {
        (void)info;
        if (!o || !p) {
    // `_Generic` arm for `Point2D` resolves correctly from inside another
    // user-type writer.
    bool _write_Bounds(Str *o, FmtInfo *info, Bounds *b) {
        (void)info;
        if (!o || !b) {
    // a standalone Point2D plus an in-tree i32. Exercises a writer that mixes
    // nested user types, repeated user types, and built-ins in one call.
    bool _write_Region(Str *o, FmtInfo *info, Region *r) {
        (void)info;
        if (!o || !r) {
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Point2D p  = {.x = 3, .y = 4};
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Point2D p     = {.x = -1, .y = 2};
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Point2D src = {.x = 100, .y = -200};
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Bounds b = {
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Bounds src = {
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Region r = {
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Region src = {
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              out   = StrInit(&alloc);
    
        Region region = {
        bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET;
        if (ok) {
            Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
            ok    = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "203.0.113.7:9999") == 0;
            StrDeinit(&s);
        bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET6;
        if (ok) {
            Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
            // SocketAddrFormat emits the bracketed form for IPv6.
            ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "[::1]:443") == 0;
        if (ok) {
            VecForeachPtr(&out, ad) {
                Str s = SocketAddrFormat(ad, a);
                u64 L = StrLen(&s);
                if (L < 3 || StrBegin(&s)[L - 1] != '3' || StrBegin(&s)[L - 2] != '5' || StrBegin(&s)[L - 3] != ':') {
        bool ok = got && one.family == SOCKET_FAMILY_INET;
        if (ok) {
            Str s = SocketAddrFormat(&one, a);
            ok    = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "127.0.0.1:80") == 0;
            StrDeinit(&s);
        // counted as a leak by the very report we're about to generate.
        HeapAllocator scratch = HeapAllocatorInit();
        Str           out     = StrInit(&scratch);
        DebugAllocatorReportLeaks(&dbg, &out);
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Container/Int.h>
        bool success = true;
    
        Str s = StrInit(&alloc);
        z     = "Hello";
        StrReadFmt(z, "{}", s);
        StrReadFmt(z, "{}", s);
    
        Str expected = StrInitFromZstr("Hello", &alloc);
        success      = success && (StrCmp(&s, &expected) == 0);
        StrDeinit(&expected);
    
        i32 num  = 0;
        Str name = StrInit(&alloc);
        z        = "Count: 42, Name: Alice";
        StrReadFmt(z, "Count: {}, Name: {}", num, name);
        success = success && (num == 42);
    
        Str expected = StrInitFromZstr("Alice", &alloc);
        success      = success && (StrCmp(&name, &expected) == 0);
        StrDeinit(&expected);
        success = success && abc_pass;
    
        Str str_val = StrInit(&alloc);
        z           = "Hello";
        StrReadFmt(z, "{c}", str_val);
        z           = "Hello";
        StrReadFmt(z, "{c}", str_val);
        Str  expected = StrInitFromZstr("Hello", &alloc);
        bool str_pass = (StrCmp(&str_val, &expected) == 0);
        WriteFmt("str_val test: comparing with 'Hello', pass = {}\n", str_pass ? "true" : "false");
        // Test 1: :a (lowercase) conversion
        {
            Str  result = StrInit(&alloc);
            Zstr in     = "Hello World";
    
            // Should read "hello" (stops at first space)
            Str  expected   = StrInitFromZstr("hello world", &alloc);
            bool test1_pass = (StrCmp(&result, &expected) == 0);
            WriteFmt("Expected: 'hello', Pass: {}\n\n", test1_pass ? "true" : "false");
        // Test 1.1: :a (lowercase) conversion
        {
            Str  result = StrInit(&alloc);
            Zstr in     = "Hello World";
    
            // Should read "hello" (stops at first space)
            Str  expected   = StrInitFromZstr("hello", &alloc);
            bool test1_pass = (StrCmp(&result, &expected) == 0);
            WriteFmt("Expected: 'hello', Pass: {}\n\n", test1_pass ? "true" : "false");
        // Test 2: :A (uppercase) conversion
        {
            Str  result = StrInit(&alloc);
            Zstr in     = "hello world";
    
            // Should read "HELLO" (stops at first space)
            Str  expected   = StrInitFromZstr("HELLO WORLD", &alloc);
            bool test2_pass = (StrCmp(&result, &expected) == 0);
            WriteFmt("Expected: 'HELLO', Pass: {}\n\n", test2_pass ? "true" : "false");
        // Test 2.1: :A (uppercase) conversion
        {
            Str  result1 = StrInit(&alloc);
            Str  result2 = StrInit(&alloc);
            Zstr in      = "hello world";
        {
            Str  result1 = StrInit(&alloc);
            Str  result2 = StrInit(&alloc);
            Zstr in      = "hello world";
        // Test 2.2: :A (uppercase) conversion
        {
            Str  result1 = StrInit(&alloc);
            Str  result2 = StrInit(&alloc);
            Zstr in      = "hello world mighty misra";
        {
            Str  result1 = StrInit(&alloc);
            Str  result2 = StrInit(&alloc);
            Zstr in      = "hello world mighty misra";
        // Test 3: :a with quoted string
        {
            Str  result = StrInit(&alloc);
            Zstr in     = "\"MiXeD CaSe\"";
    
            // Should read "mixed case" (converts the entire quoted string)
            Str  expected   = StrInitFromZstr("mixed case", &alloc);
            bool test3_pass = (StrCmp(&result, &expected) == 0);
            WriteFmt("Expected: 'mixed case', Pass: {}\n\n", test3_pass ? "true" : "false");
        // Test 4: :A with quoted string containing special characters
        {
            Str  result = StrInit(&alloc);
            Zstr in     = "\"abc123XYZ\"";
    
            // Should read "ABC123XYZ" (only letters are converted, numbers unchanged)
            Str  expected   = StrInitFromZstr("ABC123XYZ", &alloc);
            bool test4_pass = (StrCmp(&result, &expected) == 0);
            WriteFmt("Expected: 'ABC123XYZ', Pass: {}\n\n", test4_pass ? "true" : "false");
        // Test 5: Regular :c format (no case conversion) for comparison
        {
            Str  result = StrInit(&alloc);
            Zstr in     = "Hello World";
    
            // Should read "Hello" (stops at first space, no case conversion)
            Str  expected   = StrInitFromZstr("Hello World", &alloc);
            bool test5_pass = (StrCmp(&result, &expected) == 0);
            WriteFmt("Expected: 'Hello World', Pass: {}\n\n", test5_pass ? "true" : "false");
        z          = "10110";
        StrReadFmt(z, "{}", bv1);
        Str result1 = BitVecToStr(&bv1);
        success     = success && (ZstrCompare(StrBegin(&result1), "10110") == 0);
        WriteFmt(
        z          = "   1101";
        StrReadFmt(z, "{}", bv4);
        Str result4 = BitVecToStr(&bv4);
        success     = success && (ZstrCompare(StrBegin(&result4), "1101") == 0);
        WriteFmt(
        z          = "0";
        StrReadFmt(z, "{}", bv5);
        Str result5 = BitVecToStr(&bv5);
        success     = success && (ZstrCompare(StrBegin(&result5), "0") == 0);
        WriteFmt(
        Int oct = IntInit(alloc_base);
    
        Str dec_text = StrInit(&alloc);
        Str hex_text = StrInit(&alloc);
        Str bin_text = StrInit(&alloc);
    
        Str dec_text = StrInit(&alloc);
        Str hex_text = StrInit(&alloc);
        Str bin_text = StrInit(&alloc);
        Str oct_text = StrInit(&alloc);
        Str dec_text = StrInit(&alloc);
        Str hex_text = StrInit(&alloc);
        Str bin_text = StrInit(&alloc);
        Str oct_text = StrInit(&alloc);
        Str hex_text = StrInit(&alloc);
        Str bin_text = StrInit(&alloc);
        Str oct_text = StrInit(&alloc);
    
        z = "123456789012345678901234567890";
        Float neg = FloatInit(alloc_base);
    
        Str dec_text = StrInit(&alloc);
        Str sci_text = StrInit(&alloc);
        Str neg_text = StrInit(&alloc);
    
        Str dec_text = StrInit(&alloc);
        Str sci_text = StrInit(&alloc);
        Str neg_text = StrInit(&alloc);
        Str dec_text = StrInit(&alloc);
        Str sci_text = StrInit(&alloc);
        Str neg_text = StrInit(&alloc);
    
        z = "1234567890.012345";
    #include <Misra/Std/Allocator/Heap.h>
    #include <Misra/Std/Container/Graph.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        typedef Graph(Str) StrGraph;
        StrGraph    graph = GraphInitWithDeepCopy(str_init_copy, str_deinit, &alloc);
        Str         name  = StrInitFromZstr("alpha", &alloc);
        typedef Graph(Str) StrGraph;
        StrGraph    graph = GraphInitWithDeepCopy(str_init_copy, str_deinit, &alloc);
        Str         name  = StrInitFromZstr("alpha", &alloc);
        GraphNodeId node_id;
        GraphNode   node;
        GraphNodeId node_id;
        GraphNode   node;
        Str        *stored_name;
    
        node_id     = GraphAddNodeL(&graph, name);
    
    static bool test_graph_node_owned_str_rvalue(void) {
        WriteFmt("Testing Graph node owned Str r-value insertion\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        typedef Graph(Str) StrGraph;
        StrGraph    graph = GraphInitWithDeepCopy(NULL, str_deinit, &alloc);
        GraphNodeId node_id;
        GraphNodeId node_id;
        GraphNode   node;
        Str        *stored_name;
    
        node_id     = GraphAddNodeR(&graph, StrZ("alpha", &alloc));
        WriteFmt("Testing Graph init optional allocator\n");
    
        typedef Graph(Str) StrGraph;
    
        // intentional bypass: no public setter on `Allocator` for effort /
        Float clone    = FloatClone(&original);
        Float expected = FloatFromStr("-12.5", &alloc.base);
        Str   text     = FloatToStr(&clone);
    
        FloatAbs(&original);
    
        Float value = float_from_u64(42, ALLOCATOR_OF(&alloc));
        Str   text  = FloatToStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), "42") == 0;
    
        Float value = float_from_i64(-42, ALLOCATOR_OF(&alloc));
        Str   text  = FloatToStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), "-42") == 0;
        Int   integer = IntFromStr("12345678901234567890", ALLOCATOR_OF(&alloc));
        Float value   = float_from_int(&integer, ALLOCATOR_OF(&alloc));
        Str   text    = FloatToStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), "12345678901234567890") == 0;
        Float value        = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
        Int   result_value = IntInit(ALLOCATOR_OF(&alloc));
        Str   text         = StrInit(ALLOCATOR_OF(&alloc));
    
        bool result = FloatToInt(&result_value, &value);
    
        Float value = FloatFromStr("-123.45", ALLOCATOR_OF(&alloc));
        Str   text  = FloatToStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), "-123.45") == 0;
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              text;
        bool             ok;
    
        Float value = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, ALLOCATOR_OF(&alloc));
        Str   text  = FloatToStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_ONES) == 0;
    
        Float value = FloatFromStr("1.2300e3", ALLOCATOR_OF(&alloc));
        Str   text  = FloatToStr(&value);
    
        bool result = ZstrCompare(StrBegin(&text), "1230") == 0;
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Container/Int.h>
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        StrClear(&output);
    
        Str s = StrInitFromZstr("World", &alloc);
        StrAppendFmt(&output, "{}", s);
        success = success && (ZstrCompare(StrBegin(&output), "World") == 0);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        StrClear(&output);
    
        Str s = StrInitFromZstr("MiXeD CaSe", &alloc);
    
        StrAppendFmt(&output, "{c}", s);
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str  output  = StrInit(&alloc);
        bool success = true;
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str   output  = StrInit(&alloc);
        bool  success = true;
        Float exact   = FloatFromStr("1234567890.012345", alloc_base);
    bool test_str_write_fmt_clears(void) {
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              s     = StrInit(&alloc);
        StrAppendFmt(&s, "old prefix ");
        StrWriteFmt(&s, "fresh {}", LVAL(42));
    bool test_str_patch_fmt(void) {
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str              s     = StrInit(&alloc);
        StrAppendFmt(&s, "AAAAAAAA");
        size before_length = StrLen(&s);
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Insert a character in the middle
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Insert a string in the middle: (cstr, cstr_len) adjacent, then idx
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Insert a string in the middle
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Push a string at position 2
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Push a string at position 2
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Push a string at the back
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Push a string at the back
    
    
        Str s = StrInitFromZstr("World", &alloc);
    
        // Push a string at the front
    
    
        Str s = StrInitFromZstr("World", &alloc);
    
        // Push a string at the front
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Push characters at the back
    
    
        Str s = StrInitFromZstr("World", &alloc);
    
        // Push characters at the front
    
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr(" World", &alloc);
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr(" World", &alloc);
    
        // Merge s2 into s1 (L-value semantics)
    
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr(" World", &alloc);
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr(" World", &alloc);
    
        // Merge s2 into s1 (R-value semantics)
    
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr(" World", &alloc);
    
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr(" World", &alloc);
    
        // Merge s2 into s1 (L-form; ownership of s2's storage transfers to s1)
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Append formatted suffix.
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Insert tests\n\n");
    
        // Array of test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, NULL, 0, "Str.Insert");
    }
    
        Float value = FloatFromStr("12.5", &alloc.base);
        Str   text  = StrInit(&alloc.base);
    
        FloatNegate(&value);
        Float b            = FloatFromStr("0.03", &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatAdd(&result_value, &a, &b);
        Float b            = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatAdd(&result_value, &a, &b);
        Int   whole        = IntFrom(2, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatAdd(&result_value, &a, &b);
        Float b            = FloatFromStr("2", &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatSub(&result_value, &a, &b);
        Float b            = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatSub(&result_value, &a, &b);
        Int   whole        = IntFrom(2, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatSub(&result_value, &a, &b);
        Float b            = FloatFromStr("-0.2", &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatMul(&result_value, &a, &b);
        Float b            = FloatFromStr("2", &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatMul(&result_value, &a, &b);
        Int   whole        = IntFrom(2, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatMul(&result_value, &a, &b);
        Float b            = FloatFromStr("8", &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatDiv(&result_value, &a, &b, 3);
        Float b            = FloatFromStr("2", &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatDiv(&result_value, &a, &b, 0);
        Int   whole        = IntFrom(3, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
    
        FloatDiv(&result_value, &a, &b, 1);
        Int b            = IntFrom(1, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Str text         = StrInit(&alloc.base);
    
        IntAdd(&result_value, &a, &b);
        Int result_value = IntInit(&alloc.base);
        Int huge         = IntFromStr("123456789012345678901234567890", &alloc.base);
        Str text         = StrInit(&alloc.base);
    
        IntAdd(&result_value, &base, &rhs);
        Int preserved    = IntFrom(99, &alloc.base);
        Int huge         = IntFromStr("12345678901234567890", &alloc.base);
        Str text         = StrInit(&alloc.base);
    
        bool result = IntSub(&result_value, &base, &rhs);
        Int value        = IntFromStr("12345678901234567890", &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Str text         = StrInit(&alloc.base);
    
        IntMul(&result_value, &value, 25u);
        Int exponent     = IntFrom(20, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Str text         = StrInit(&alloc.base);
    
        IntPow(&result_value, &base, 20u);
        Int quotient  = IntInit(&alloc.base);
        Int remainder = IntInit(&alloc.base);
        Str qtext     = StrInit(&alloc.base);
    
        IntDivMod(&quotient, &remainder, &dividend, 97u);
        Int dividend     = IntFromStr("12345678901234567890", &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Str text         = StrInit(&alloc.base);
    
        bool result = IntDivExact(&result_value, &dividend, 90u);
        Int quotient  = IntInit(&alloc.base);
        Int remainder = IntInit(&alloc.base);
        Str text      = StrInit(&alloc.base);
    
        IntDivMod(&quotient, &remainder, &dividend, 97);
        Int value = IntFromStr("1000000000", &alloc.base);
        Int next  = IntInit(&alloc.base);
        Str text  = StrInit(&alloc.base);
    
        bool ok = IntNextPrime(&next, &value);
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/File.h>
    #include <Misra/Std/Log.h>
    // is the caller's Str; on success it holds the resolved name so the
    // caller can read it back and remove it.
    static bool write_test_file(Zstr text, Str *out_path, Allocator *alloc) {
        File f = FileOpenTemp(out_path, alloc);
        if (!FileIsOpen(&f)) {
    
    bool test_file_read_into_str(void) {
        WriteFmt("Testing FileRead into Str (whole-file load)\n");
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str path;
        if (!write_test_file("hello from file", &path, alloc_base)) {
            DefaultAllocatorDeinit(&alloc);
        }
    
        Str body = StrInit(alloc_base);
        i64 got  = FileRead(&f, &body);
        FileClose(&f);
    
    bool test_file_read_grows_str(void) {
        WriteFmt("Testing FileRead grows the Str backing buffer\n");
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str path;
        if (!write_test_file("this is longer than the initial buffer", &path, alloc_base)) {
            DefaultAllocatorDeinit(&alloc);
        }
    
        Str body = StrInit(alloc_base);
        i64 got  = FileRead(&f, &body);
        FileClose(&f);
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    // Test Str type definition
    bool test_str_type(void) {
        WriteFmt("Testing Str type definition\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        // Create a Str object
        Str s = StrInit(&alloc);
    
        // Check that it behaves like a Vec of chars
    
        // Add some strings
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr("World", &alloc);
        // Add some strings
        Str s1 = StrInitFromZstr("Hello", &alloc);
        Str s2 = StrInitFromZstr("World", &alloc);
    
        VecPushBack(&sv, s1);
        // Check the content of the strings
        if (result) {
            Str *str1 = &VecAt(&sv, 0);
            Str *str2 = &VecAt(&sv, 1);
        if (result) {
            Str *str1 = &VecAt(&sv, 0);
            Str *str2 = &VecAt(&sv, 1);
    
            result = result && (ZstrCompare(StrBegin(str1), "Hello") == 0);
    
        // Create a valid Str
        Str s = StrInit(&alloc);
    
        // This should not crash
    
        // Create an invalid Str by corrupting its fields
        Str s = StrInit(&alloc);
    
        // Corrupt the string to make it invalid
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Type tests\n\n");
    
        // Array of normal test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, deadend_tests, deadend_count, "Str.Type");
    }
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Types.h>
    
        // Convert to string
        Str  str;
        bool ok = BitVecTryToStr(&str, &bv);
    
        BitVec bv;
        Str    str;
        bool   ok = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc));
        bool   result = ok && (BitVecAllocator(&bv)->effort == alloc.base.effort) &&
    
        // Test converting empty bitvec
        Str str_obj = BitVecToStr(&bv);
        result      = result && (StrLen(&str_obj) == 0);
        StrDeinit(&str_obj);
        for (size i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
            BitVec bv  = BitVecFromStr(patterns[i], ALLOCATOR_OF(&alloc));
            Str    str = BitVecToStr(&bv);
    
            // Should get exact same string back
        BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
    
        Str empty_str = BitVecToStr(&empty);
        result        = result && (StrLen(&empty_str) == 0);
        StrDeinit(&empty_str);
    
            // Test string conversion consistency
            Str str = BitVecToStr(&bv);
            result  = result && (ZstrCompare(StrBegin(&str), test_cases[i].pattern) == 0);
            StrDeinit(&str);
    
        // All three should produce the same result when converted back
        Str str1 = BitVecToStr(&bv1);
        Str str2 = BitVecToStr(&bv2);
        Str str3 = BitVecToStr(&bv3);
        // All three should produce the same result when converted back
        Str str1 = BitVecToStr(&bv1);
        Str str2 = BitVecToStr(&bv2);
        Str str3 = BitVecToStr(&bv3);
        Str str1 = BitVecToStr(&bv1);
        Str str2 = BitVecToStr(&bv2);
        Str str3 = BitVecToStr(&bv3);
    
        // At least two of them should match (bit order might affect one)
    
        // Test string conversion
        Str large_str = BitVecToStr(&large_bv);
        result        = result && (StrLen(&large_str) == 1000);
    #include <Misra/Std/Container/Graph.h>
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Memory.h>
    }
    
    typedef Graph(Str) CityGraph;
    typedef Map(Str, GraphNodeId) CityIndex;
    
    typedef Graph(Str) CityGraph;
    typedef Map(Str, GraphNodeId) CityIndex;
    
    static GraphNodeId city_add_intersection(CityGraph *graph, CityIndex *index, const Str *name, DefaultAllocator *alloc) {
    typedef Map(Str, GraphNodeId) CityIndex;
    
    static GraphNodeId city_add_intersection(CityGraph *graph, CityIndex *index, const Str *name, DefaultAllocator *alloc) {
        GraphNodeId id = GraphAddNodeR(graph, StrInitFromCstr(StrBegin(name), StrLen(name), alloc));
        GraphNodeId id = GraphAddNodeR(graph, StrInitFromCstr(StrBegin(name), StrLen(name), alloc));
    
        Str key_copy = StrInitFromCstr(StrBegin(name), StrLen(name), alloc);
        MapInsertR(index, key_copy, id);
        return id;
    }
    
    static bool city_reachable(CityGraph *graph, CityIndex *index, const Str *from, const Str *to) {
        GraphNodeId *from_id = MapGetFirstPtr(index, *from);
        GraphNodeId *to_id   = MapGetFirstPtr(index, *to);
        // hand its address through; the helpers + Map / Graph deep-copy
        // callbacks own the resulting clones.
        Str s_alpha   = StrInitFromZstr("Alpha", &alloc);
        Str s_beta    = StrInitFromZstr("Beta", &alloc);
        Str s_gamma   = StrInitFromZstr("Gamma", &alloc);
        // callbacks own the resulting clones.
        Str s_alpha   = StrInitFromZstr("Alpha", &alloc);
        Str s_beta    = StrInitFromZstr("Beta", &alloc);
        Str s_gamma   = StrInitFromZstr("Gamma", &alloc);
        Str s_delta   = StrInitFromZstr("Delta", &alloc);
        Str s_alpha   = StrInitFromZstr("Alpha", &alloc);
        Str s_beta    = StrInitFromZstr("Beta", &alloc);
        Str s_gamma   = StrInitFromZstr("Gamma", &alloc);
        Str s_delta   = StrInitFromZstr("Delta", &alloc);
        Str s_echo    = StrInitFromZstr("Echo", &alloc);
        Str s_beta    = StrInitFromZstr("Beta", &alloc);
        Str s_gamma   = StrInitFromZstr("Gamma", &alloc);
        Str s_delta   = StrInitFromZstr("Delta", &alloc);
        Str s_echo    = StrInitFromZstr("Echo", &alloc);
        Str s_unknown = StrInitFromZstr("Unknown", &alloc);
        Str s_gamma   = StrInitFromZstr("Gamma", &alloc);
        Str s_delta   = StrInitFromZstr("Delta", &alloc);
        Str s_echo    = StrInitFromZstr("Echo", &alloc);
        Str s_unknown = StrInitFromZstr("Unknown", &alloc);
        Str s_delta   = StrInitFromZstr("Delta", &alloc);
        Str s_echo    = StrInitFromZstr("Echo", &alloc);
        Str s_unknown = StrInitFromZstr("Unknown", &alloc);
    
        GraphNodeId alpha = city_add_intersection(&graph, &index, &s_alpha, &alloc);
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str s = StrInit(&alloc);
    
        // Validate the string
        Zstr test_str = "Hello, World!";
        size len      = 5; // Just "Hello"
        Str  s        = StrInitFromCstr(test_str, len, &alloc);
    
        // Validate the string
    
        Zstr test_str = "Hello, World!";
        Str  s        = StrInitFromZstr(test_str, &alloc);
    
        // Validate the string
    
        Zstr test_str = "Alias Test";
        Str  s        = StrZ(test_str, &alloc);
    
        ValidateStr(&s);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str src = StrInitFromZstr("Hello, World!", &alloc);
        Str dst = StrInitFromStr(&src, &alloc);
    
        Str src = StrInitFromZstr("Hello, World!", &alloc);
        Str dst = StrInitFromStr(&src, &alloc);
    
        // Validate both strings
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str src = StrInitFromZstr("Hello, World!", &alloc);
        Str dst = StrDup(&src, &alloc);
    
        Str src = StrInitFromZstr("Hello, World!", &alloc);
        Str dst = StrDup(&src, &alloc);
    
        // Validate both strings
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str s = StrInit(&alloc);
        StrAppendFmt(&s, "Hello, {}!", &"World"[0]);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str src = StrInitFromZstr("Hello, World!", &alloc);
        Str dst = StrInit(&alloc);
    
        Str src = StrInitFromZstr("Hello, World!", &alloc);
        Str dst = StrInit(&alloc);
    
        // Copy src to dst
    // Test that Str clones inherit the source allocator pointer
    bool test_str_clone_inherits_allocator_config(void) {
        WriteFmt("Testing Str clone allocator inheritance\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str src = StrInitFromCstr("Hello, World!", ZstrLen("Hello, World!"), &alloc);
    
        Str  dup    = StrInitFromStr(&src, &alloc);
        Str src = StrInitFromCstr("Hello, World!", ZstrLen("Hello, World!"), &alloc);
    
        Str  dup    = StrInitFromStr(&src, &alloc);
        Str  dst    = StrInit(&alloc);
        bool copied = StrInitCopy(&dst, &src);
    
        Str  dup    = StrInitFromStr(&src, &alloc);
        Str  dst    = StrInit(&alloc);
        bool copied = StrInitCopy(&dst, &src);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Str s = StrInitFromZstr("Hello, World!", &alloc);
    
        // Validate the string before deinit
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Init tests\n\n");
    
        // Array of test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, NULL, 0, "Str.Init");
    }
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character with its index
    
        // Build a new string by iterating through each character with its index
        Str result = StrInit(&alloc);
        StrForeachIdx(&s, chr, idx) {
            StrAppendFmt(&result, "{c}{}", chr, idx);
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character in reverse with its index
    
        // Build a new string by iterating through each character in reverse with its index
        Str result = StrInit(&alloc);
    
        StrForeachReverseIdx(&s, chr, idx) {
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character pointer with its index
    
        // Build a new string by iterating through each character pointer with its index
        Str result = StrInit(&alloc);
        StrForeachPtrIdx(&s, chrptr, idx) {
            // Append the character (via pointer) and its index to the result string
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character pointer in reverse with its index
    
        // Build a new string by iterating through each character pointer in reverse with its index
        Str result = StrInit(&alloc);
    
        StrForeachReversePtrIdx(&s, chrptr, idx) {
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character
    
        // Build a new string by iterating through each character
        Str result = StrInit(&alloc);
        StrForeach(&s, chr) {
            // Append the character to the result string
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character in reverse
    
        // Build a new string by iterating through each character in reverse
        Str  result     = StrInit(&alloc);
        size char_count = 0;
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character pointer
    
        // Build a new string by iterating through each character pointer
        Str result = StrInit(&alloc);
        StrForeachPtr(&s, chrptr) {
            // Append the character (via pointer) to the result string
    
    
        Str s = StrInitFromZstr("Hello", &alloc);
    
        // Build a new string by iterating through each character pointer in reverse
    
        // Build a new string by iterating through each character pointer in reverse
        Str  result     = StrInit(&alloc);
        size char_count = 0;
    
    
        Str s = StrInitFromZstr("Hello World", &alloc);
    
        // Build a new string by iterating through a range of characters with indices
    
        // Build a new string by iterating through a range of characters with indices
        Str result = StrInit(&alloc);
        StrForeachInRangeIdx(&s, chr, idx, 6, 11) {
            // Append the character and its index to the result string
    
        // Test with empty range
        Str empty_result = StrInit(&alloc);
        StrForeachInRangeIdx(&s, chr, idx, 3, 3) {
            // This block should not execute
    
    
        Str s = StrInitFromZstr("Hello World", &alloc);
    
        // Build a new string by iterating through a range of characters
    
        // Build a new string by iterating through a range of characters
        Str result = StrInit(&alloc);
        StrForeachInRange(&s, chr, 0, 5) {
            // Append the character to the result string
    
        // Test with range at the end of the string
        Str end_result = StrInit(&alloc);
        StrForeachInRange(&s, chr, 6, 11) {
            // Append the character to the result string
    
    
        Str s = StrInitFromZstr("Hello World", &alloc);
    
        // Build a new string by iterating through a range of character pointers with indices
    
        // Build a new string by iterating through a range of character pointers with indices
        Str result = StrInit(&alloc);
        StrForeachPtrInRangeIdx(&s, chrptr, idx, 6, 11) {
            // Append the character and its index to the result string
    
    
        Str s = StrInitFromZstr("Hello World", &alloc);
    
        // Build a new string by iterating through a range of character pointers
    
        // Build a new string by iterating through a range of character pointers
        Str result = StrInit(&alloc);
        StrForeachPtrInRange(&s, chrptr, 0, 5) {
            // Append the character to the result string
    
    
        Str s = StrInitFromZstr("Hello World!", &alloc); // 12 characters
    
        // Use StrForeachInRangeIdx which captures the 'end' parameter at the start
    
    
        Str s = StrInitFromZstr("Programming", &alloc); // 11 characters
    
        // Use StrForeachInRangeIdx with a fixed range that will become invalid
    
    
        Str s = StrInitFromZstr("Beautiful Weather", &alloc); // 17 characters
    
        // StrForeachReverseIdx (VecForeachReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
    
    
        Str s = StrInitFromZstr("Programming Test", &alloc); // 16 characters
    
        // StrForeachPtrIdx (VecForeachPtrIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
    
    
        Str s = StrInitFromZstr("Excellent Example", &alloc); // 17 characters
    
        // StrForeachReversePtrIdx (VecForeachPtrReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
    
    
        Str s = StrInitFromZstr("Comprehensive Testing Framework", &alloc); // 31 characters
    
        // Use StrForeachPtrInRangeIdx with a fixed range that becomes invalid when we modify the string
    
    
        Str s = StrInitFromZstr("Testing Basic", &alloc); // 13 characters
    
        // Basic StrForeachIdx (VecForeachIdx) now has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
    // Main function that runs all tests
    int main(void) {
        WriteFmt("[INFO] Starting Str.Foreach.Simple tests\n\n");
    
        // Array of normal test functions
    
        // Run all tests using the centralized test driver
        return run_test_suite(tests, total_tests, NULL, 0, "Str.Foreach.Simple");
    }
        ArgParse         p = ArgParseInit("prog", NULL, &a);
    
        Str name = StrInit(&a);
        ArgOptional(&p, NULL, "--name", &name, "n");
    #define MISRA_SYS_H
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys/Errno.h>
    /// TAGS: System, Error, String
    ///
    Str *StrError(i32 eno, Str *err_str);
    
    ///
    /// TAGS: I/O, Callback, Generic
    ///
    typedef bool (*TypeSpecificWriter)(Str *o, FmtInfo *fmt_info, void *data);
    
    ///
                (x),                                                                                                       \
                TypeSpecificIO: (x),                                                                                       \
                Str: TO_TYPE_SPECIFIC_IO(Str, &(x)),                                                                       \
                IOFMT_FLOAT_CASE_(x, &(x)) IOFMT_INT_CASE_(x, &(x)) IOFMT_BITVEC_CASE_(x, &(x)) IOFMT_USER_CASE_(x, &(x))  \
                    Zstr: TO_TYPE_SPECIFIC_IO(Zstr, &(x)),                                                                 \
                (x),                                                                                                       \
                TypeSpecificIO: (x),                                                                                       \
                Str: TO_TYPE_SPECIFIC_IO(Str, (void *)&(x)),                                                               \
                IOFMT_FLOAT_CASE_(x, (void *)&(x)) IOFMT_INT_CASE_(x, (void *)&(x)) IOFMT_BITVEC_CASE_(x, (void *)&(x))    \
                    IOFMT_USER_CASE_(x, (void *)&(x)) Zstr: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)),                       \
    /// TAGS: Str, Format, Pad
    ///
    bool StrPad(Str *o, size width, Alignment align, size content_len);
    
    #if FEATURE_FLOAT
    /// TAGS: Float, Format, Decimal
    ///
    bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc);
    #    define FloatTryToDecimalStr(...) OVERLOAD(FloatTryToDecimalStr, __VA_ARGS__)
    #    define FloatTryToDecimalStr_4(out, value, precision, has_precision)                                               \
    ///
    bool float_try_to_scientific_str(
        Str       *out,
        Float     *value,
        u32        precision,
    
    // not for direct use
    bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
    bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    // not for direct use
    bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
    bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
    bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s);
    bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s);
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
    bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s);
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
    bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s);
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
    bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s);
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
    bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    #if FEATURE_FLOAT
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
    bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    #if FEATURE_FLOAT
    bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
    bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    #if FEATURE_FLOAT
    bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
    #endif
    #if FEATURE_BITVEC
    #endif
    #if FEATURE_BITVEC
    bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
    #endif
    #if FEATURE_INT
    #endif
    #if FEATURE_INT
    bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
    #endif
    #endif
    
    Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s);
    Zstr _read_u8(Zstr i, FmtInfo *fmt_info, u8 *v);
    Zstr _read_u16(Zstr i, FmtInfo *fmt_info, u16 *v);
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys.h>
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: file_open((Zstr)StrBegin((Str *)(path)), (mode)),                                                       \
            Zstr: file_open((Zstr)(path), (mode)),                                                                         \
            char *: file_open((Zstr)(path), (mode))                                                                        \
    ///
    i64 file_read(File *f, void *buf, u64 n);
    i64 file_read_to_str(File *f, Str *out);
    i64 file_read_to_buf(File *f, Buf *out);
    #define FileRead(...) OVERLOAD(FileRead, __VA_ARGS__)
    #define FileRead(...) OVERLOAD(FileRead, __VA_ARGS__)
    #define FileRead_2(f, out)                                                                                             \
        _Generic((out), Buf *: file_read_to_buf((f), (Buf *)(out)), Str *: file_read_to_str((f), (Str *)(out)))
    #define FileRead_3(f, buf, n) file_read((f), (buf), (n))
    ///
    i64 file_read_and_close_to_buf(Zstr path, Buf *out);
    i64 file_read_and_close_to_str(Zstr path, Str *out);
    #define FileReadAndClose(path, out)                                                                                    \
        _Generic(                                                                                                          \
            Buf *: _Generic(                                                                                               \
                (path),                                                                                                    \
                Str *: file_read_and_close_to_buf((Zstr)StrBegin((Str *)(path)), (Buf *)(out)),                            \
                Zstr: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)),                                              \
                char *: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out))                                             \
                char *: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out))                                             \
            ),                                                                                                             \
            Str *: _Generic(                                                                                               \
                (path),                                                                                                    \
                Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)),                            \
            Str *: _Generic(                                                                                               \
                (path),                                                                                                    \
                Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)),                            \
                Zstr: file_read_and_close_to_str((Zstr)(path), (Str *)(out)),                                              \
                char *: file_read_and_close_to_str((Zstr)(path), (Str *)(out))                                             \
                (path),                                                                                                    \
                Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)),                            \
                Zstr: file_read_and_close_to_str((Zstr)(path), (Str *)(out)),                                              \
                char *: file_read_and_close_to_str((Zstr)(path), (Str *)(out))                                             \
            )                                                                                                              \
                Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)),                            \
                Zstr: file_read_and_close_to_str((Zstr)(path), (Str *)(out)),                                              \
                char *: file_read_and_close_to_str((Zstr)(path), (Str *)(out))                                             \
            )                                                                                                              \
        )
    ///
    i64 file_write_and_close_from_buf(Zstr path, const Buf *in);
    i64 file_write_and_close_from_str(Zstr path, const Str *in);
    i64 file_write_and_close_from_bytes(Zstr path, const void *buf, u64 n);
    #define FileWriteAndClose(...) OVERLOAD(FileWriteAndClose, __VA_ARGS__)
            Buf *: _Generic(                                                                                               \
                (path),                                                                                                    \
                Str *: file_write_and_close_from_buf((Zstr)StrBegin((Str *)(path)), (const Buf *)(container)),             \
                Zstr: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)),                               \
                char *: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container))                              \
                char *: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container))                              \
            ),                                                                                                             \
            Str *: _Generic(                                                                                               \
                (path),                                                                                                    \
                Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)),             \
            Str *: _Generic(                                                                                               \
                (path),                                                                                                    \
                Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)),             \
                Zstr: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)),                               \
                char *: file_write_and_close_from_str((Zstr)(path), (const Str *)(container))                              \
                (path),                                                                                                    \
                Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)),             \
                Zstr: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)),                               \
                char *: file_write_and_close_from_str((Zstr)(path), (const Str *)(container))                              \
            )                                                                                                              \
                Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)),             \
                Zstr: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)),                               \
                char *: file_write_and_close_from_str((Zstr)(path), (const Str *)(container))                              \
            )                                                                                                              \
        )
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: file_write_and_close_from_bytes((Zstr)StrBegin((Str *)(path)), (buf), (n)),                             \
            Zstr: file_write_and_close_from_bytes((Zstr)(path), (buf), (n)),                                               \
            char *: file_write_and_close_from_bytes((Zstr)(path), (buf), (n))                                              \
    /// TAGS: File, Temp
    ///
    File file_open_temp(Str *out_path, Allocator *alloc);
    #define FileOpenTemp(...)               OVERLOAD(FileOpenTemp, __VA_ARGS__)
    #define FileOpenTemp_1(out_path)        file_open_temp((out_path), MisraScope)
    // Foundation: always available.
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
            ARG_KIND_INVALID = 0, // unknown target type -- registration fails
            ARG_KIND_ZSTR,        // `Zstr *` / `char **`
            ARG_KIND_STR,         // `Str *`
            ARG_KIND_BOOL,        // `bool *`
            ARG_KIND_U8,
            Zstr *: ((ArgTarget) {ARG_KIND_ZSTR, (void *)(t)}),                                                            \
            char **: ((ArgTarget) {ARG_KIND_ZSTR, (void *)(t)}),                                                           \
            Str *: ((ArgTarget) {ARG_KIND_STR, (void *)(t)}),                                                              \
            bool *: ((ArgTarget) {ARG_KIND_BOOL, (void *)(t)}),                                                            \
            u8 *: ((ArgTarget) {ARG_KIND_U8, (void *)(t)}),                                                                \
    #include <Misra/Std/Allocator/Page.h>
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Sys/Backtrace.h>
        /// TAGS: Allocator, Debug, Reporting
        ///
        void DebugAllocatorReportLeaks(DebugAllocator *self, Str *out);
    
    #ifdef __cplusplus
    
    // clang-format off
    #include "Str/Type.h"
    #include "Str/Init.h"
    #include "Str/Insert.h"
    // clang-format off
    #include "Str/Type.h"
    #include "Str/Init.h"
    #include "Str/Insert.h"
    #include "Str/Remove.h"
    #include "Str/Type.h"
    #include "Str/Init.h"
    #include "Str/Insert.h"
    #include "Str/Remove.h"
    #include "Str/Access.h"
    #include "Str/Init.h"
    #include "Str/Insert.h"
    #include "Str/Remove.h"
    #include "Str/Access.h"
    #include "Str/Memory.h"
    #include "Str/Insert.h"
    #include "Str/Remove.h"
    #include "Str/Access.h"
    #include "Str/Memory.h"
    #include "Str/Convert.h"
    #include "Str/Remove.h"
    #include "Str/Access.h"
    #include "Str/Memory.h"
    #include "Str/Convert.h"
    #include "Str/Foreach.h"
    #include "Str/Access.h"
    #include "Str/Memory.h"
    #include "Str/Convert.h"
    #include "Str/Foreach.h"
    #include "Str/Ops.h"
    #include "Str/Memory.h"
    #include "Str/Convert.h"
    #include "Str/Foreach.h"
    #include "Str/Ops.h"
    #include "Str/Private.h"
    #include "Str/Convert.h"
    #include "Str/Foreach.h"
    #include "Str/Ops.h"
    #include "Str/Private.h"
    // clang-format on
    #include "Str/Foreach.h"
    #include "Str/Ops.h"
    #include "Str/Private.h"
    // clang-format on
    #include "Access.h"
    #include "Private.h"
    #include <Misra/Std/Container/Str.h>
    
    #ifdef __cplusplus
        ///
        bool float_try_from_str_zstr(Float *out, Zstr text);
        bool float_try_from_str_str(Float *out, const Str *text);
    #define FloatTryFromStr(out, text)                                                                                     \
        _Generic((text), Str *: float_try_from_str_str, Zstr: float_try_from_str_zstr, char *: float_try_from_str_zstr)(   \
        bool float_try_from_str_str(Float *out, const Str *text);
    #define FloatTryFromStr(out, text)                                                                                     \
        _Generic((text), Str *: float_try_from_str_str, Zstr: float_try_from_str_zstr, char *: float_try_from_str_zstr)(   \
            (out),                                                                                                         \
            (text)                                                                                                         \
        ///
        Float float_from_str_zstr(Zstr text, Allocator *alloc);
        Float float_from_str_str(const Str *text, Allocator *alloc);
    #define FloatFromStr(...) OVERLOAD(FloatFromStr, __VA_ARGS__)
    #define FloatFromStr_1(text)                                                                                           \
    #define FloatFromStr(...) OVERLOAD(FloatFromStr, __VA_ARGS__)
    #define FloatFromStr_1(text)                                                                                           \
        _Generic((text), Str *: float_from_str_str, Zstr: float_from_str_zstr, char *: float_from_str_zstr)(               \
            (text),                                                                                                        \
            MisraScope                                                                                                     \
        )
    #define FloatFromStr_2(text, alloc)                                                                                    \
        _Generic((text), Str *: float_from_str_str, Zstr: float_from_str_zstr, char *: float_from_str_zstr)(               \
            (text),                                                                                                        \
            ALLOCATOR_OF(alloc)                                                                                            \
        )
    
        bool float_try_to_str(Str *out, const Float *value, Allocator *alloc);
        Str  float_to_str(const Float *value, Allocator *alloc);
    
        bool float_try_to_str(Str *out, const Float *value, Allocator *alloc);
        Str  float_to_str(const Float *value, Allocator *alloc);
    
    #ifdef __cplusplus
    #include "Access.h"
    #include "Private.h"
    #include <Misra/Std/Container/Str.h>
    
    #ifdef __cplusplus
        ///
        bool int_try_from_str_radix_zstr(Int *out, Zstr digits, u8 radix);
        bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix);
    #define IntTryFromStrRadix(out, digits, radix)                                                                                     \
        _Generic((digits), Str *: int_try_from_str_radix_str, Zstr: int_try_from_str_radix_zstr, char *: int_try_from_str_radix_zstr)( \
        bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix);
    #define IntTryFromStrRadix(out, digits, radix)                                                                                     \
        _Generic((digits), Str *: int_try_from_str_radix_str, Zstr: int_try_from_str_radix_zstr, char *: int_try_from_str_radix_zstr)( \
            (out),                                                                                                                     \
            (digits),                                                                                                                  \
        ///
        Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc);
        Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc);
    #define IntFromStrRadix(...) OVERLOAD(IntFromStrRadix, __VA_ARGS__)
    #define IntFromStrRadix_2(digits, radix)                                                                               \
    #define IntFromStrRadix(...) OVERLOAD(IntFromStrRadix, __VA_ARGS__)
    #define IntFromStrRadix_2(digits, radix)                                                                               \
        _Generic((digits), Str *: int_from_str_radix_str, Zstr: int_from_str_radix_zstr, char *: int_from_str_radix_zstr)( \
            (digits),                                                                                                      \
            (radix),                                                                                                       \
        )
    #define IntFromStrRadix_3(digits, radix, alloc)                                                                        \
        _Generic((digits), Str *: int_from_str_radix_str, Zstr: int_from_str_radix_zstr, char *: int_from_str_radix_zstr)( \
            (digits),                                                                                                      \
            (radix),                                                                                                       \
        /// TAGS: Int, Convert, String, Radix, Allocator
        ///
        bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc);
        Str  int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc);
        ///
        bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc);
        Str  int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc);
    
        ///
        ///
        bool int_try_from_str_zstr(Int *out, Zstr decimal);
        bool int_try_from_str_str(Int *out, const Str *decimal);
    #define IntTryFromStr(out, decimal)                                                                                    \
        _Generic((decimal), Str *: int_try_from_str_str, Zstr: int_try_from_str_zstr, char *: int_try_from_str_zstr)(      \
        bool int_try_from_str_str(Int *out, const Str *decimal);
    #define IntTryFromStr(out, decimal)                                                                                    \
        _Generic((decimal), Str *: int_try_from_str_str, Zstr: int_try_from_str_zstr, char *: int_try_from_str_zstr)(      \
            (out),                                                                                                         \
            (decimal)                                                                                                      \
        ///
        Int int_from_str_zstr(Zstr decimal, Allocator *alloc);
        Int int_from_str_str(const Str *decimal, Allocator *alloc);
    #define IntFromStr(...) OVERLOAD(IntFromStr, __VA_ARGS__)
    #define IntFromStr_1(decimal)                                                                                          \
    #define IntFromStr(...) OVERLOAD(IntFromStr, __VA_ARGS__)
    #define IntFromStr_1(decimal)                                                                                          \
        _Generic((decimal), Str *: int_from_str_str, Zstr: int_from_str_zstr, char *: int_from_str_zstr)(                  \
            (decimal),                                                                                                     \
            MisraScope                                                                                                     \
        )
    #define IntFromStr_2(decimal, alloc)                                                                                   \
        _Generic((decimal), Str *: int_from_str_str, Zstr: int_from_str_zstr, char *: int_from_str_zstr)(                  \
            (decimal),                                                                                                     \
            ALLOCATOR_OF(alloc)                                                                                            \
        /// TAGS: Int, Convert, String, Decimal, Allocator
        ///
        bool int_try_to_str(Str *out, const Int *value, Allocator *alloc);
        Str  int_to_str(const Int *value, Allocator *alloc);
        ///
        bool int_try_to_str(Str *out, const Int *value, Allocator *alloc);
        Str  int_to_str(const Int *value, Allocator *alloc);
    
        ///
        ///
        bool int_try_from_binary_zstr(Int *out, Zstr binary);
        bool int_try_from_binary_str(Int *out, const Str *binary);
    #define IntTryFromBinary(out, binary)                                                                                     \
        _Generic((binary), Str *: int_try_from_binary_str, Zstr: int_try_from_binary_zstr, char *: int_try_from_binary_zstr)( \
        bool int_try_from_binary_str(Int *out, const Str *binary);
    #define IntTryFromBinary(out, binary)                                                                                     \
        _Generic((binary), Str *: int_try_from_binary_str, Zstr: int_try_from_binary_zstr, char *: int_try_from_binary_zstr)( \
            (out),                                                                                                            \
            (binary)                                                                                                          \
        ///
        Int int_from_binary_zstr(Zstr binary, Allocator *alloc);
        Int int_from_binary_str(const Str *binary, Allocator *alloc);
    #define IntFromBinary(...) OVERLOAD(IntFromBinary, __VA_ARGS__)
    #define IntFromBinary_1(binary)                                                                                        \
    #define IntFromBinary(...) OVERLOAD(IntFromBinary, __VA_ARGS__)
    #define IntFromBinary_1(binary)                                                                                        \
        _Generic((binary), Str *: int_from_binary_str, Zstr: int_from_binary_zstr, char *: int_from_binary_zstr)(          \
            (binary),                                                                                                      \
            MisraScope                                                                                                     \
        )
    #define IntFromBinary_2(binary, alloc)                                                                                 \
        _Generic((binary), Str *: int_from_binary_str, Zstr: int_from_binary_zstr, char *: int_from_binary_zstr)(          \
            (binary),                                                                                                      \
            ALLOCATOR_OF(alloc)                                                                                            \
        /// TAGS: Int, Convert, Binary
        ///
        Str IntToBinary(const Int *value);
    
        ///
        ///
        bool int_try_from_oct_str_zstr(Int *out, Zstr octal);
        bool int_try_from_oct_str_str(Int *out, const Str *octal);
    #define IntTryFromOctStr(out, octal)                                                                                        \
        _Generic((octal), Str *: int_try_from_oct_str_str, Zstr: int_try_from_oct_str_zstr, char *: int_try_from_oct_str_zstr)( \
        bool int_try_from_oct_str_str(Int *out, const Str *octal);
    #define IntTryFromOctStr(out, octal)                                                                                        \
        _Generic((octal), Str *: int_try_from_oct_str_str, Zstr: int_try_from_oct_str_zstr, char *: int_try_from_oct_str_zstr)( \
            (out),                                                                                                              \
            (octal)                                                                                                             \
        ///
        Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc);
        Int int_from_oct_str_str(const Str *octal, Allocator *alloc);
    #define IntFromOctStr(...) OVERLOAD(IntFromOctStr, __VA_ARGS__)
    #define IntFromOctStr_1(octal)                                                                                         \
    #define IntFromOctStr(...) OVERLOAD(IntFromOctStr, __VA_ARGS__)
    #define IntFromOctStr_1(octal)                                                                                         \
        _Generic((octal), Str *: int_from_oct_str_str, Zstr: int_from_oct_str_zstr, char *: int_from_oct_str_zstr)(        \
            (octal),                                                                                                       \
            MisraScope                                                                                                     \
        )
    #define IntFromOctStr_2(octal, alloc)                                                                                  \
        _Generic((octal), Str *: int_from_oct_str_str, Zstr: int_from_oct_str_zstr, char *: int_from_oct_str_zstr)(        \
            (octal),                                                                                                       \
            ALLOCATOR_OF(alloc)                                                                                            \
        /// TAGS: Int, Convert, Oct
        ///
        Str IntToOctStr(const Int *value);
    
        ///
        ///
        bool int_try_from_hex_str_zstr(Int *out, Zstr hex);
        bool int_try_from_hex_str_str(Int *out, const Str *hex);
    #define IntTryFromHexStr(out, hex)                                                                                        \
        _Generic((hex), Str *: int_try_from_hex_str_str, Zstr: int_try_from_hex_str_zstr, char *: int_try_from_hex_str_zstr)( \
        bool int_try_from_hex_str_str(Int *out, const Str *hex);
    #define IntTryFromHexStr(out, hex)                                                                                        \
        _Generic((hex), Str *: int_try_from_hex_str_str, Zstr: int_try_from_hex_str_zstr, char *: int_try_from_hex_str_zstr)( \
            (out),                                                                                                            \
            (hex)                                                                                                             \
        ///
        Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc);
        Int int_from_hex_str_str(const Str *hex, Allocator *alloc);
    #define IntFromHexStr(...) OVERLOAD(IntFromHexStr, __VA_ARGS__)
    #define IntFromHexStr_1(hex)                                                                                           \
    #define IntFromHexStr(...) OVERLOAD(IntFromHexStr, __VA_ARGS__)
    #define IntFromHexStr_1(hex)                                                                                           \
        _Generic((hex), Str *: int_from_hex_str_str, Zstr: int_from_hex_str_zstr, char *: int_from_hex_str_zstr)(          \
            (hex),                                                                                                         \
            MisraScope                                                                                                     \
        )
    #define IntFromHexStr_2(hex, alloc)                                                                                    \
        _Generic((hex), Str *: int_from_hex_str_str, Zstr: int_from_hex_str_zstr, char *: int_from_hex_str_zstr)(          \
            (hex),                                                                                                         \
            ALLOCATOR_OF(alloc)                                                                                            \
        /// TAGS: Int, Convert, Hex
        ///
        Str IntToHexStr(const Int *value);
    
    #ifdef __cplusplus
    
    #include "Type.h"
    #include <Misra/Std/Container/Str/Type.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
        ///
        bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern);
        bool bitvec_regex_match_str(BitVec *bv, const Str *pattern);
    #define BitVecRegexMatch(bv, pattern)                                                                                   \
        _Generic((pattern), Str *: bitvec_regex_match_str, Zstr: bitvec_regex_match_zstr, char *: bitvec_regex_match_zstr)( \
        bool bitvec_regex_match_str(BitVec *bv, const Str *pattern);
    #define BitVecRegexMatch(bv, pattern)                                                                                   \
        _Generic((pattern), Str *: bitvec_regex_match_str, Zstr: bitvec_regex_match_zstr, char *: bitvec_regex_match_zstr)( \
            (bv),                                                                                                           \
            (pattern)                                                                                                       \
    #include "Type.h"
    #include <Misra/Types.h>
    #include <Misra/Std/Container/Str.h>
    
    #ifdef __cplusplus
        /// TAGS: BitVec, Convert, String, Allocator
        ///
        bool bitvec_try_to_str(Str *out, BitVec *bv, Allocator *alloc);
    
        ///
        /// TAGS: BitVec, Convert, String, Allocator
        ///
        Str bitvec_to_str(BitVec *bv, Allocator *alloc);
    
        ///
        ///
        bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc);
        bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc);
    #define BitVecTryFromStr(...) OVERLOAD(BitVecTryFromStr, __VA_ARGS__)
    #define BitVecTryFromStr_2(out, str)                                                                                   \
    #define BitVecTryFromStr(...) OVERLOAD(BitVecTryFromStr, __VA_ARGS__)
    #define BitVecTryFromStr_2(out, str)                                                                                   \
        _Generic((str), Str *: bitvec_try_from_str_str, Zstr: bitvec_try_from_str_zstr, char *: bitvec_try_from_str_zstr)( \
            (out),                                                                                                         \
            (str),                                                                                                         \
        )
    #define BitVecTryFromStr_3(out, str, alloc)                                                                            \
        _Generic((str), Str *: bitvec_try_from_str_str, Zstr: bitvec_try_from_str_zstr, char *: bitvec_try_from_str_zstr)( \
            (out),                                                                                                         \
            (str),                                                                                                         \
        ///
        BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc);
        BitVec bitvec_from_str_str(const Str *str, Allocator *alloc);
    #define BitVecFromStr(...) OVERLOAD(BitVecFromStr, __VA_ARGS__)
    #define BitVecFromStr_1(str)                                                                                           \
    #define BitVecFromStr(...) OVERLOAD(BitVecFromStr, __VA_ARGS__)
    #define BitVecFromStr_1(str)                                                                                           \
        _Generic((str), Str *: bitvec_from_str_str, Zstr: bitvec_from_str_zstr, char *: bitvec_from_str_zstr)(             \
            (str),                                                                                                         \
            MisraScope                                                                                                     \
        )
    #define BitVecFromStr_2(str, alloc)                                                                                    \
        _Generic((str), Str *: bitvec_from_str_str, Zstr: bitvec_from_str_zstr, char *: bitvec_from_str_zstr)(             \
            (str),                                                                                                         \
            ALLOCATOR_OF(alloc)                                                                                            \
        /// TAGS: Str, Init, Cstr
        ///
        bool str_try_init_from_cstr(Str *out, Zstr cstr, size len, Allocator *alloc);
    
        ///
        /// TAGS: Str, Init, Cstr
        ///
        Str  str_init_from_cstr(Zstr cstr, size len, Allocator *alloc);
    
    ///
    #define StrInit(...) OVERLOAD(StrInit, __VA_ARGS__)
    #ifdef __cplusplus
    #    define StrInit_0()          (Str VecInit_1(MisraScope))
    #    define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
    #else
    #ifdef __cplusplus
    #    define StrInit_0()          (Str VecInit_1(MisraScope))
    #    define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
    #else
    #    define StrInit_0()          ((Str)VecInit_1(MisraScope))
    #    define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
    #else
    #    define StrInit_0()          ((Str)VecInit_1(MisraScope))
    #    define StrInit_1(alloc_ptr) ((Str)VecInit_1(alloc_ptr))
    #endif
    #else
    #    define StrInit_0()          ((Str)VecInit_1(MisraScope))
    #    define StrInit_1(alloc_ptr) ((Str)VecInit_1(alloc_ptr))
    #endif
        for (char UNPL(_d)[(ne) + 1] = {0}, *UNPL(_loop) = UNPL(_d); UNPL(_loop);                                          \
             MemSet(UNPL(_d), 0, sizeof(UNPL(_d))), UNPL(_loop) = NULL)                                                    \
            for (Str name = {.length      = 0,                                                                             \
                             .capacity    = (ne),                                                                          \
                             .data        = UNPL(_d),                                                                      \
        /// TAGS: Str, Deinit, Init
        ///
        void StrDeinit(Str *str);
    
        ///
        /// TAGS: Str, Init, Copy
        ///
        bool StrInitCopy(Str *dst, const Str *src);
    
        ///
        _Generic(                                                                                                          \
            (other),                                                                                                       \
            Str *: str_cmp_str ((s), (const Str *)(other)),                                                                \
            Zstr:  str_cmp_zstr((s), (Zstr)(other)),                                                                        \
            char *: str_cmp_zstr((s), (Zstr)(other))                                                                        \
        _Generic(                                                                                                          \
            (other),                                                                                                       \
            Str *: str_cmp_str_ignore_case ((s), (const Str *)(other)),                                                    \
            Zstr:  str_cmp_zstr_ignore_case((s), (Zstr)(other)),                                                            \
            char *: str_cmp_zstr_ignore_case((s), (Zstr)(other))                                                            \
        _Generic(                                                                                                          \
            (key),                                                                                                         \
            Str *: str_find_str ((s), (const Str *)(key)),                                                                 \
            Zstr:  str_find_zstr((s), (Zstr)(key)),                                                                         \
            char *: str_find_zstr((s), (Zstr)(key))                                                                         \
        _Generic(                                                                                                          \
            (key),                                                                                                         \
            Str *: str_index_of_str ((s), (const Str *)(key)),                                                             \
            Zstr:  str_index_of_zstr((s), (Zstr)(key)),                                                                     \
            char *: str_index_of_zstr((s), (Zstr)(key))                                                                     \
        _Generic(                                                                                                          \
            (key),                                                                                                         \
            Str *: str_contains_str ((s), (const Str *)(key)),                                                             \
            Zstr:  str_contains_zstr((s), (Zstr)(key)),                                                                     \
            char *: str_contains_zstr((s), (Zstr)(key))                                                                     \
        _Generic(                                                                                                          \
            (prefix),                                                                                                      \
            Str *: str_starts_with_str ((s), (const Str *)(prefix)),                                                       \
            Zstr:  str_starts_with_zstr((s), (Zstr)(prefix)),                                                               \
            char *: str_starts_with_zstr((s), (Zstr)(prefix))                                                               \
        _Generic(                                                                                                          \
            (suffix),                                                                                                      \
            Str *: str_ends_with_str ((s), (const Str *)(suffix)),                                                         \
            Zstr:  str_ends_with_zstr((s), (Zstr)(suffix)),                                                                 \
            char *: str_ends_with_zstr((s), (Zstr)(suffix))                                                                 \
        _Generic(                                                                                                          \
            (match),                                                                                                       \
            Str *: str_replace_str ((s), (const Str *)(match), (const Str *)(replacement), (count)),                       \
            Zstr:  str_replace_zstr((s), (Zstr)(match), (Zstr)(replacement), (count)),                                      \
            char *: str_replace_zstr((s), (Zstr)(match), (Zstr)(replacement), (count))                                      \
        _Generic(                                                                                                          \
            (key),                                                                                                         \
            Str *: str_split_to_iters_str ((s), (const Str *)(key)),                                                       \
            Zstr:  str_split_to_iters_zstr((s), (Zstr)(key)),                                                               \
            char *: str_split_to_iters_zstr((s), (Zstr)(key))                                                               \
        _Generic(                                                                                                          \
            (key),                                                                                                         \
            Str *: str_split_str ((s), (const Str *)(key)),                                                                \
            Zstr:  str_split_zstr((s), (Zstr)(key)),                                                                        \
            char *: str_split_zstr((s), (Zstr)(key))                                                                        \
        /// TAGS: Str, Convert, U64
        ///
        Str *StrFromU64(Str *str, u64 value, const StrIntFormat *config);
    
        ///
        /// TAGS: Str, Convert, I64
        ///
        Str *StrFromI64(Str *str, i64 value, const StrIntFormat *config);
    
        ///
        /// TAGS: Str, Convert, F64
        ///
        Str *StrFromF64(Str *str, f64 value, const StrFloatFormat *config);
    
        ///
        /// TAGS: Str, Convert, U64
        ///
        bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config);
    
        ///
        /// TAGS: Str, Convert, I64
        ///
        bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config);
    
        ///
        /// TAGS: Str, Convert, F64
        ///
        bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config);
    
    /// TAGS: Str, Type, Vector
    ///
    typedef Vec(Str) Strs;
    
    ///
    /// TAGS: Str, Validate, API
    ///
    void ValidateStr(const Str *s);
    
    ///
    
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Types.h>
    
    typedef struct ProcMaps {
        Str            raw;     // owns the raw /proc/self/maps bytes
        ProcMapEntries entries; // pointers into `raw`
    } ProcMaps;
    
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Types.h>
    /// TAGS: Backtrace, Format, Trace, Stack
    ///
    void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc);
    
    ///
    /// TAGS: Backtrace, Format, Trace, Stack
    ///
    void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc);
    
    #if FEATURE_SYS_SYMRESOLVE
    /// TAGS: Backtrace, Format, Trace, Symbol, Stack
    ///
    void format_stack_trace_with_raw(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver);
    void format_stack_trace_with_vec(Str *out, const StackFrames *frames, SymbolResolver *resolver);
    #endif
    ///
    void format_stack_trace_with_raw(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver);
    void format_stack_trace_with_vec(Str *out, const StackFrames *frames, SymbolResolver *resolver);
    #endif
    
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Types.h>
        /// TAGS: Proc, Write, Stdio
        ///
        i32 ProcWriteToStdin(Proc *proc, const Str *buf);
    
        ///
        /// TAGS: Proc, Read, Stdio
        ///
        i32 ProcReadFromStdout(Proc *proc, Str *buf);
    
        ///
        /// TAGS: Proc, Read, Stdio
        ///
        i32 ProcReadFromStderr(Proc *proc, Str *buf);
    
        ///
        /// TAGS: Proc, Get, Executable, Path
        ///
        Str *GetCurrentExecutablePath(Str *exe_path);
    
    ///
    #define ProcReadFromStdoutFmt(p, ...)                                                                                  \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStdout((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
    #define ProcReadFromStderrFmt(p, ...)                                                                                  \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStderr((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
    #define ProcWriteToStdinFmt(p, ...)                                                                                    \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
    #define ProcWriteToStdinFmtLn(p, ...)                                                                                  \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            StrPushBackR(&UNPL(buf), '\n');                                                                                 \
    #include <Misra/Parsers/MachO.h>
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str/Type.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Types.h>
    
    typedef struct MachoCacheEntry {
        Str            module_path;
        u64            slide;
        Macho          main;
    bool macho_cache_resolve_str(
        MachoCache *self,
        const Str  *module_path,
        u64         slide,
        u64         runtime_ip,
        _Generic(                                                                                                          \
            (module_path),                                                                                                 \
            Str *: macho_cache_resolve_str((self), (const Str *)(module_path), (slide), (runtime_ip), (out_name), (out_offset)),  \
            Zstr: macho_cache_resolve_zstr((self), (Zstr)(module_path), (slide), (runtime_ip), (out_name), (out_offset)),  \
            char *: macho_cache_resolve_zstr((self), (Zstr)(module_path), (slide), (runtime_ip), (out_name), (out_offset)) \
    #define MISRA_SYS_DIR_H
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
    typedef struct DirEntry {
        DirEntryType type;
        Str          name;
    } DirEntry;
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), MisraScope),                                            \
            Zstr: dir_get_contents((Zstr)(path), MisraScope),                                                              \
            char *: dir_get_contents((Zstr)(path), MisraScope)                                                             \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)),                                   \
            Zstr: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)),                                                     \
            char *: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc))                                                    \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: file_get_size((Zstr)StrBegin((Str *)(path))),                                                           \
            Zstr: file_get_size((Zstr)(path)),                                                                             \
            char *: file_get_size((Zstr)(path))                                                                            \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: file_remove((Zstr)StrBegin((Str *)(path))),                                                             \
            Zstr: file_remove((Zstr)(path)),                                                                               \
            char *: file_remove((Zstr)(path))                                                                              \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: dir_remove((Zstr)StrBegin((Str *)(path))),                                                              \
            Zstr: dir_remove((Zstr)(path)),                                                                                \
            char *: dir_remove((Zstr)(path))                                                                               \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: dir_create((Zstr)StrBegin((Str *)(path))),                                                              \
            Zstr: dir_create((Zstr)(path)),                                                                                \
            char *: dir_create((Zstr)(path))                                                                               \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: dir_create_all((Zstr)StrBegin((Str *)(path))),                                                          \
            Zstr: dir_create_all((Zstr)(path)),                                                                            \
            char *: dir_create_all((Zstr)(path))                                                                           \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: dir_remove_all((Zstr)StrBegin((Str *)(path))),                                                          \
            Zstr: dir_remove_all((Zstr)(path)),                                                                            \
            char *: dir_remove_all((Zstr)(path))                                                                           \
    
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Types.h>
    /// TAGS: Socket, Parse, Address
    ///
    bool socket_addr_parse_str(SocketAddr *out, const Str *spec, SocketKind kind);
    #define SocketAddrParse(out, spec, kind)                                                                                                                      \
        _Generic(                                                                                                                                                 \
        _Generic(                                                                                                                                                 \
            (spec),                                                                                                                                               \
            Str *: socket_addr_parse_str((out), (const Str *)(spec), (kind)),                                                                                     \
            Zstr: socket_addr_parse_zstr((out), (Zstr)(spec), (kind)),                                                                                            \
            char *: socket_addr_parse_zstr((out), (Zstr)(spec), (kind))                                                                                           \
    /// TAGS: Socket, Address, Format
    ///
    Str socket_addr_format(const SocketAddr *addr, Allocator *alloc);
    #define SocketAddrFormat(...)           OVERLOAD(SocketAddrFormat, __VA_ARGS__)
    #define SocketAddrFormat_1(addr)        socket_addr_format((addr), MisraScope)
    
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Sys/Socket.h>
        ///
        typedef struct HostsEntry {
            Str  name;
            u8   ip[16];
            bool is_ipv6;
        ///
        bool dns_resolve_5_zstr(DnsResolver *self, Zstr hostname, u16 port, SocketKind kind, DnsAddrs *out);
        bool dns_resolve_5_str(DnsResolver *self, const Str *hostname, u16 port, SocketKind kind, DnsAddrs *out);
    #define DnsResolve_5(self, hostname, port, kind, out)                                                                  \
        _Generic(                                                                                                          \
        _Generic(                                                                                                          \
            (hostname),                                                                                                    \
            Str *: dns_resolve_5_str((self), (const Str *)(hostname), (port), (kind), (out)),                              \
            Zstr: dns_resolve_5_zstr((self), (Zstr)(hostname), (port), (kind), (out)),                                     \
            char *: dns_resolve_5_zstr((self), (Zstr)(hostname), (port), (kind), (out))                                    \
        ///
        bool dns_resolve_4_vec_zstr(DnsResolver *self, Zstr spec, SocketKind kind, DnsAddrs *out);
        bool dns_resolve_4_vec_str(DnsResolver *self, const Str *spec, SocketKind kind, DnsAddrs *out);
    #define DnsResolve_4_vec(self, spec, kind, out)                                                                        \
        _Generic(                                                                                                          \
        _Generic(                                                                                                          \
            (spec),                                                                                                        \
            Str *: dns_resolve_4_vec_str((self), (const Str *)(spec), (kind), (out)),                                      \
            Zstr: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (out)),                                             \
            char *: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (out))                                            \
        ///
        bool dns_resolve_4_one_zstr(DnsResolver *self, Zstr spec, SocketKind kind, SocketAddr *out);
        bool dns_resolve_4_one_str(DnsResolver *self, const Str *spec, SocketKind kind, SocketAddr *out);
    
        ///
            DnsAddrs *: _Generic(                                                                                          \
                (spec),                                                                                                    \
                Str *: dns_resolve_4_vec_str((self), (const Str *)(spec), (kind), (DnsAddrs *)(out)),                      \
                Zstr: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (DnsAddrs *)(out)),                             \
                char *: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (DnsAddrs *)(out))                            \
            SocketAddr *: _Generic(                                                                                        \
                (spec),                                                                                                    \
                Str *: dns_resolve_4_one_str((self), (const Str *)(spec), (kind), (SocketAddr *)(out)),                    \
                Zstr: dns_resolve_4_one_zstr((self), (Zstr)(spec), (kind), (SocketAddr *)(out)),                           \
                char *: dns_resolve_4_one_zstr((self), (Zstr)(spec), (kind), (SocketAddr *)(out))                          \
    #include <Misra/Parsers/Pe.h>
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str/Type.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Types.h>
    
    typedef struct PdbCacheEntry {
        Str  module_path; // owned; cleaned via StrDeinit
        u64  module_base; // last-seen runtime load base
        Pe   pe;
    bool pdb_cache_resolve_str(
        PdbCache  *self,
        const Str *module_path,
        u64        module_base,
        u64        runtime_ip,
        _Generic(                                                                                                          \
            (module_path),                                                                                                 \
            Str *: pdb_cache_resolve_str((self), (const Str *)(module_path), (module_base), (runtime_ip), (out_name), (out_offset)),  \
            Zstr: pdb_cache_resolve_zstr((self), (Zstr)(module_path), (module_base), (runtime_ip), (out_name), (out_offset)),         \
            char *: pdb_cache_resolve_zstr((self), (Zstr)(module_path), (module_base), (runtime_ip), (out_name), (out_offset))        \
    
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Utility/StrIter.h>
    #include <Misra/Std/Zstr.h>
    // translation-unit-visible spot so the public header and the
    // implementation agree on the layout.
    typedef Map(Str, Str) KvConfig;
    
    // Private backends. Included AFTER the KvConfig typedef so the
    /// TAGS: KvConfig, Parse, Key, Read
    ///
    StrIter KvConfigReadKey(StrIter si, Str *key);
    
    ///
    /// TAGS: KvConfig, Parse, Value, Read
    ///
    StrIter KvConfigReadValue(StrIter si, Str *value);
    
    ///
    /// TAGS: KvConfig, Parse, Pair, Read
    ///
    StrIter KvConfigReadPair(StrIter si, Str *key, Str *value);
    
    ///
    ///
    #define KvConfigGet(cfg, key)                                                                                          \
        _Generic((key), Str *: kvconfig_get_str, Zstr: kvconfig_get_zstr, char *: kvconfig_get_zstr)((cfg), (key))
    
    ///
    ///
    #define KvConfigGetPtr(cfg, key)                                                                                       \
        _Generic((key), Str *: kvconfig_get_ptr_str, Zstr: kvconfig_get_ptr_zstr, char *: kvconfig_get_ptr_zstr)(          \
            (cfg),                                                                                                         \
            (key)                                                                                                          \
    ///
    #define KvConfigContains(cfg, key)                                                                                     \
        _Generic((key), Str *: kvconfig_contains_str, Zstr: kvconfig_contains_zstr, char *: kvconfig_contains_zstr)(       \
            (cfg),                                                                                                         \
            (key)                                                                                                          \
    ///
    #define KvConfigGetBool(cfg, key, value)                                                                               \
        _Generic((key), Str *: kvconfig_get_bool_str, Zstr: kvconfig_get_bool_zstr, char *: kvconfig_get_bool_zstr)(       \
            (cfg),                                                                                                         \
            (key),                                                                                                         \
    ///
    #define KvConfigGetI64(cfg, key, value)                                                                                \
        _Generic((key), Str *: kvconfig_get_i64_str, Zstr: kvconfig_get_i64_zstr, char *: kvconfig_get_i64_zstr)(          \
            (cfg),                                                                                                         \
            (key),                                                                                                         \
    ///
    #define KvConfigGetF64(cfg, key, value)                                                                                \
        _Generic((key), Str *: kvconfig_get_f64_str, Zstr: kvconfig_get_f64_zstr, char *: kvconfig_get_f64_zstr)(          \
            (cfg),                                                                                                         \
            (key),                                                                                                         \
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope),                                              \
            Zstr: pe_open((out), (Zstr)(path), MisraScope),                                                                \
            char *: pe_open((out), (Zstr)(path), MisraScope)                                                               \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)),                                     \
            Zstr: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)),                                                       \
            char *: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc))                                                      \
    ///
    #define PeFindSection(self, name)                                                                                      \
        _Generic((name), Str *: pe_find_section_str, Zstr: pe_find_section_zstr, char *: pe_find_section_zstr)(            \
            (self),                                                                                                        \
            (name)                                                                                                         \
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
        // is a borrowed pointer into here; pool and entries are freed
        // together in `PdbDeinit`.
        Str name_pool;
    } Pdb;
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope),                                             \
            Zstr: pdb_open((out), (Zstr)(path), MisraScope),                                                               \
            char *: pdb_open((out), (Zstr)(path), MisraScope)                                                              \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)),                                    \
            Zstr: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)),                                                      \
            char *: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc))                                                     \
    #include <Misra/Parsers/Elf.h>
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Types.h>
        Allocator       *allocator;
        DwarfLineEntries entries;
        Str              string_pool;
    } DwarfLines;
        Allocator           *allocator;
        DwarfFunctionEntries entries;
        Str                  string_pool;
    } DwarfFunctions;
    ///
    typedef struct HttpHeader {
        Str key;
        Str value;
    } HttpHeader;
    typedef struct HttpHeader {
        Str key;
        Str value;
    } HttpHeader;
    ///
    HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key);
    HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key);
    #define HttpHeadersFind(headers, key)                                                                                  \
        _Generic((key), Str *: http_headers_find_str, Zstr: http_headers_find_zstr, char *: http_headers_find_zstr)(       \
    HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key);
    #define HttpHeadersFind(headers, key)                                                                                  \
        _Generic((key), Str *: http_headers_find_str, Zstr: http_headers_find_zstr, char *: http_headers_find_zstr)(       \
            (headers),                                                                                                     \
            (key)                                                                                                          \
        Allocator        *allocator;
        HttpRequestMethod method;
        Str               url;
        HttpHeaders       headers;
    } HttpRequest;
        _Generic(                                                                                                          \
            (in),                                                                                                          \
            Str *: http_request_parse_str((req), (const Str *)(in)),                                                       \
            Zstr: http_request_parse_zstr((req), (Zstr)(in)),                                                              \
            char *: http_request_parse_zstr((req), (Zstr)(in))                                                             \
        HttpResponseCode status_code;
        HttpHeaders      headers;
        Str              body;
    } HttpResponse;
    /// TAGS: Http, Respond, Html
    ///
    HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html);
    
    #if FEATURE_FILE
            _Generic(                                                                                                      \
                (filepath),                                                                                                \
                Str *: http_respond_with_file_str((response), (status), (content_type), (const Str *)(filepath)),          \
                Zstr: http_respond_with_file_zstr((response), (status), (content_type), (Zstr)(filepath)),                 \
                char *: http_respond_with_file_zstr((response), (status), (content_type), (Zstr)(filepath))                \
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope),                                             \
            Zstr: elf_open((out), (Zstr)(path), MisraScope),                                                               \
            char *: elf_open((out), (Zstr)(path), MisraScope)                                                              \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)),                                    \
            Zstr: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)),                                                      \
            char *: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc))                                                     \
    ///
    #define ElfFindSection(self, name)                                                                                     \
        _Generic((name), Str *: elf_find_section_str, Zstr: elf_find_section_zstr, char *: elf_find_section_zstr)(         \
            (self),                                                                                                        \
            (name)                                                                                                         \
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope),                                           \
            Zstr: macho_open((out), (Zstr)(path), MisraScope),                                                             \
            char *: macho_open((out), (Zstr)(path), MisraScope)                                                            \
        _Generic(                                                                                                          \
            (path),                                                                                                        \
            Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)),                                  \
            Zstr: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)),                                                    \
            char *: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc))                                                   \
        macho_find_section(                                                                                                \
            (self),                                                                                                        \
            _Generic((segment), Str *: (Zstr)StrBegin((Str *)(segment)), Zstr: (Zstr)(segment), char *: (Zstr)(segment)),  \
            _Generic((section), Str *: (Zstr)StrBegin((Str *)(section)), Zstr: (Zstr)(section), char *: (Zstr)(section))   \
        )
            (self),                                                                                                        \
            _Generic((segment), Str *: (Zstr)StrBegin((Str *)(segment)), Zstr: (Zstr)(segment), char *: (Zstr)(segment)),  \
            _Generic((section), Str *: (Zstr)StrBegin((Str *)(section)), Zstr: (Zstr)(section), char *: (Zstr)(section))   \
        )
    
    #include <Misra/Std/Allocator.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Vec.h>
        ///
        typedef struct DnsRecord {
            Str        name;
            DnsType    type;
            u16        rclass;
            u8         ipv4[4];
            u8         ipv6[16];
            Str        target;
            DnsWireBuf rdata;
        } DnsRecord;
        _Generic(                                                                                                          \
            (name),                                                                                                        \
            Str *: dns_build_query_str((out), (id), (const Str *)(name), (type)),                                          \
            Zstr: dns_build_query_zstr((out), (id), (Zstr)(name), (type)),                                                 \
            char *: dns_build_query_zstr((out), (id), (Zstr)(name), (type))                                                \
    #define MISRA_PARSERS_JSON_H
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Utility/StrIter.h>
    /// TAGS: JSON, String, Parsing, EscapeSequences
    ///
    StrIter JReadString(StrIter si, Str *str);
    
    ///
    #define JR_STR(si, str)                                                                                                \
        do {                                                                                                               \
            Str UNPL(my_str) = StrInit();                                                                                  \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        do {                                                                                                               \
            if (!StrCmp(&key, (k))) {                                                                                      \
                Str UNPL(my_str) = StrInit();                                                                              \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
                                                                                                                           \
                                                                                                                           \
                Str key = StrInit();                                                                                       \
                                                                                                                           \
                /* key start */                                                                                            \
    #define JW_STR(j, s)                                                                                                   \
        do {                                                                                                               \
            const Str *UNPL(jw_s)   = &(s);                                                                                \
            u64        UNPL(jw_len) = StrLen(UNPL(jw_s));                                                                  \
            StrAppendFmt(&(j), "\"{}\"", UNPL(jw_len) ? (Zstr)StrBegin(UNPL(jw_s)) : (Zstr) "");                           \
Last updated on