Skip to content

Str

Str

Description

The Str type is a specialization of Vec for characters

Usage example (Cross-references)

Usage examples (Cross-references)
    
    #include "../Harness.h"
    #include "Str.h"
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include "../Harness.h"
    #include "Str.h"
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <string.h>
    
    // Generate a Str from fuzz input data
    static Str generate_str_from_input(const uint8_t *data, size_t *offset, size_t size, size_t max_len) {
        // Extract length (limit to max_len for sanity)
        uint8_t len = extract_u8(data, offset, size);
    
        // Create Str from input data
        Str str  = StrInitFromCstr((const char *)(data + *offset), len);
        *offset += len;
    }
    
    void init_str(Str *str) {
        *str = StrInit();
    }
    }
    
    void deinit_str(Str *str) {
        StrDeinit(str);
    }
    }
    
    void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size) {
        switch (func) {
            case STR_INIT : {
            case STR_INIT_FROM_STR : {
                if (VecLen(str) > 0) {
                    Str temp = StrInitFromStr(str);
                    StrDeinit(str);
                    *str = temp;
            case STR_DUP : {
                if (VecLen(str) > 0) {
                    Str temp = StrDup(str);
                    StrDeinit(str);
                    *str = temp;
            case STR_CMP : {
                if (VecLen(str) > 0) {
                    Str temp   = generate_str_from_input(data, offset, size, 20);
                    int result = StrCmp(str, &temp);
                    (void)result; // Suppress unused variable warning
            case STR_FIND_STR : {
                if (VecLen(str) > 0) {
                    Str   temp  = generate_str_from_input(data, offset, size, 10);
                    char *found = StrFindStr(str, &temp);
                    (void)found; // Suppress unused variable warning
                if (*offset + 2 <= size) {
                    size_t idx  = extract_u16(data, offset, size) % (VecLen(str) + 1);
                    Str    temp = generate_str_from_input(data, offset, size, 20);
                    StrInsert(str, &temp, idx);
                    StrDeinit(&temp);
    
            case STR_APPEND_STR : {
                Str temp = generate_str_from_input(data, offset, size, 20);
                StrMerge(str, &temp);
                StrDeinit(&temp);
    
            case STR_MERGE : {
                Str temp = generate_str_from_input(data, offset, size, 20);
                StrMerge(str, &temp);
                StrDeinit(&temp);
    
            case STR_MERGE_STR : {
                Str temp = generate_str_from_input(data, offset, size, 20);
                StrMerge(str, &temp);
                StrDeinit(&temp);
    #define FUZZ_STR_H
    
    #include <Misra/Std/Container/Str.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    // Function prototypes
    void init_str(Str *str);
    void deinit_str(Str *str);
    void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size);
    // Function prototypes
    void init_str(Str *str);
    void deinit_str(Str *str);
    void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size);
    void init_str(Str *str);
    void deinit_str(Str *str);
    void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size);
    
    #endif // FUZZ_STR_H
    
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Container/Str.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>
    #include <string.h> // For strlen
    
    // Generate a Str from fuzz input data
    static Str generate_str_from_input(const uint8_t *data, size_t *offset, size_t size, size_t max_len) {
        // Extract length (limit to max_len for sanity)
        uint8_t len = extract_u8(data, offset, size);
    
        // Create Str with capacity
        Str str = StrInit();
    
        // 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, size, 32);
                VecPushBack(vec, str);
                break;
    
            case VEC_STR_PUSH_FRONT : {
                Str str = generate_str_from_input(data, offset, size, 32);
                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 <= size) {
                    size_t index = extract_u32(data, offset, size) % (VecLen(vec) + 1);
                    Str    str   = generate_str_from_input(data, offset, size, 32);
                    VecInsert(vec, str, index);
                }
                if (VecLen(vec) > 0 && *offset + 4 <= size) {
                    size_t index = extract_u32(data, offset, size) % VecLen(vec);
                    Str    str;
                    VecRemove(vec, &str, index);
                    // StrDeinit is called automatically by the vector
                if (VecLen(vec) > 0 && *offset + 4 <= size) {
                    size_t index = extract_u32(data, offset, 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, size, 16);
                            VecAt(vec, i) = str;
                        }
    
                    // Create temporary array of Str objects
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, size, 16);
                    size_t index = extract_u32(data, offset, size) % VecLen(vec);
                    size_t count = extract_u32(data, offset, size) % (VecLen(vec) - index + 1);
                    VecRemoveRange(vec, (Str *)NULL, index, count);
                }
                break;
                if (*offset + 4 <= size) {
                    size_t index = extract_u32(data, offset, size) % (VecLen(vec) + 1);
                    Str    str   = generate_str_from_input(data, offset, size, 32);
                    VecInsertFast(vec, str, index);
                }
                if (VecLen(vec) > 0 && *offset + 4 <= size) {
                    size_t index = extract_u32(data, offset, size) % VecLen(vec);
                    Str    str;
                    VecRemoveFast(vec, &str, index);
                    // StrDeinit is called automatically by the vector
                    size_t index = extract_u32(data, offset, size) % VecLen(vec);
                    size_t count = extract_u32(data, offset, size) % (VecLen(vec) - index + 1);
                    VecRemoveRangeFast(vec, (Str *)NULL, index, count);
                }
                break;
    
                    // Create temporary array of Str objects
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, size, 16);
    
                    // Create temporary array of Str objects
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, size, 16);
    
                    // Create temporary array of Str objects
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, size, 16);
            case VEC_STR_BEGIN : {
                if (VecLen(vec) > 0) {
                    Str *begin = VecBegin(vec);
                    (void)begin; // Use the result to avoid warnings
                }
                if (VecLen(vec) > 0 && *offset + 4 <= size) {
                    size_t index = extract_u32(data, offset, size) % VecLen(vec);
                    Str   *ptr   = VecPtrAt(vec, index);
                    (void)ptr; // Use the result to avoid warnings
                }
                    size_t count = extract_u32(data, offset, size) % 5;
                    for (size_t i = 0; i < count; i++) {
                        Str str = generate_str_from_input(data, offset, size, 16);
                        VecPushBack(&temp, str);
                    }
    
                    // Create temporary array of Str objects
                    Str temp_strings[10];
                    for (size_t i = 0; i < count; i++) {
                        temp_strings[i] = generate_str_from_input(data, offset, size, 16);
                    size_t count = extract_u32(data, offset, size) % 5;
                    for (size_t i = 0; i < count; i++) {
                        Str str = generate_str_from_input(data, offset, size, 16);
                        VecPushBack(&temp, str);
                    }
    #include <string.h>
    
    Str *SysGetEnv(const char *name, Str *value) {
    #ifdef _WIN32
        char  *env_var;
    }
    
    Str *SysStrError(i32 eno, Str *err_str) {
        char buf[1024] = {0};
    #if _WIN32
    
    
    static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
    static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    
    static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
    static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
    static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
    static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
    static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
    static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
    static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
    
    static const char *_read_r8(const char *i, FmtInfo *fmt_info, u8 *v);
    
    // Helper function to pad string with spaces
    static void PadString(Str *o, size width, Alignment align, size content_len) {
        if (content_len >= width)
            return;
    }
    
    bool StrWriteFmtInternal(Str *o, const char *fmt, TypeSpecificIO *args, u64 argc) {
        if (!o || !fmt) {
            LOG_FATAL("Invalid arguments");
        }
    
        Str buffer = StrInit();
        int fd     = FILENO(file);
    // Helper function to write integer values as character sequences in a consistent order
    // regardless of system endianness (big-endian order: most significant byte first)
    static inline void write_int_as_chars(Str *o, FormatFlags flags, u64 value, size num_bytes) {
        if (!o || !num_bytes || num_bytes > 8) {
            LOG_FATAL("Invalid arguments to write_int_as_chars");
    }
    
    static inline void write_char_internal(Str *o, FormatFlags flags, const char *vs, size len) {
        if (!o || !vs || !len) {
            LOG_FATAL("Invalid arguments");
    }
    
    static void FloatFmtAppendExponent(Str *out, i64 exponent, bool uppercase) {
        char sign         = exponent < 0 ? '-' : '+';
        u64  magnitude    = exponent < 0 ? (u64)(-(exponent + 1)) + 1 : (u64)exponent;
    }
    
    static Str FloatFmtToDecimalStr(Float *value, u32 precision, bool has_precision) {
        Str canonical = FloatToStr(value);
    
    static Str FloatFmtToDecimalStr(Float *value, u32 precision, bool has_precision) {
        Str canonical = FloatToStr(value);
    
        if (!has_precision) {
    
        {
            Str         result = StrInit();
            const char *body   = canonical.data;
            const char *dot    = NULL;
    }
    
    static Str FloatFmtToScientificStr(Float *value, u32 precision, bool has_precision, bool uppercase) {
        Str digits = IntToStr(&value->significand);
        Str result = StrInit();
    
    static Str FloatFmtToScientificStr(Float *value, u32 precision, bool has_precision, bool uppercase) {
        Str digits = IntToStr(&value->significand);
        Str result = StrInit();
        u64 frac_digits = 0;
    static Str FloatFmtToScientificStr(Float *value, u32 precision, bool has_precision, bool uppercase) {
        Str digits = IntToStr(&value->significand);
        Str result = StrInit();
        u64 frac_digits = 0;
        i64 exponent    = 0;
    }
    
    void _write_Str(Str *o, FmtInfo *fmt_info, Str *s) {
        if (!o || !s || !fmt_info) {
            LOG_FATAL("Invalid arguments");
                    }
                    // Create hex string for each character
                    Str hex = StrInit();
                    StrFromU64(&hex, c, &config);
                    // Ensure 2 digits with leading zero
    }
    
    void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s) {
        if (!o || !s || !*s || !fmt_info) {
            LOG_FATAL("Invalid arguments");
                    }
                    // Create hex string for each character
                    Str          hex    = StrInit();
                    StrIntFormat config = {.base = 16, .uppercase = (fmt_info->flags & FMT_FLAG_CAPS) != 0};
                    StrFromU64(&hex, (u8)xs[i], &config);
    }
    
    void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    
        // Create temporary buffer for number formatting
        Str temp = StrInit();
    
        // Determine base based on format flags
    }
    
    void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    
        // Create temporary buffer for number formatting
        Str temp = StrInit();
    
        // Determine base based on format flags
    }
    
    void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            // Normal case - use StrFromF64
            // Create temporary buffer for number formatting
            Str temp = StrInit();
    
            // Use StrFromF64 directly with the appropriate parameters
    }
    
    void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    void _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
        size start_len = 0;
        Str  temp      = StrInit();
    void _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
        size start_len = 0;
        Str  temp      = StrInit();
    
        if (!o || !fmt_info || !value) {
    }
    
    const char *_read_Str(const char *i, FmtInfo *fmt_info, Str *s) {
        if (!i || !s)
            LOG_FATAL("Invalid arguments");
    
    // Create a helper function to check if the parsed string contains only valid numeric characters
    static bool IsValidNumericString(const Str *str, bool allow_float) {
        if (!str || !str->data)
            return false;
    
            // Create a temporary Str for parsing
            Str temp = StrInitFromCstr(start, i - start);
    
            // Try to parse as special value
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Validate the string is a proper floating point number
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Check for special prefixes with no digits
    
        // For string types, :c has no effect - work like regular string reading
        Str         temp        = StrInit();
        FmtInfo     default_fmt = {.align = ALIGN_RIGHT, .width = 0, .precision = 6, .flags = FMT_FLAG_NONE};
        const char *next        = _read_Str(i, &default_fmt, &temp);
    }
    
    void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv) {
        if (!o || !fmt_info || !bv) {
            LOG_FATAL("Invalid arguments");
                // Empty BitVec - don't output anything
            } else {
                Str bit_str = BitVecToStr(bv);
                StrMerge(o, &bit_str);
                StrDeinit(&bit_str);
    }
    
    void _write_Int(Str *o, FmtInfo *fmt_info, Int *value) {
        if (!o || !fmt_info || !value) {
            LOG_FATAL("Invalid arguments");
    
        size start_len = o->length;
        Str  temp      = StrInit();
        u8   radix     = IntFmtRadixFromFlags(fmt_info);
    }
    
    void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s) {
        (void)o;
        (void)fmt_info;
    
            // Parse hex string
            Str            hex_str = StrInitFromCstr(hex_start, i - hex_start);
            u64            value;
            StrParseConfig config = {.base = 16};
    
            // Parse octal string
            Str            oct_str = StrInitFromCstr(oct_start, i - oct_start);
            u64            value;
            StrParseConfig config = {.base = 8};
    
        // Create string from binary digits (already null-terminated by StrInitFromCstr)
        Str bin_str = StrInitFromCstr(bin_start, i - bin_start);
    
        // Convert to BitVec using the null-terminated string
        }
    
        Str temp   = StrInitFromCstr(start, i - start);
        Int parsed = IntFromStrRadix(temp.data, radix);
        size        token_len = 0;
        const char *start     = NULL;
        Str         temp      = StrInit();
        Float       parsed    = FloatInit();
    
            // Create a temporary Str for parsing
            Str temp = StrInitFromCstr(start, i - start);
    
            // Try to parse as special value
    
        // Create a temporary Str for parsing
        Str temp = StrInitFromCstr(start, pos);
    
        // Validate the string is a proper floating point number
    }
    
    static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    }
    
    static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
    
    
    static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            if (!localtime_r(&raw_time, &time_info)) {
    #endif
                Str syserr;
                StrInitStack(syserr, SYS_ERROR_STR_MAX_LENGTH, {
                    SysStrError(errno, &syserr);
    
            // Get path to temp directory
            Str log_dir = StrInit();
            if (!SysGetEnv("TMP", &log_dir) && !SysGetEnv("TEMP", &log_dir) && !SysGetEnv("TMPDIR", &log_dir) &&
                !SysGetEnv("TEMPDIR", &log_dir) && !SysGetEnv("PWD", &log_dir)) {
    
            // generate log file name
            Str file_name = StrInit();
            StrWriteFmt(&file_name, "{}/misra-{}-{}", log_dir, SysGetCurrentProcessId(), &time_buffer[0]);
            FWriteFmtLn(stderr, "storing logs in {}", file_name.data);
    
    LOG_STREAM_FALLBACK: {
        Str syserr;
        StrInitStack(syserr, SYS_ERROR_STR_MAX_LENGTH, {
            FWriteFmtLn(stderr, "Error opening log file, will write logs to stderr");
    #include <stdio.h>
    #include <stdlib.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Types.h>
    #include "Misra/Std/Utility/StrIter.h"
    
    static Str *string_va_printf(Str *str, const char *fmt, va_list args);
    
    Str *StrPrintf(Str *str, const char *fmt, ...) {
    static Str *string_va_printf(Str *str, const char *fmt, va_list args);
    
    Str *StrPrintf(Str *str, const char *fmt, ...) {
        ValidateStr(str);
    }
    
    Str *StrAppendf(Str *str, const char *fmt, ...) {
        ValidateStr(str);
    }
    
    static Str *string_va_printf(Str *str, const char *fmt, va_list args) {
        ValidateStr(str);
    }
    
    bool StrInitCopy(Str *dst, const Str *src) {
        ValidateStr(src);
        ValidateStr(src);
    
        MemSet(dst, 0, sizeof(Str));
        *dst             = StrInit();
        dst->copy_init   = src->copy_init;
    }
    
    void StrDeinit(Str *copy) {
        ValidateStr(copy);
        if (copy->data) {
    }
    
    StrIters StrSplitToIters(Str *s, const char *key) {
        ValidateStr(s);
    }
    
    Strs StrSplit(Str *s, const char *key) {
        ValidateStr(s);
                const char *next = ZstrFindSubstring(prev, key);
                if (next) {
                    Str tmp = StrInitFromCstr(prev, next - prev);
                    VecPushBack(&sv, tmp); // exclude delimiter
                    prev = next + keylen;  // skip past delimiter
                } else {
                    if (ZstrCompareN(prev, key, end - prev)) {
                        Str tmp = StrInitFromCstr(prev, end - prev);
                        VecPushBack(&sv, tmp); // remaining part
                    }
    //                 = -1 means from left
    //                 = 1 means from right
    Str strip_str(Str *s, const char *chars_to_strip, int split_direction) {
        ValidateStr(s);
    }
    
    bool StrStartsWithZstr(const Str *s, const char *prefix) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix, ZstrLen(prefix));
    }
    
    bool StrEndsWithZstr(const Str *s, const char *suffix) {
        ValidateStr(s);
        return ends_with(s->data, s->length, suffix, ZstrLen(suffix));
    }
    
    bool StrStartsWithCstr(const Str *s, const char *prefix, size prefix_len) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix, prefix_len);
    }
    
    bool StrEndsWithCstr(const Str *s, const char *suffix, size suffix_len) {
        ValidateStr(s);
        return ends_with(s->data, s->length, suffix, suffix_len);
    }
    
    bool StrStartsWith(const Str *s, const Str *prefix) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix->data, prefix->length);
    }
    
    bool StrEndsWith(const Str *s, const Str *suffix) {
        ValidateStr(s);
        return ends_with(s->data, s->length, suffix->data, suffix->length);
    // Helper: replace in-place all `match` → `replacement` up to `count`
    static void
        str_replace(Str *s, const char *match, size match_len, const char *replacement, size replacement_len, size count) {
        ValidateStr(s);
        size i        = 0;
    }
    
    void StrReplaceZstr(Str *s, const char *match, const char *replacement, size count) {
        ValidateStr(s);
        str_replace(s, match, ZstrLen(match), replacement, ZstrLen(replacement), count);
    
    void StrReplaceCstr(
        Str        *s,
        const char *match,
        size        match_len,
    }
    
    void StrReplace(Str *s, const Str *match, const Str *replacement, size count) {
        ValidateStr(s);
        str_replace(s, match->data, match->length, replacement->data, replacement->length, count);
    
    // Helper function to skip prefixes for explicit bases
    static inline size_t skip_prefix(const Str *str, size_t 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);
    
        // Create substring without sign
        Str temp_str      = StrInit();
        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);
    }
    
    // ct
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Log.h>
    Float FloatFromStr(const char *text) {
        Float result          = FloatInit();
        Str   digits          = StrInit();
        size  pos             = 0;
        bool  negative        = false;
    }
    
    Str FloatToStr(Float *value) {
        Str digits = StrInit();
        Str result = StrInit();
    
    Str FloatToStr(Float *value) {
        Str digits = StrInit();
        Str result = StrInit();
    Str FloatToStr(Float *value) {
        Str digits = StrInit();
        Str result = StrInit();
    
        ValidateFloat(value);
    }
    
    Str IntToStr(Int *value) {
        return IntToStrRadix(value, 10, false);
    }
    }
    
    Str IntToStrRadix(Int *value, u8 radix, bool uppercase) {
        ValidateInt(value);
        int_validate_radix(radix);
    
        Int current   = IntClone(value);
        Str result    = StrInit();
    
        while (!IntIsZero(&current)) {
    }
    
    Str IntToBinary(Int *value) {
        return IntToStrRadix(value, 2, false);
    }
    }
    
    Str IntToOctStr(Int *value) {
        return IntToStrRadix(value, 8, false);
    }
    }
    
    Str IntToHexStr(Int *value) {
        return IntToStrRadix(value, 16, false);
    }
    
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Log.h>
    
    // Conversion functions
    Str BitVecToStr(BitVec *bv) {
        ValidateBitVec(bv);
        ValidateBitVec(bv);
    
        Str result = StrInit();
        if (bv->length == 0) {
            return result;
    
        // Convert bitvector to string for regex matching
        Str  bv_str = BitVecToStr(bv);
        bool result = false;
    }
    
    static bool kvconfig_equals_ignore_case(const Str *value, const char *zstr) {
        size idx = 0;
    }
    
    static bool kvconfig_parse_bool_value(const Str *value, bool *out) {
        if (!out) {
            LOG_ERROR("Expected valid bool output pointer");
    }
    
    static bool kvconfig_parse_i64_value(const Str *value, i64 *out) {
        char     *endptr = NULL;
        long long parsed;
    }
    
    static bool kvconfig_parse_f64_value(const Str *value, f64 *out) {
        char  *endptr = NULL;
        double parsed;
    
    u64 KvConfigHash(const void *data, u32 ignored_size) {
        const Str *str  = data;
        u64        hash = 1469598103934665603ULL;
        size       idx;
    
    i32 KvConfigCompare(const void *lhs, const void *rhs) {
        const Str *a   = lhs;
        const Str *b   = rhs;
        size       min = 0;
    i32 KvConfigCompare(const void *lhs, const void *rhs) {
        const Str *a   = lhs;
        const Str *b   = rhs;
        size       min = 0;
        i32        cmp = 0;
    }
    
    StrIter KvConfigReadKey(StrIter si, Str *key) {
        StrIter saved_si = si;
    }
    
    StrIter KvConfigReadValue(StrIter si, Str *value) {
        StrIter saved_si = si;
        char    quote    = '\0';
    
        if (value->length > 0) {
            Str stripped = StrStrip(value, NULL);
            StrDeinit(value);
            *value = stripped;
    }
    
    StrIter KvConfigReadPair(StrIter si, Str *key, Str *value) {
        StrIter saved_si = si;
    
        while (StrIterRemainingLength(&si)) {
            Str     key   = StrInit();
            Str     value = StrInit();
            StrIter read_si;
        while (StrIterRemainingLength(&si)) {
            Str     key   = StrInit();
            Str     value = StrInit();
            StrIter read_si;
    }
    
    Str *KvConfigGetPtr(KvConfig *cfg, const char *key) {
        Str  lookup = {0};
        Str *value  = NULL;
    
    Str *KvConfigGetPtr(KvConfig *cfg, const char *key) {
        Str  lookup = {0};
        Str *value  = NULL;
    Str *KvConfigGetPtr(KvConfig *cfg, const char *key) {
        Str  lookup = {0};
        Str *value  = NULL;
    
        if (!cfg || !key) {
    }
    
    Str KvConfigGet(KvConfig *cfg, const char *key) {
        Str *value = KvConfigGetPtr(cfg, key);
    
    Str KvConfigGet(KvConfig *cfg, const char *key) {
        Str *value = KvConfigGetPtr(cfg, key);
    
        if (!value) {
    
    bool KvConfigGetBool(KvConfig *cfg, const char *key, bool *value) {
        Str *str = KvConfigGetPtr(cfg, key);
    
        if (!str) {
    
    bool KvConfigGetI64(KvConfig *cfg, const char *key, i64 *value) {
        Str *str = KvConfigGetPtr(cfg, key);
    
        if (!str) {
    
    bool KvConfigGetF64(KvConfig *cfg, const char *key, f64 *value) {
        Str *str = KvConfigGetPtr(cfg, key);
    
        if (!str) {
            }
    
            Str key = StrInit();
    
            // key start
    }
    
    StrIter JReadString(StrIter si, Str *str) {
        if (!StrIterRemainingLength(&si)) {
            return si;
        StrIter saved_si = si;
        si               = JSkipWhitespace(si);
        Str ns           = StrInit();
    
        bool is_neg = false;
        if (StrIterPeek(&si) == '"') {
            StrIter before_si = si;
            Str     s         = StrInit();
            si                = JReadString(si, &s);
            StrDeinit(&s);
    
        // Build command line
        Str cmdline = StrInit();
        StrPushBackZstr(&cmdline, filepath);
        for (char **arg = argv + 1; *arg; ++arg) {
    }
    
    i32 SysProcWriteToStdin(SysProc *proc, Str *buf) {
        if (!proc || !buf) {
            LOG_FATAL("Invalid arguments");
    }
    
    i32 sys_proc_read_internal(SysProc *proc, Str *buf, bool is_stdout) {
        if (!proc || !buf) {
            LOG_FATAL("Invalid argument");
    }
    
    i32 SysProcReadFromStdout(SysProc *proc, Str *buf) {
        return sys_proc_read_internal(proc, buf, /* is stdout*/ true);
    }
    }
    
    i32 SysProcReadFromStderr(SysProc *proc, Str *buf) {
        return sys_proc_read_internal(proc, buf, /* is stdout*/ false);
    }
    }
    
    Str *SysGetCurrentExecutablePath(Str *exe_path) {
        if (!exe_path) {
            LOG_FATAL("Invalid arguments: exe_path is NULL");
                continue;
            } else {
                Str         entry_path = StrInit();
                const char *dir_name   = &entry->d_name[0];
                StrWriteFmt(&entry_path, "{}/{}", path, dir_name);
    
    typedef struct Project {
        Str  build_dir;
        Strs source_directories;
        Strs test_directories;
                    JR_STR_KV(json, "build_dir", p.build_dir);                                                             \
                    JR_ARR_KV(json, "test_directories", {                                                                  \
                        Str s = StrInit();                                                                                 \
                        JR_STR(json, s);                                                                                   \
                        VecPushBack(&p.test_directories, s);                                                               \
                    });                                                                                                    \
                    JR_ARR_KV(json, "source_directories", {                                                                \
                        Str s = StrInit();                                                                                 \
                        JR_STR(json, s);                                                                                   \
                        VecPushBack(&p.source_directories, s);                                                             \
        Scope(&project, ProjectDeinit, {
            // read project config
            Str config = StrInit();
            Scope(&config, StrDeinit, {
                if (!ReadCompleteFile(config_path, &config.data, &config.length, &config.capacity)) {
                    VecForeach(&dir_paths, dir_name) {
                        // keep track of current path we're exploring
                        Str current_path = StrInit();
                        StrMerge(&current_path, &dir_name);
                                if (dir_entry.type == SYS_DIR_ENTRY_TYPE_DIRECTORY) {
                                    // create new directory path relative to current directory search path
                                    Str path = StrInit();
                                    StrMerge(&path, &current_path);
                                    StrPushBack(&path, '/');
                    else if (dir_entry.type == SYS_DIR_ENTRY_TYPE_REGULAR_FILE) {
                        // create complete relative file path
                        Str path = StrInit();
                        StrMerge(&path, &current_path);
                        StrPushBack(&path, '/');
    // go over each file and generate corresponding markdown
    VecForeach(&file_paths, file_path) {
        Str file_contents = StrInit();
        Scope(&file_contents, StrDeinit, {
            if (!ReadCompleteFile(file_path.data, &file_contents.data, &file_contents.length, &file_contents.capacity)) {
            }
    
            Str output_path = StrInit();
            Scope(&output_path, StrDeinit, {
                StrMerge(&output_path, &file_path);
                LOG_INFO("{}", output_path);
    
                Str md_code = StrInit();
                Scope(&md_code, StrDeinit, {
                    // Create template strings for StrWriteFmt with escaped braces
    
    typedef struct EnumEntry {
        Str name;
        Str str;
        i64 value;
    typedef struct EnumEntry {
        Str name;
        Str str;
        i64 value;
    } EnumEntry;
        }
    
        Str code = StrInit();
        ReadCompleteFile(input_filename, &code.data, &code.length, &code.capacity);
    
        StrIter json        = StrIterFromStr(code);
        Str     enum_name   = StrInit();
        bool    to_from_str = false;
    
    int main(void) {
        Str file = StrInit();
        if (ReadCompleteFile("Bin/Demangler/CppNameManglingGrammar", &file.data, &file.length, &file.capacity)) {
            Strs lines = StrSplit(&file, "\n");
            VecForeachPtr(&lines, line) {
                if (StrStartsWithZstr(line, "[.") && StrEndsWithZstr(line, "]")) {
                    Str rule_name = StrInit();
                    StrReadFmt(line->data, "[.{}]", rule_name);
    static bool test_kvconfig_basic_parse(void) {
        KvConfig cfg = KvConfigInit();
        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;
    static bool test_kvconfig_comments_quotes_and_duplicates(void) {
        KvConfig cfg = KvConfigInit();
        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;
    static bool test_kvconfig_get_returns_copy(void) {
        KvConfig cfg         = KvConfigInit();
        Str      src         = StrInitFromZstr("host = localhost\n");
        StrIter  input       = StrIterFromStr(src);
        Str      host_copy   = StrInit();
        Str      src         = StrInitFromZstr("host = localhost\n");
        StrIter  input       = StrIterFromStr(src);
        Str      host_copy   = StrInit();
        Str     *stored_host = NULL;
        bool     result      = true;
        StrIter  input       = StrIterFromStr(src);
        Str      host_copy   = StrInit();
        Str     *stored_host = NULL;
        bool     result      = true;
    static bool test_kvconfig_numeric_and_bool_accessors(void) {
        KvConfig cfg = KvConfigInit();
        Str      src = StrInitFromZstr(
            "workers = 16\n"
                 "pi = 3.14159\n"
    static bool test_kvconfig_invalid_line_fails(void) {
        KvConfig cfg = KvConfigInit();
        Str      src = StrInitFromZstr(
            "valid = yes\n"
                 "broken line\n"
        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, const char *expected) {
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
    // Helper function to compare JSON output (removes whitespace for comparison)
    bool compare_json_output(const Str *output, const char *expected) {
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
    bool compare_json_output(const Str *output, const char *expected) {
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
    
        // Remove whitespace from both strings for comparison
    
        bool success = true;
        Str  json    = StrInit();
    
        struct {
                u64 id;
                struct {
                    Str name;
                    u64 age;
                } profile;
                } profile;
            } user;
            Str status;
        } data = {
            {123, {StrInitFromZstr("Alice"), 30}},
    
        bool success = true;
        Str  json    = StrInit();
    
        struct {
                struct {
                    struct {
                        Str head;
                        u64 count;
                        f64 budget;
                    } engineering;
                } departments;
                Str name;
            } company;
        } data = {
    
        bool success = true;
        Str  json    = StrInit();
    
        ApiResponse response = {true, StrInitFromZstr("Success"), VecInitWithDeepCopy(NULL, AnnSymbolDeinit)};
            JW_OBJ_KV(json, "data", {
                // Write dynamic key for source function ID
                Str source_key = StrInit();
                u64 source_id  = response.data.length > 0 ? VecAt(&response.data, 0).source_function_id : 0;
                StrWriteFmt(&source_key, "{}", source_id);
                    if (response.data.length > 0) {
                        AnnSymbol *s          = &VecAt(&response.data, 0);
                        Str        target_key = StrInit();
                        StrWriteFmt(&target_key, "{}", s->target_function_id);
    
        bool success = true;
        Str  json    = StrInit();
    
        Vec(FunctionInfo) functions = VecInitWithDeepCopy(NULL, FunctionInfoDeinit);
    
        bool success = true;
        Str  json    = StrInit();
    
        SearchResult result = {0};
    
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("malware");
        Str tag2 = StrInitFromZstr("x86");
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("malware");
        Str tag2 = StrInitFromZstr("x86");
    
        VecPushBack(&result.tags, tag1);
    
        bool success = true;
        Str  json    = StrInit();
    
        Vec(AnnSymbol) symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit);
            JW_OBJ_KV(json, "functions", {
                VecForeach(&symbols, symbol) {
                    Str source_key = StrInit();
                    StrWriteFmt(&source_key, "{}", symbol.source_function_id);
    
                    JW_OBJ_KV(json, source_key.data, {
                Str target_key = StrInit();
                StrWriteFmt(&target_key, "{}", symbol.target_function_id);
    
        bool success = true;
        Str  json    = StrInit();
    
        // Create strings for the nested structure
    
        // Create strings for the nested structure
        Str deep_message = StrInitFromZstr("deep");
        Str test_name    = StrInitFromZstr("test");
        // Create strings for the nested structure
        Str deep_message = StrInitFromZstr("deep");
        Str test_name    = StrInitFromZstr("test");
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit();
    
        Vec(u32) numbers = VecInit();
        VecPushBack(&numbers, num3);
    
        Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
        // Create strings and push them properly
    
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("a");
        Str str2 = StrInitFromZstr("b");
        Str str3 = StrInitFromZstr("c");
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("a");
        Str str2 = StrInitFromZstr("b");
        Str str3 = StrInitFromZstr("c");
        Str str1 = StrInitFromZstr("a");
        Str str2 = StrInitFromZstr("b");
        Str str3 = StrInitFromZstr("c");
    
        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;
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"name\": \"Alice\", \"city\": \"New York\"}");
        StrIter si      = StrIterFromStr(json);
        StrIter si      = StrIterFromStr(json);
    
        Str name = StrInit();
        Str city = StrInit();
    
        Str name = StrInit();
        Str city = StrInit();
    
        JR_OBJ(si, {
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"count\": 42, \"score\": 95.5, \"year\": 2024}");
        StrIter si      = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"enabled\": true, \"visible\": false}");
        StrIter si      = StrIterFromStr(json);
    
        bool success = true;
        Str  json =
            StrInitFromZstr("{\"id\": 1001, \"name\": \"Bob\", \"age\": 25, \"is_active\": true, \"salary\": 50000.0}");
        StrIter si = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"debug_mode\": false, \"timeout\": 30, \"log_level\": \"INFO\"}");
        StrIter si      = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"languages\": [\"C\", \"Python\", \"Rust\"]}");
        StrIter si      = StrIterFromStr(json);
        StrIter si      = StrIterFromStr(json);
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
    
        JR_OBJ(si, {
        JR_OBJ(si, {
            JR_ARR_KV(si, "languages", {
                Str lang = StrInit();
                JR_STR(si, lang);
                VecPushBack(&languages, lang);
    
        if (languages.length >= 3) {
            Str *lang1 = &VecAt(&languages, 0);
            Str *lang2 = &VecAt(&languages, 1);
            Str *lang3 = &VecAt(&languages, 2);
        if (languages.length >= 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 (StrCmpCstr(lang1, "C", 1) != 0) {
    
        bool success = true;
        Str  json =
            StrInitFromZstr("{\"user\": {\"name\": \"Charlie\", \"email\": \"charlie@example.com\"}, \"active\": true}");
        StrIter si = StrIterFromStr(json);
        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();
                JR_STR(si, tag);
                VecPushBack(&product.tags, tag);
    
        if (product.tags.length >= 3) {
            Str *tag1 = &VecAt(&product.tags, 0);
            Str *tag2 = &VecAt(&product.tags, 1);
            Str *tag3 = &VecAt(&product.tags, 2);
        if (product.tags.length >= 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 (StrCmpCstr(tag1, "electronics", 11) != 0) {
        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;
        WriteFmt("Testing basic iterator functionality\n");
    
        Str     json = StrInitFromZstr("{\"test\": \"value\"}");
        StrIter si   = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"id\": 12345, \"name\": \"test\", \"active\": true, \"score\": 98.5}");
        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\"}"
        );
                u64 id;
                struct {
                    Str name;
                    u64 age;
                } profile;
                } profile;
            } user;
            Str status;
        } data = {
            {0, {StrInit(), 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}");
        StrIter si      = StrIterFromStr(json);
    
        bool    success = true;
        Str     json    = StrInitFromZstr("{\"id\": 54321, \"name\": \"test_model\"}");
        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, "
    
    // Helper function to compare JSON output (removes spaces for comparison)
    bool compare_json_output(const Str *output, const char *expected) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected);
    bool compare_json_output(const Str *output, const char *expected) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
    
        // Remove spaces and newlines from both strings for comparison
    
        bool success = true;
        Str  json    = StrInit();
    
        // Write completely empty object
    
        bool success = true;
        Str  json    = StrInit();
    
        Vec(i32) empty_numbers = VecInit();
    
        Vec(i32) empty_numbers = VecInit();
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit();
    
        Str empty_name = StrInit();
        Str  json    = StrInit();
    
        Str empty_name = StrInit();
        Str empty_desc = StrInit();
    
        Str empty_name = StrInit();
        Str empty_desc = StrInit();
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit();
    
        i32 temp    = -25;
    
        bool success = true;
        Str  json    = StrInit();
    
        i64 big_int     = 9223372036854775807LL;
    
        bool success = true;
        Str  json    = StrInit();
    
        i32  int_zero   = 0;
    
        bool success = true;
        Str  json    = StrInit();
    
        // 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");
        Str message = StrInitFromZstr("Hello, \"World\"!");
        Str data    = StrInitFromZstr("line1\nline2\ttab");
        // Note: These are the actual characters, not escape sequences
        Str path    = StrInitFromZstr("C:\\Program Files\\App");
        Str message = StrInitFromZstr("Hello, \"World\"!");
        Str data    = StrInitFromZstr("line1\nline2\ttab");
        Str path    = StrInitFromZstr("C:\\Program Files\\App");
        Str message = StrInitFromZstr("Hello, \"World\"!");
        Str data    = StrInitFromZstr("line1\nline2\ttab");
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit();
    
        // These contain actual special characters that should be escaped
    
        // These contain actual special characters that should be escaped
        Str quotes    = StrInitFromZstr("\"quotes\"");
        Str backslash = StrInitFromZstr("\\");
        Str newline   = StrInitFromZstr("\n");
        // These contain actual special characters that should be escaped
        Str quotes    = StrInitFromZstr("\"quotes\"");
        Str backslash = StrInitFromZstr("\\");
        Str newline   = StrInitFromZstr("\n");
        Str tab       = StrInitFromZstr("\t");
        Str quotes    = StrInitFromZstr("\"quotes\"");
        Str backslash = StrInitFromZstr("\\");
        Str newline   = StrInitFromZstr("\n");
        Str tab       = StrInitFromZstr("\t");
        Str backslash = StrInitFromZstr("\\");
        Str newline   = StrInitFromZstr("\n");
        Str tab       = StrInitFromZstr("\t");
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit();
    
        Vec(i32) empty_list = VecInit();
    
        bool success = true;
        Str  json    = StrInit();
    
        Vec(i32) empty_arr  = VecInit();
    
        bool success = true;
        Str  json    = StrInit();
    
        i64 max_int   = 2147483647LL;
    
        bool success = true;
        Str  json    = StrInit();
    
        f64 tiny          = 0.000001;
    
        bool success = true;
        Str  json1   = StrInit();
        Str  json2   = StrInit();
        Str  json3   = StrInit();
        bool success = true;
        Str  json1   = StrInit();
        Str  json2   = StrInit();
        Str  json3   = StrInit();
        Str  json4   = StrInit();
        Str  json1   = StrInit();
        Str  json2   = StrInit();
        Str  json3   = StrInit();
        Str  json4   = StrInit();
        Str  json2   = StrInit();
        Str  json3   = StrInit();
        Str  json4   = StrInit();
    
        // Single integer
    
        // Single string
        Str single_str = StrInitFromZstr("hello");
        JW_OBJ(json2, { JW_STR_KV(json2, "text", single_str); });
    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, const char *expected) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected);
    bool compare_json_output(const Str *output, const char *expected) {
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
        // Create a copy of expected without spaces for comparison
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
        Str expected_str   = StrInitFromZstr(expected);
        Str output_clean   = StrInit();
        Str expected_clean = StrInit();
    
        // Remove spaces and newlines from both strings for comparison
    
        bool success = true;
        Str  json    = StrInit();
    
        Str name = StrInitFromZstr("Alice");
        Str  json    = StrInit();
    
        Str name = StrInitFromZstr("Alice");
        Str city = StrInitFromZstr("New York");
    
        Str name = StrInitFromZstr("Alice");
        Str city = StrInitFromZstr("New York");
    
        JW_OBJ(json, {
    
        bool success = true;
        Str  json    = StrInit();
    
        u32 count = 42;
    
        bool success = true;
        Str  json    = StrInit();
    
        bool enabled = true;
    
        bool success = true;
        Str  json    = StrInit();
    
        Person person = {1001, StrInitFromZstr("Bob"), 25, true, 50000.0};
    
        bool success = true;
        Str  json    = StrInit();
    
        Config config = {false, 30, StrInitFromZstr("INFO")};
    
        bool success = true;
        Str  json    = StrInit();
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
        Str  json    = StrInit();
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
    
        // Create strings and push them properly
    
        // Create strings and push them properly
        Str lang1 = StrInitFromZstr("C");
        Str lang2 = StrInitFromZstr("Python");
        Str lang3 = StrInitFromZstr("Rust");
        // Create strings and push them properly
        Str lang1 = StrInitFromZstr("C");
        Str lang2 = StrInitFromZstr("Python");
        Str lang3 = StrInitFromZstr("Rust");
        Str lang1 = StrInitFromZstr("C");
        Str lang2 = StrInitFromZstr("Python");
        Str lang3 = StrInitFromZstr("Rust");
    
        VecPushBack(&languages, lang1);
    
        bool success = true;
        Str  json    = StrInit();
    
        struct {
        struct {
            struct {
                Str name;
                Str email;
            } user;
            struct {
                Str name;
                Str email;
            } user;
            bool active;
    
        bool success = true;
        Str  json    = StrInit();
    
        SimpleProduct product = {0};
    
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("electronics");
        Str tag2 = StrInitFromZstr("computers");
        Str tag3 = StrInitFromZstr("portable");
        // Create strings and push them properly
        Str tag1 = StrInitFromZstr("electronics");
        Str tag2 = StrInitFromZstr("computers");
        Str tag3 = StrInitFromZstr("portable");
        Str tag1 = StrInitFromZstr("electronics");
        Str tag2 = StrInitFromZstr("computers");
        Str tag3 = StrInitFromZstr("portable");
    
        VecPushBack(&product.tags, tag1);
    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;
            f64  temperature;
            bool enabled;
            Str  message;
        } original = {42, 25.5, true, StrInitFromZstr("hello world")};
    
        // Write to JSON
        Str json = StrInit();
        JW_OBJ(json, {
            JW_INT_KV(json, "count", original.count);
            f64  temperature;
            bool enabled;
            Str  message;
        } parsed = {0, 0.0, false, StrInit()};
    
        // Write to JSON
        Str json = StrInit();
        JW_OBJ(json, {
            JW_INT_KV(json, "big_int", original.big_int);
    
        // Write to JSON
        Str json = StrInit();
        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(),
    
        // Write to JSON
        Str json = StrInit();
        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(), StrInit(), StrInit(), StrInit()};
            Str simple;
            Str with_spaces;
            Str with_special;
        } parsed = {StrInit(), StrInit(), StrInit(), StrInit()};
        // Original data
        Vec(i32) original_numbers = VecInit();
        Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
        // Populate arrays
    
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("first");
        Str str2 = StrInitFromZstr("second");
        Str str3 = StrInitFromZstr("");
        // Create strings and push them properly
        Str str1 = StrInitFromZstr("first");
        Str str2 = StrInitFromZstr("second");
        Str str3 = StrInitFromZstr("");
        Str str4 = StrInitFromZstr("last");
        Str str1 = StrInitFromZstr("first");
        Str str2 = StrInitFromZstr("second");
        Str str3 = StrInitFromZstr("");
        Str str4 = StrInitFromZstr("last");
        Str str2 = StrInitFromZstr("second");
        Str str3 = StrInitFromZstr("");
        Str str4 = StrInitFromZstr("last");
    
        VecPushBack(&original_strings, str1);
    
        // Write to JSON
        Str json = StrInit();
        JW_OBJ(json, {
            JW_ARR_KV(json, "numbers", original_numbers, num, { JW_INT(json, num); });
        // Read back from JSON
        Vec(i32) parsed_numbers = VecInit();
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
        StrIter si = StrIterFromStr(json);
            });
            JR_ARR_KV(si, "strings", {
                Str str = StrInit();
                JR_STR(si, str);
                VecPushBack(&parsed_strings, str);
    
        // Write to JSON
        Str json = StrInit();
        JW_OBJ(json, {
            JW_OBJ_KV(json, "user", {
    
        // Create strings and push them properly
        Str feature1 = StrInitFromZstr("auth");
        Str feature2 = StrInitFromZstr("logging");
        // Create strings and push them properly
        Str feature1 = StrInitFromZstr("auth");
        Str feature2 = StrInitFromZstr("logging");
    
        VecPushBack(&original.config.features, feature1);
    
        // Write to JSON
        Str json = StrInit();
        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();
                    JR_STR(si, feature);
                    VecPushBack(&parsed.config.features, feature);
        // Original empty data
        Vec(i32) empty_numbers = VecInit();
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
        Str empty_str          = StrInit();
        Vec(i32) empty_numbers = VecInit();
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
        Str empty_str          = StrInit();
    
        // Write to JSON
    
        // Write to JSON
        Str json = StrInit();
        JW_OBJ(json, {
            JW_STR_KV(json, "empty_string", empty_str);
        // Read back from JSON
        Vec(i32) parsed_numbers = VecInit();
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
        Str  parsed_str         = StrInit();
        bool found_empty_object = false;
        Vec(i32) parsed_numbers = VecInit();
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
        Str  parsed_str         = StrInit();
        bool found_empty_object = false;
            });
            JR_ARR_KV(si, "empty_strings", {
                Str str = StrInit();
                JR_STR(si, str);
                VecPushBack(&parsed_strings, str);
    
        // Write to JSON
        Str json = StrInit();
        JW_OBJ(json, {
            JW_INT_KV(json, "max_int", original.max_int);
    // 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("{}");
        StrIter si1   = StrIterFromStr(json1);
    
        // Test empty object with whitespace
        Str     json2 = StrInitFromZstr("  {   }  ");
        StrIter si2   = StrIterFromStr(json2);
    
        // Test completely empty array
        Str     json1 = StrInitFromZstr("{\"items\":[]}");
        StrIter si1   = StrIterFromStr(json1);
    
        // Test empty array with whitespace
        Str     json2 = StrInitFromZstr("{\"data\": [  ] }");
        StrIter si2   = StrIterFromStr(json2);
        StrIter si2   = StrIterFromStr(json2);
    
        Vec(Str) data = VecInitWithDeepCopy(NULL, StrDeinit);
    
        JR_OBJ(si2, {
        JR_OBJ(si2, {
            JR_ARR_KV(si2, "data", {
                Str value = StrInit();
                JR_STR(si2, value);
                VecPushBack(&data, value);
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"name\":\"\",\"description\":\"\"}");
        StrIter si   = StrIterFromStr(json);
    
        struct {
            Str name;
            Str description;
        } obj = {StrInit(), StrInit()};
        struct {
            Str name;
            Str description;
        } obj = {StrInit(), StrInit()};
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"temp\":-25,\"balance\":-1000.50,\"delta\":-0.001}");
        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}");
        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(), StrInit(), StrInit()};
            Str path;
            Str message;
            Str data;
        } obj = {StrInit(), StrInit(), StrInit()};
        bool success = true;
    
        Str json =
            StrInitFromZstr("{\"escaped\":\"\\\"quotes\\\"\",\"backslash\":\"\\\\\",\"newline\":\"\\n\",\"tab\":\"\\t\"}");
        StrIter si = StrIterFromStr(json);
    
        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(), StrInit(), StrInit(), StrInit()};
            Str backslash;
            Str newline;
            Str tab;
        } obj = {StrInit(), StrInit(), StrInit(), StrInit()};
    
        // Test with lots of different whitespace patterns
        Str     json = StrInitFromZstr("  {\n\t\"name\"  :  \"test\"  ,\n  \"value\": 42\t,\"flag\"\n:\ntrue\n}\t");
        StrIter si   = StrIterFromStr(json);
    
        struct {
            Str  name;
            i32  value;
            bool flag;
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"outer\":{},\"list\":[],\"deep\":{\"inner\":{}}}");
        StrIter si   = StrIterFromStr(json);
        bool success = true;
    
        Str     json = StrInitFromZstr("{\"empty_obj\":{},\"filled_obj\":{\"x\":1},\"empty_arr\":[],\"filled_arr\":[1,2]}");
        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}");
        StrIter si   = StrIterFromStr(json);
        bool success = true;
    
        Str json   = StrInitFromZstr("{\"tiny\":0.000001,\"huge\":999999.999999,\"zero\":0.0,\"negative_tiny\":-0.000001}");
        StrIter si = StrIterFromStr(json);
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <stdio.h>
        WriteFmt("Testing StrInsertCharAt\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Insert a character in the middle
        WriteFmt("Testing StrInsertCstr\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Insert a string in the middle
        WriteFmt("Testing StrInsertZstr\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Insert a string in the middle
        WriteFmt("Testing StrInsert\n");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        // Insert s2 into s1 in the middle
        WriteFmt("Testing StrPushCstr\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Push a string at position 2
        WriteFmt("Testing StrPushZstr\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Push a string at position 2
        WriteFmt("Testing StrPushBackCstr\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Push a string at the back
        WriteFmt("Testing StrPushBackZstr\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Push a string at the back
        WriteFmt("Testing StrPushFrontCstr\n");
    
        Str s = StrInitFromZstr("World");
    
        // Push a string at the front
        WriteFmt("Testing StrPushFrontZstr\n");
    
        Str s = StrInitFromZstr("World");
    
        // Push a string at the front
        WriteFmt("Testing StrPushBack\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Push characters at the back
        WriteFmt("Testing StrPushFront\n");
    
        Str s = StrInitFromZstr("World");
    
        // Push characters at the front
        WriteFmt("Testing StrMergeL\n");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        // Merge s2 into s1 (L-value semantics)
        WriteFmt("Testing StrMergeR\n");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        // Merge s2 into s1 (R-value semantics)
        WriteFmt("Testing StrMerge\n");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr(" World");
    
        // Merge s2 into s1
        WriteFmt("Testing StrAppendf\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Append formatted string
    // 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");
        Str   text  = StrInit();
    
        FloatNegate(&value);
        Float b            = FloatFromStr("0.03");
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatAdd(&result_value, &a, &b);
        Float b            = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS);
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatAdd(&result_value, &a, &b);
        Int   whole        = IntFrom(2);
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatAdd(&result_value, &a, b);
        Float b            = FloatFromStr("2");
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatSub(&result_value, &a, &b);
        Float b            = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES);
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatSub(&result_value, &a, &b);
        Int   whole        = IntFrom(2);
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatSub(&result_value, &a, b);
        Float b            = FloatFromStr("-0.2");
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatMul(&result_value, &a, &b);
        Float b            = FloatFromStr("2");
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatMul(&result_value, &a, &b);
        Int   whole        = IntFrom(2);
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatMul(&result_value, &a, b);
        Float b            = FloatFromStr("8");
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatDiv(&result_value, &a, &b, 3);
        Float b            = FloatFromStr("2");
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatDiv(&result_value, &a, &b, 0);
        Int   whole        = IntFrom(3);
        Float result_value = FloatInit();
        Str   text         = StrInit();
    
        FloatDiv(&result_value, &a, b, 1);
    
        Int value = IntFrom(13);
        Str text  = IntToBinary(&value);
    
        bool result = IntBitLength(&value) == 4;
        Int value   = IntFromBytesLE(bytes, sizeof(bytes));
        u64 written = IntToBytesLE(&value, out, sizeof(out));
        Str text    = IntToHexStr(&value);
    
        bool result = written == 4;
        Int value   = IntFromBytesBE(bytes, sizeof(bytes));
        u64 written = IntToBytesBE(&value, out, sizeof(out));
        Str text    = IntToHexStr(&value);
    
        bool result = written == 4;
    
        Int value = IntFromBinary("001011");
        Str text  = IntToBinary(&value);
    
        bool result = IntToU64(&value) == 11;
        const char *digits = "123456789012345678901234567890";
        Int         value  = IntFromStr(digits);
        Str         text   = IntToStr(&value);
    
        bool result = strcmp(text.data, digits) == 0;
    
        Int value = IntFromStrRadix("zz", 36);
        Str text  = IntToStrRadix(&value, 36, false);
    
        bool result = IntToU64(&value) == 1295;
    
        Int value = IntFrom(0xBEEF);
        Str text  = IntToStrRadix(&value, 16, true);
    
        bool result = strcmp(text.data, "BEEF") == 0;
    
        Int zero = IntFromBinary("0");
        Str text = IntToBinary(&zero);
    
        bool result = IntBitLength(&zero) == 0;
    
        Int value = IntFromOctStr("0o7_55");
        Str text  = IntToOctStr(&value);
    
        bool result = IntToU64(&value) == 493;
        const char *hex   = "deadbeefcafebabe1234";
        Int         value = IntFromHexStr(hex);
        Str         text  = IntToHexStr(&value);
    
        bool result = strcmp(text.data, hex) == 0;
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Io.h>
    
        // Test basic string reading
        Str s = StrInit();
        z     = "Hello";
        StrReadFmt(z, "{}", s);
        StrReadFmt(z, "{}", s);
    
        Str expected = StrInitFromZstr("Hello");
        success      = success && (StrCmp(&s, &expected) == 0);
        StrDeinit(&expected);
    
        i32 num  = 0;
        Str name = StrInit();
        z        = "Count: 42, Name: Alice";
        StrReadFmt(z, "Count: {}, Name: {}", num, name);
        success = success && (num == 42);
    
        Str expected = StrInitFromZstr("Alice");
        success      = success && (StrCmp(&name, &expected) == 0);
        StrDeinit(&expected);
        success = success && abc_pass;
    
        Str str_val = StrInit();
        z           = "Hello";
        StrReadFmt(z, "{c}", str_val);
        z           = "Hello";
        StrReadFmt(z, "{c}", str_val);
        Str  expected = StrInitFromZstr("Hello");
        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();
            const char *in     = "Hello World";
    
            // Should read "hello" (stops at first space)
            Str  expected   = StrInitFromZstr("hello world");
            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();
            const char *in     = "Hello World";
    
            // Should read "hello" (stops at first space)
            Str  expected   = StrInitFromZstr("hello");
            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();
            const char *in     = "hello world";
    
            // Should read "HELLO" (stops at first space)
            Str  expected   = StrInitFromZstr("HELLO WORLD");
            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();
            Str         result2 = StrInit();
            const char *in      = "hello world";
        {
            Str         result1 = StrInit();
            Str         result2 = StrInit();
            const char *in      = "hello world";
        // Test 2.2: :A (uppercase) conversion
        {
            Str         result1 = StrInit();
            Str         result2 = StrInit();
            const char *in      = "hello world mighty misra";
        {
            Str         result1 = StrInit();
            Str         result2 = StrInit();
            const char *in      = "hello world mighty misra";
        // Test 3: :a with quoted string
        {
            Str         result = StrInit();
            const char *in     = "\"MiXeD CaSe\"";
    
            // Should read "mixed case" (converts the entire quoted string)
            Str  expected   = StrInitFromZstr("mixed case");
            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();
            const char *in     = "\"abc123XYZ\"";
    
            // Should read "ABC123XYZ" (only letters are converted, numbers unchanged)
            Str  expected   = StrInitFromZstr("ABC123XYZ");
            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();
            const char *in     = "Hello World";
    
            // Should read "Hello" (stops at first space, no case conversion)
            Str  expected   = StrInitFromZstr("Hello World");
            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(result1.data, "10110") == 0);
        WriteFmt(
        z          = "   1101";
        StrReadFmt(z, "{}", bv4);
        Str result4 = BitVecToStr(&bv4);
        success     = success && (ZstrCompare(result4.data, "1101") == 0);
        WriteFmt(
        z          = "0";
        StrReadFmt(z, "{}", bv5);
        Str result5 = BitVecToStr(&bv5);
        success     = success && (ZstrCompare(result5.data, "0") == 0);
        WriteFmt("Test 5 - Zero: {}, Success: {}\n", result5, (ZstrCompare(result5.data, "0") == 0) ? "true" : "false");
        Int oct = IntInit();
    
        Str dec_text = StrInit();
        Str hex_text = StrInit();
        Str bin_text = StrInit();
    
        Str dec_text = StrInit();
        Str hex_text = StrInit();
        Str bin_text = StrInit();
        Str oct_text = StrInit();
        Str dec_text = StrInit();
        Str hex_text = StrInit();
        Str bin_text = StrInit();
        Str oct_text = StrInit();
        Str hex_text = StrInit();
        Str bin_text = StrInit();
        Str oct_text = StrInit();
    
        z = "123456789012345678901234567890";
        Float neg = FloatInit();
    
        Str dec_text = StrInit();
        Str sci_text = StrInit();
        Str neg_text = StrInit();
    
        Str dec_text = StrInit();
        Str sci_text = StrInit();
        Str neg_text = StrInit();
        Str dec_text = StrInit();
        Str sci_text = StrInit();
        Str neg_text = StrInit();
    
        z = "1234567890.012345";
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    // Test Str type definition
    bool test_str_type(void) {
        WriteFmt("Testing Str type definition\n");
    
        // Create a Str object
    
        // Create a Str object
        Str s = StrInit();
    
        // Check that it behaves like a Vec of chars
    
        // Add some strings
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr("World");
        // Add some strings
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr("World");
    
        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(str1->data, "Hello") == 0);
    
        // Create a valid Str
        Str s = StrInit();
    
        // This should not crash
    
        // Create an invalid Str by corrupting its fields
        Str s = StrInit();
    
        // 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/Container/Str.h>
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Io.h>
        WriteFmt("Testing basic formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing string formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
    
        // Test Str object
        Str s = StrInitFromZstr("World");
        StrWriteFmt(&output, "{}", s);
        success = success && (ZstrCompare(output.data, "World") == 0);
        WriteFmt("Testing integer decimal formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing integer hexadecimal formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing integer binary formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing integer octal formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing basic floating point formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing floating point precision formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing special floating point values\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing width and alignment formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing multiple arguments\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing character formatting specifiers\n");
    
        Str  output  = StrInit();
        bool success = true;
    
        // Test with Str object
        Str s = StrInitFromZstr("MiXeD CaSe");
    
        // Test with :c (preserve case)
        WriteFmt("Testing BitVec formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing Int formatting\n");
    
        Str  output  = StrInit();
        bool success = true;
        WriteFmt("Testing Float formatting\n");
    
        Str   output  = StrInit();
        bool  success = true;
        Float exact   = FloatFromStr("1234567890.012345");
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Io.h>
        WriteFmt("Testing StrForeachIdx\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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();
        StrForeachIdx(&s, chr, idx) {
            StrWriteFmt(&result, "{c}{}", chr, idx);
        WriteFmt("Testing StrForeachReverseIdx\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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();
    
        StrForeachReverseIdx(&s, chr, idx) {
        WriteFmt("Testing StrForeachPtrIdx\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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();
        StrForeachPtrIdx(&s, chrptr, idx) {
            // Append the character (via pointer) and its index to the result string
        WriteFmt("Testing StrForeachReversePtrIdx\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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();
    
        StrForeachReversePtrIdx(&s, chrptr, idx) {
        WriteFmt("Testing StrForeach\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Build a new string by iterating through each character
    
        // Build a new string by iterating through each character
        Str result = StrInit();
        StrForeach(&s, chr) {
            // Append the character to the result string
        WriteFmt("Testing StrForeachReverse\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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();
        size char_count = 0;
        WriteFmt("Testing StrForeachPtr\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Build a new string by iterating through each character pointer
    
        // Build a new string by iterating through each character pointer
        Str result = StrInit();
        StrForeachPtr(&s, chrptr) {
            // Append the character (via pointer) to the result string
        WriteFmt("Testing StrForeachPtrReverse\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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();
        size char_count = 0;
        WriteFmt("Testing StrForeachInRangeIdx\n");
    
        Str s = StrInitFromZstr("Hello World");
    
        // 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();
        StrForeachInRangeIdx(&s, chr, idx, 6, 11) {
            // Append the character and its index to the result string
    
        // Test with empty range
        Str empty_result = StrInit();
        StrForeachInRangeIdx(&s, chr, idx, 3, 3) {
            // This block should not execute
        WriteFmt("Testing StrForeachInRange\n");
    
        Str s = StrInitFromZstr("Hello World");
    
        // 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();
        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();
        StrForeachInRange(&s, chr, 6, 11) {
            // Append the character to the result string
        WriteFmt("Testing StrForeachPtrInRangeIdx\n");
    
        Str s = StrInitFromZstr("Hello World");
    
        // 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();
        StrForeachPtrInRangeIdx(&s, chrptr, idx, 6, 11) {
            // Append the character and its index to the result string
        WriteFmt("Testing StrForeachPtrInRange\n");
    
        Str s = StrInitFromZstr("Hello World");
    
        // 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();
        StrForeachPtrInRange(&s, chrptr, 0, 5) {
            // Append the character to the result string
        WriteFmt("Testing StrForeachInRangeIdx where idx goes out of bounds\n");
    
        Str s = StrInitFromZstr("Hello World!"); // 12 characters
    
        // Use StrForeachInRangeIdx which captures the 'end' parameter at the start
        WriteFmt("Testing StrForeachInRangeIdx with character deletion where idx goes out of bounds\n");
    
        Str s = StrInitFromZstr("Programming"); // 11 characters
    
        // Use StrForeachInRangeIdx with a fixed range that will become invalid
        WriteFmt("Testing StrForeachReverseIdx where idx goes out of bounds\n");
    
        Str s = StrInitFromZstr("Beautiful Weather"); // 17 characters
    
        // StrForeachReverseIdx (VecForeachReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
        WriteFmt("Testing StrForeachPtrIdx where idx goes out of bounds\n");
    
        Str s = StrInitFromZstr("Programming Test"); // 16 characters
    
        // StrForeachPtrIdx (VecForeachPtrIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
        WriteFmt("Testing StrForeachReversePtrIdx where idx goes out of bounds\n");
    
        Str s = StrInitFromZstr("Excellent Example"); // 17 characters
    
        // StrForeachReversePtrIdx (VecForeachPtrReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
        WriteFmt("Testing StrForeachPtrInRangeIdx where idx goes out of bounds\n");
    
        Str s = StrInitFromZstr("Comprehensive Testing Framework"); // 31 characters
    
        // Use StrForeachPtrInRangeIdx with a fixed range that becomes invalid when we modify the string
        WriteFmt("Testing basic StrForeachIdx where idx goes out of bounds\n");
    
        Str s = StrInitFromZstr("Testing Basic"); // 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");
    }
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <stdio.h>
        WriteFmt("Testing StrFromU64\n");
    
        Str s = StrInit();
    
        // Test decimal conversion
        WriteFmt("Testing StrFromI64\n");
    
        Str s = StrInit();
    
        // Test positive decimal conversion
        WriteFmt("Testing StrFromF64\n");
    
        Str s = StrInit();
    
        // Test integer conversion
    
        // Test decimal conversion
        Str  s       = StrInitFromZstr("12345");
        u64  value   = 0;
        bool success = StrToU64(&s, &value, NULL);
    
        // Test positive decimal conversion
        Str  s       = StrInitFromZstr("12345");
        i64  value   = 0;
        bool success = StrToI64(&s, &value, NULL);
    
        // Test integer conversion
        Str  s       = StrInitFromZstr("123");
        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");
    
        bool result = true;
    
        for (size_t i = 0; i < sizeof(u64_values) / sizeof(u64_values[0]); i++) {
            Str s = StrInit();
    
            // Test decimal round-trip
    
        for (size_t i = 0; i < sizeof(i64_values) / sizeof(i64_values[0]); i++) {
            Str s = StrInit();
    
            // Test decimal round-trip
        for (size_t i = 0; i < sizeof(f64_values) / sizeof(f64_values[0]); i++) {
            for (u8 precision = 1; precision <= 6; precision++) {
                Str s = StrInit();
    
                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");
    
        bool result = true;
        // Test base boundary conditions
        for (u8 base = 2; base <= 36; base++) {
            Str s = StrInit();
    
            // Test with base value itself
    
        // Test extreme values
        Str s = StrInit();
    
        // Test maximum u64
    
        for (size_t i = 0; i < sizeof(prefix_tests) / sizeof(prefix_tests[0]); i++) {
            Str            test_str = StrInitFromZstr(prefix_tests[i].input);
            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");
    
        bool result = true;
    
        for (u8 precision = 1; precision <= 17; precision++) {
            Str s = StrInit();
    
            StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};
    
        for (size_t i = 0; i < sizeof(sci_values) / sizeof(sci_values[0]); i++) {
            Str s = StrInit();
    
            // Force scientific notation
    
        for (u8 base = 2; base <= 36; base++) {
            Str s = StrInit();
    
            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");
    
        bool result = true;
        // Test each base from 2 to 36
        for (u8 base = 2; base <= 36; base++) {
            Str s = StrInit();
    
            // Test StrFromU64
        // Test uppercase digits for bases that use letters (11-36)
        for (u8 base = 11; base <= 36; base++) {
            Str s = StrInit();
    
            StrIntFormat config = {.base = base, .uppercase = true, .use_prefix = false};
        for (size_t i = 0; i < sizeof(test_values) / sizeof(test_values[0]); i++) {
            for (u8 base = 2; base <= 36; base++) {
                Str s = StrInit();
    
                StrIntFormat config = {.base = base, .uppercase = false, .use_prefix = false};
    
    bool test_str_large_scale_conversions(void) {
        WriteFmt("Testing Str large-scale conversions\n");
    
        bool result = true;
            u64 test_value = i * 1000007; // Large prime multiplier
    
            Str          s      = StrInit();
            StrIntFormat config = {.base = 10, .uppercase = false};
            StrFromU64(&s, test_value, &config);
                f64 test_value = mantissa * pow(10.0, exp);
    
                Str            s      = StrInit();
                StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};
                StrFromF64(&s, test_value, &config);
        strcpy(long_number, "12345678901234567890123456789012345678901234567890");
    
        Str  long_str   = StrInitFromZstr(long_number);
        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/Log.h>
    #include <stdio.h>
        WriteFmt("Testing StrTryReduceSpace\n");
    
        Str s = StrInit();
    
        // Reserve more space than needed
        WriteFmt("Testing StrSwapCharAt\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Swap 'H' and 'o'
        WriteFmt("Testing StrResize\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Initial length should be 5
        WriteFmt("Testing StrReserve\n");
    
        Str s = StrInit();
    
        // Reserve more space
        WriteFmt("Testing StrClear\n");
    
        Str s = StrInitFromZstr("Hello, World!");
    
        // Initial length should be 13
        WriteFmt("Testing StrReverse\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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/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/Log.h>
        WriteFmt("Testing StrCmp and StrCmpCstr\n");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr("Hello");
        Str s3 = StrInitFromZstr("World");
    
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr("Hello");
        Str s3 = StrInitFromZstr("World");
        Str s4 = StrInitFromZstr("Hello World");
        Str s1 = StrInitFromZstr("Hello");
        Str s2 = StrInitFromZstr("Hello");
        Str s3 = StrInitFromZstr("World");
        Str s4 = StrInitFromZstr("Hello World");
        Str s2 = StrInitFromZstr("Hello");
        Str s3 = StrInitFromZstr("World");
        Str s4 = StrInitFromZstr("Hello World");
    
        // Test StrCmp with equal strings
        WriteFmt("Testing StrFindStr, StrFindZstr, and StrFindCstr\n");
    
        Str haystack = StrInitFromZstr("Hello World");
        Str needle1  = StrInitFromZstr("World");
        Str needle2  = StrInitFromZstr("Hello");
    
        Str haystack = StrInitFromZstr("Hello World");
        Str needle1  = StrInitFromZstr("World");
        Str needle2  = StrInitFromZstr("Hello");
        Str needle3  = StrInitFromZstr("NotFound");
        Str haystack = StrInitFromZstr("Hello World");
        Str needle1  = StrInitFromZstr("World");
        Str needle2  = StrInitFromZstr("Hello");
        Str needle3  = StrInitFromZstr("NotFound");
        Str needle1  = StrInitFromZstr("World");
        Str needle2  = StrInitFromZstr("Hello");
        Str needle3  = StrInitFromZstr("NotFound");
    
        // Test StrFindStr with match at end
        WriteFmt("Testing StrStartsWith and StrEndsWith variants\n");
    
        Str s      = StrInitFromZstr("Hello World");
        Str prefix = StrInitFromZstr("Hello");
        Str suffix = StrInitFromZstr("World");
    
        Str s      = StrInitFromZstr("Hello World");
        Str prefix = StrInitFromZstr("Hello");
        Str suffix = StrInitFromZstr("World");
        Str s      = StrInitFromZstr("Hello World");
        Str prefix = StrInitFromZstr("Hello");
        Str suffix = StrInitFromZstr("World");
    
        // Test StrStartsWith
    
        // Test StrReplaceZstr
        Str s1 = StrInitFromZstr("Hello World");
        StrReplaceZstr(&s1, "World", "Universe", 1);
        bool result = (ZstrCompare(s1.data, "Hello Universe") == 0);
        StrDeinit(&s1);
        s1          = StrInitFromZstr("Hello World");
        Str find    = StrInitFromZstr("World");
        Str replace = StrInitFromZstr("Universe");
        StrReplace(&s1, &find, &replace, 1);
        s1          = StrInitFromZstr("Hello World");
        Str find    = StrInitFromZstr("World");
        Str replace = StrInitFromZstr("Universe");
        StrReplace(&s1, &find, &replace, 1);
        result = result && (ZstrCompare(s1.data, "Hello Universe") == 0);
    
        // Test StrSplit
        Str  s     = StrInitFromZstr("Hello,World,Test");
        Strs split = StrSplit(&s, ",");
    
        // Test StrLStrip
        Str  s1       = StrInitFromZstr("  Hello  ");
        Str  stripped = StrLStrip(&s1, NULL);
        bool result   = (ZstrCompare(stripped.data, "Hello  ") == 0);
        // Test StrLStrip
        Str  s1       = StrInitFromZstr("  Hello  ");
        Str  stripped = StrLStrip(&s1, NULL);
        bool result   = (ZstrCompare(stripped.data, "Hello  ") == 0);
        StrDeinit(&stripped);
    // 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");
    }
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <stdio.h>
    
        // Convert to string
        Str str = BitVecToStr(&bv);
    
        // Check result
    
        // Test converting empty bitvec
        Str str_obj = BitVecToStr(&bv);
        result      = result && (str_obj.length == 0);
        StrDeinit(&str_obj);
        for (size_t i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
            BitVec bv  = BitVecFromStr(patterns[i]);
            Str    str = BitVecToStr(&bv);
    
            // Should get exact same string back
        BitVec empty = BitVecInit();
    
        Str empty_str = BitVecToStr(&empty);
        result        = result && (empty_str.length == 0);
        StrDeinit(&empty_str);
    
            // Test string conversion consistency
            Str str = BitVecToStr(&bv);
            result  = result && (ZstrCompare(str.data, 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 && (large_str.length == 1000);
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <stdio.h>
        WriteFmt("Testing StrFirst\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Get the first character
        WriteFmt("Testing StrLast\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Get the last character
        WriteFmt("Testing StrBegin\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Get a pointer to the first character using StrBegin
        WriteFmt("Testing StrEnd\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Get a pointer to one past the last character using StrEnd
        WriteFmt("Testing StrCharAt\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Access characters at different indices
        WriteFmt("Testing StrCharPtrAt\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // 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");
    }
    
        Float value = FloatFrom(42);
        Str   text  = FloatToStr(&value);
    
        bool result = strcmp(text.data, "42") == 0;
    
        Float value = FloatFrom(-42);
        Str   text  = FloatToStr(&value);
    
        bool result = strcmp(text.data, "-42") == 0;
        Int   integer = IntFromStr("12345678901234567890");
        Float value   = FloatFrom(&integer);
        Str   text    = FloatToStr(&value);
    
        bool result = strcmp(text.data, "12345678901234567890") == 0;
        Float value        = FloatFromStr("1234500e-2");
        Int   result_value = IntInit();
        Str   text         = StrInit();
    
        bool result = FloatToInt(&result_value, &value);
    
        Float value = FloatFromStr("-123.45");
        Str   text  = FloatToStr(&value);
    
        bool result = strcmp(text.data, "-123.45") == 0;
    
        Float value = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES);
        Str   text  = FloatToStr(&value);
    
        bool result = strcmp(text.data, FLOAT_TEST_VERY_LARGE_ONES) == 0;
    
        Float value = FloatFromStr("1.2300e3");
        Str   text  = FloatToStr(&value);
    
        bool result = strcmp(text.data, "1230") == 0;
        Int b      = IntFrom(1);
        Int result_value = IntInit();
        Str text   = StrInit();
    
        IntAdd(&result_value, &a, &b);
        Int result_value = IntInit();
        Int huge         = IntFromStr("123456789012345678901234567890");
        Str text         = StrInit();
    
        IntAdd(&result_value, &base, rhs);
        Int preserved    = IntFrom(99);
        Int huge         = IntFromStr("12345678901234567890");
        Str text         = StrInit();
    
        bool result = IntSub(&result_value, &base, rhs);
        Int value = IntFromStr("12345678901234567890");
        Int result_value = IntInit();
        Str text = StrInit();
    
        IntMul(&result_value, &value, 25u);
        Int exponent = IntFrom(20);
        Int result_value = IntInit();
        Str text = StrInit();
    
        IntPow(&result_value, &base, 20u);
        Int quotient  = IntInit();
        Int remainder = IntInit();
        Str qtext     = StrInit();
    
        IntDivMod(&quotient, &remainder, &dividend, 97u);
        Int dividend = IntFromStr("12345678901234567890");
        Int result_value = IntInit();
        Str text = StrInit();
    
        bool result = IntDivExact(&result_value, &dividend, 90u);
        Int quotient = IntInit();
        Int remainder = IntInit();
        Str text = StrInit();
    
        IntDivMod(&quotient, &remainder, &dividend, 97);
        Int value = IntFromStr("1000000000");
        Int next = IntInit();
        Str text = StrInit();
    
        IntNextPrime(&next, &value);
        Float clone    = FloatClone(&original);
        Float expected = FloatFromStr("-12.5");
        Str   text     = FloatToStr(&clone);
    
        FloatAbs(&original);
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <stdio.h>
        WriteFmt("Testing StrInit\n");
    
        Str s = StrInit();
    
        // Validate the string
        const char *test_str = "Hello, World!";
        size_t      len      = 5; // Just "Hello"
        Str         s        = StrInitFromCstr(test_str, len);
    
        // Validate the string
    
        const char *test_str = "Hello, World!";
        Str         s        = StrInitFromZstr(test_str);
    
        // Validate the string
        WriteFmt("Testing StrInitFromStr\n");
    
        Str src = StrInitFromZstr("Hello, World!");
        Str dst = StrInitFromStr(&src);
    
        Str src = StrInitFromZstr("Hello, World!");
        Str dst = StrInitFromStr(&src);
    
        // Validate both strings
        WriteFmt("Testing StrDup\n");
    
        Str src = StrInitFromZstr("Hello, World!");
        Str dst = StrDup(&src);
    
        Str src = StrInitFromZstr("Hello, World!");
        Str dst = StrDup(&src);
    
        // Validate both strings
        WriteFmt("Testing StrWriteFmt\n");
    
        Str s = StrInit();
        StrWriteFmt(&s, "Hello, {}!", &"World"[0]);
    
        // Test with the actual StrInitStack macro
        Str stack_str;
        StrInitStack(stack_str, 20, {
            // Inside the scope where the stack string is valid
        WriteFmt("Testing StrInitCopy\n");
    
        Str src = StrInitFromZstr("Hello, World!");
        Str dst = StrInit();
    
        Str src = StrInitFromZstr("Hello, World!");
        Str dst = StrInit();
    
        // Copy src to dst
        WriteFmt("Testing StrDeinit\n");
    
        Str s = StrInitFromZstr("Hello, World!");
    
        // 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/Log.h>
    #include <stdio.h>
        WriteFmt("Testing StrPopBack\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Pop a character from the back
        WriteFmt("Testing StrPopFront\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Pop a character from the front
        WriteFmt("Testing StrRemove\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Remove a character from the middle
        WriteFmt("Testing StrRemoveRange\n");
    
        Str s = StrInitFromZstr("Hello World");
    
        // Create a buffer to store the removed characters
        WriteFmt("Testing StrDeleteLastChar\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Delete the last character
        WriteFmt("Testing StrDelete\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Delete a character from the middle
        WriteFmt("Testing StrDeleteRange\n");
    
        Str s = StrInitFromZstr("Hello World");
    
        // 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");
    }
    #define MISRA_SYS_H
    
    #include <Misra/Std/Container/Str.h>
    #include <errno.h>
    /// TAGS: System, Environment, Memory
    ///
    Str *SysGetEnv(const char *name, Str *value);
    
    ///
    /// TAGS: System, Error, String
    ///
    Str *SysStrError(i32 eno, Str *err_str);
    
    ///
    
    // decompiler
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Sys.h>
    #include <Misra/Types.h>
    /// TAGS: I/O, Callback, Generic
    ///
    typedef void (*TypeSpecificWriter)(Str *o, FmtInfo *fmt_info, void *data);
    
    ///
                (x),                                                                                                       \
                TypeSpecificIO: (x),                                                                                       \
                Str: TO_TYPE_SPECIFIC_IO(Str, &(x)),                                                                       \
                Float: TO_TYPE_SPECIFIC_IO(Float, &(x)),                                                                   \
                Int: TO_TYPE_SPECIFIC_IO(Int, &(x)),                                                                       \
                (x),                                                                                                       \
                TypeSpecificIO: (x),                                                                                       \
                Str: TO_TYPE_SPECIFIC_IO(Str, (void *)&(x)),                                                               \
                Float: TO_TYPE_SPECIFIC_IO(Float, (void *)&(x)),                                                           \
                Int: TO_TYPE_SPECIFIC_IO(Int, (void *)&(x)),                                                               \
    /// TAGS: Formatting, I/O, String
    ///
    bool StrWriteFmtInternal(Str *o, const char *fmt, TypeSpecificIO *args, u64 argc);
    
    ///
            TypeSpecificIO *argv_ = &(varr)[0];                                                                            \
            u64             argc_ = sizeof(varr) / sizeof(TypeSpecificIO) - 1;                                             \
            Str             out_  = StrInit();                                                                             \
            StrWriteFmtInternal(&out_, (fmtstr), argv_, argc_);                                                            \
            fwrite(out_.data, 1, out_.length, (stream));                                                                   \
            TypeSpecificIO *argv_ = &(varr)[0];                                                                            \
            u64             argc_ = sizeof(varr) / sizeof(TypeSpecificIO) - 1;                                             \
            Str             out_  = StrInit();                                                                             \
            StrWriteFmtInternal(&out_, (fmtstr), argv_, argc_);                                                            \
            fwrite(out_.data, 1, out_.length, (stream));                                                                   \
    
    // not for direct use
    void _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
    void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    // not for direct use
    void _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
    void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    void _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
    void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
    void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
    void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
    void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
    void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
    void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
    void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
    void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
    void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
    void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
    void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
    void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
    void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
    void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
    void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
    void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
    void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
    void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
    void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
    void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
    void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
    
    const char *_read_Str(const char *i, FmtInfo *fmt_info, Str *s);
    void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
    
    const char *_read_Str(const char *i, FmtInfo *fmt_info, Str *s);
    const char *_read_u8(const char *i, FmtInfo *fmt_info, u8 *v);
    const char *_read_u16(const char *i, FmtInfo *fmt_info, u16 *v);
    #define MISRA_STD_CONTAINER_H
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Container/List.h>
    #define LOG_FATAL(...)                                                                                                 \
        do {                                                                                                               \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, m_.data);                                                 \
    #define LOG_ERROR(...)                                                                                                 \
        do {                                                                                                               \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, m_.data);                                                 \
    #define LOG_INFO(...)                                                                                                  \
        do {                                                                                                               \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, m_.data);                                                  \
    #define LOG_SYS_FATAL(...)                                                                                             \
        do {                                                                                                               \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            Str syserr_;                                                                                                   \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            Str syserr_;                                                                                                   \
            StrInitStack(syserr_, 256, {                                                                                   \
                SysStrError(errno, &syserr_);                                                                              \
    #define LOG_SYS_ERROR(...)                                                                                             \
        do {                                                                                                               \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            Str syserr_;                                                                                                   \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            Str syserr_;                                                                                                   \
            StrInitStack(syserr_, 256, {                                                                                   \
                SysStrError(errno, &syserr_);                                                                              \
    #define LOG_SYS_INFO(...)                                                                                              \
        do {                                                                                                               \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            Str syserr_;                                                                                                   \
            Str m_ = StrInit();                                                                                            \
            StrWriteFmt(&m_, __VA_ARGS__);                                                                                 \
            Str syserr_;                                                                                                   \
            StrInitStack(syserr_, 256, {                                                                                   \
                SysStrError(errno, &syserr_);                                                                              \
    
    // 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"
    // clang-format on
    #include "Str/Convert.h"
    #include "Str/Foreach.h"
    #include "Str/Ops.h"
    // clang-format on
        /// FAILURE : Returns NULL if config is invalid
        ///
        Str *StrFromU64(Str *str, u64 value, const StrIntFormat *config);
    
        ///
        /// FAILURE : Returns NULL if config is invalid
        ///
        Str *StrFromI64(Str *str, i64 value, const StrIntFormat *config);
    
        ///
        /// FAILURE : Returns NULL if config is invalid
        ///
        Str *StrFromF64(Str *str, f64 value, const StrFloatFormat *config);
    
        ///
        /// FAILURE : Returns false if conversion fails
        ///
        bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config);
    
        ///
        /// FAILURE : Returns false if conversion fails
        ///
        bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config);
    
        ///
        /// FAILURE : Returns false if conversion fails
        ///
        bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config);
    
    #ifdef __cplusplus
    #    define StrInitFromCstr(cstr, len)                                                                                 \
            (Str {                                                                                                         \
                .data        = ZstrDupN((char *)(cstr), (len)),                                                            \
                .length      = (len),                                                                                      \
    ///
    #    define StrInitFromCstr(cstr, len)                                                                                 \
            ((Str) {.data        = ZstrDupN((char *)(cstr), (len)),                                                        \
                    .length      = (len),                                                                                  \
                    .capacity    = (len),                                                                                  \
        /// FAILURE : NULL
        ///
        Str *StrPrintf(Str *str, const char *fmt, ...) FORMAT_STRING(2, 3);
    
    #ifdef __cplusplus
    
    #ifdef __cplusplus
    #    define StrInit() (Str VecInit())
    #else
    ///
    /// FAILURE : NULL
    ///
    #    define StrInit() ((Str)VecInit())
    #endif
        /// str : Pointer to string to be deinited
        ///
        void StrDeinit(Str *str);
    
        ///
        /// FAILURE : false
        ///
        bool StrInitCopy(Str *dst, const Str *src);
    
    #ifdef __cplusplus
        /// FAILURE : Returns false.
        ///
        bool StrStartsWithZstr(const Str *s, const char *prefix);
    
        ///
        /// FAILURE : Returns false.
        ///
        bool StrEndsWithZstr(const Str *s, const char *suffix);
    
        ///
        /// FAILURE : Returns false.
        ///
        bool StrStartsWithCstr(const Str *s, const char *prefix, size prefix_len);
    
        ///
        /// FAILURE : Returns false.
        ///
        bool StrEndsWithCstr(const Str *s, const char *suffix, size suffix_len);
    
        ///
        /// FAILURE : Returns false.
        ///
        bool StrStartsWith(const Str *s, const Str *prefix);
    
        ///
        /// FAILURE : Returns false.
        ///
        bool StrEndsWith(const Str *s, const Str *suffix);
    
        //
        /// FAILURE : No replacement if `match` not found.
        ///
        void StrReplaceZstr(Str *s, const char *match, const char *replacement, size count);
    
        ///
        ///
        void StrReplaceCstr(
            Str        *s,
            const char *match,
            size        match_len,
        /// FAILURE : No replacement if `match` not found.
        ///
        void StrReplace(Str *s, const Str *match, const Str *replacement, size count);
    
        //
        /// FAILURE : StrIters vector of zero-length
        ///
        StrIters StrSplitToIters(Str *s, const char *key);
    
        ///
        /// FAILURE : Strs vector of zero-length
        ///
        Strs StrSplit(Str *s, const char *key);
    
        //
        /// Used by StrStrip, StrLStrip, and StrRStrip macros.
        ///
        Str strip_str(Str *s, const char *key, int split_direction);
    
    ///
    /// Vector of strings
    ///
    typedef Vec(Str) Strs;
    
    ///
    /// FAILURE: `abort`
    ///
    void ValidateStr(const Str *s);
    
    ///
        /// FAILURE : NULL
        ///
        Str *StrAppendf(Str *str, const char *fmt, ...) FORMAT_STRING(2, 3);
    
    #ifdef __cplusplus
    #include "Type.h"
    #include <Misra/Types.h>
    #include <Misra/Std/Container/Str.h>
    
    #ifdef __cplusplus
        /// TAGS: BitVec, Convert, String, Export
        ///
        Str BitVecToStr(BitVec *bv);
    
        ///
    
    #include "Private.h"
    #include <Misra/Std/Container/Str.h>
    
    #ifdef __cplusplus
    /// TAGS: Int, Convert, String, Radix, Export
    ///
    Str IntToStrRadix(Int *value, u8 radix, bool uppercase);
    
    ///
    /// TAGS: Int, Convert, Decimal, String, Export
    ///
    Str IntToStr(Int *value);
    
    ///
    /// TAGS: Int, Convert, Binary, String, Export
    ///
    Str IntToBinary(Int *value);
    
    ///
    /// TAGS: Int, Convert, Octal, String, Export
    ///
    Str IntToOctStr(Int *value);
    
    ///
    /// TAGS: Int, Convert, Hex, String, Export
    ///
    Str IntToHexStr(Int *value);
    
    #ifdef __cplusplus
    
    #include "Private.h"
    #include <Misra/Std/Container/Str.h>
    
    #ifdef __cplusplus
    /// TAGS: Float, Convert, String, Format
    ///
    Str   FloatToStr(Float *value);
    
    #ifdef __cplusplus
    #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 my_str = StrInit();                                                                                        \
            si         = JReadString((si), &my_str);                                                                       \
            (str)      = my_str;                                                                                           \
        do {                                                                                                               \
            if (!StrCmpZstr(&key, (k))) {                                                                                  \
                Str my_str = StrInit();                                                                                    \
                si         = JReadString((si), &my_str);                                                                   \
                (str)      = my_str;                                                                                       \
                                                                                                                           \
                                                                                                                           \
                Str key = StrInit();                                                                                       \
                                                                                                                           \
                /* key start */                                                                                            \
    
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Utility/StrIter.h>
    #include <Misra/Types.h>
    /// TAGS: Parser, Config, KeyValue, Map
    ///
    typedef Map(Str, Str) KvConfig;
    
    ///
    /// FAILURE : Returns original iterator on invalid key.
    ///
    StrIter KvConfigReadKey(StrIter si, Str *key);
    
    ///
    /// FAILURE : Returns original iterator on parse error.
    ///
    StrIter KvConfigReadValue(StrIter si, Str *value);
    
    ///
    /// FAILURE : Returns original iterator on parse error.
    ///
    StrIter KvConfigReadPair(StrIter si, Str *key, Str *value);
    
    ///
    /// FAILURE : Empty `Str` if key does not exist.
    ///
    Str KvConfigGet(KvConfig *cfg, const char *key);
    
    ///
    /// FAILURE : `NULL` if key does not exist.
    ///
    Str *KvConfigGetPtr(KvConfig *cfg, const char *key);
    
    ///
    
    #include <Misra/Types.h>
    #include <Misra/Std/Container/Str.h>
    
    ///
    /// FAILURE: Return -1
    ///
    i32 SysProcWriteToStdin(SysProc *proc, Str *buf);
    
    ///
    /// FAILURE: Return -1
    ///
    i32 SysProcReadFromStdout(SysProc *proc, Str *buf);
    
    ///
    /// FAILURE: Return -1
    ///
    i32 SysProcReadFromStderr(SysProc *proc, Str *buf);
    
    ///
    /// TAGS: System, Process, Path
    ///
    Str *SysGetCurrentExecutablePath(Str *exe_path);
    
    #define SysProcReadFromStdoutFmt(p, ...)                                                                               \
    #define SysProcReadFromStdoutFmt(p, ...)                                                                               \
        do {                                                                                                               \
            Str b_ = StrInit();                                                                                            \
            SysProcReadFromStdout((p), &b_);                                                                               \
            const char *in_ = b_.data;                                                                                     \
    #define SysProcReadFromStderrFmt(p, ...)                                                                               \
        do {                                                                                                               \
            Str b_ = StrInit();                                                                                            \
            SysProcReadFromStderr((p), &b_);                                                                               \
            const char *in_ = b_.data;                                                                                     \
    #define SysProcWriteToStdinFmt(p, ...)                                                                                 \
        do {                                                                                                               \
            Str b_ = StrInit();                                                                                            \
            StrWriteFmt(&b_, __VA_ARGS__);                                                                                 \
            SysProcWriteToStdin((p), &b_);                                                                                 \
    #define SysProcWriteToStdinFmtLn(p, ...)                                                                               \
        do {                                                                                                               \
            Str b_ = StrInit();                                                                                            \
            StrWriteFmt(&b_, __VA_ARGS__);                                                                                 \
            StrPushBack(&b_, '\n');                                                                                        \
    #define MISRA_SYS_DIR_H
    
    #include <Misra/Std/Container/Str.h>
    
    typedef enum SysDirEntryType {
    typedef struct SysDirEntry {
        SysDirEntryType type;
        Str             name;
    } SysDirEntry;
Last updated on