Skip to content

Zstr

Description

Read-only NUL-terminated C string – the project name for what libc calls const char *. Public API surface uses this typedef so the intent (“read a borrowed C-string here”) is visible at a glance; internal helpers may keep raw const char *.

Usage example (Cross-references)

Usage examples (Cross-references)
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Float.h>
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Sys.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Int.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra.h>
    #include <Misra/Parsers/Pe.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Parsers/Dns.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra.h>
    #include <Misra/Parsers/Pdb.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Parsers/Http.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/File.h>
    #include <Misra.h>
    #include <Misra/Parsers/Dwarf.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Parsers/Elf.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/ArgParse.h>
    #include <Misra/Std/Log.h>
    #include <Misra.h>
    #include <Misra/Parsers/Dwarf.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Parsers/Elf.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Float.h>
    #include <Misra/Std/Container/Int.h>
    #include <Misra.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys/Backtrace.h>
    #if FEATURE_SYS_SYMRESOLVE
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Graph.h>
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Heap.h>
    #include <Misra/Std/Container/Graph.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Map.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Sys/Dns.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra.h>
    #include <Misra/Parsers/MachO.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Float.h>
    #include <Misra/Std/Container/Int.h>
    #include <Misra.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys/SymbolResolver.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Allocator/Heap.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Memory.h>
    
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Sys/Socket.h>
    #include <Misra.h>
    #include <Misra/Std/Allocator/Debug.h>
    #include <Misra/Std/Zstr.h>
    
    #include "../Util/TestRunner.h"
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys/Dir.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Int.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Graph.h>
    #include <Misra/Std/Log.h>
    #endif
    
    Zstr EnvGet(Zstr name) {
        if (!name) {
            return NULL;
    
    #include <Misra/Sys/Dns.h>
    #include <Misra/Std/Zstr.h>
    
    #include <Misra/Parsers/Dns.h>
    
    #include <Misra/Sys/Proc.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys.h>
    #include <Misra/Std/Memory.h>
    #include "../_Syscall.h"
    
    Zstr DirEntryTypeToZstr(DirEntryType type) {
        switch (type) {
            case SYS_DIR_ENTRY_TYPE_UNKNOWN :
    #if PLATFORM_WINDOWS
    // Windows-specific implementation using FindFirstFile/FindNextFile
    DirContents dir_get_contents(Zstr path, Allocator *alloc) {
        if (!path || !alloc) {
            LOG_FATAL("Invalid argument");
    }
    
    DirContents dir_get_contents(Zstr path, Allocator *alloc) {
        if (!path || !alloc) {
            LOG_FATAL("invalid arguments.");
    #else
    // APPLE or other Unix-based system implementation using opendir/readdir.
    DirContents dir_get_contents(Zstr path, Allocator *alloc) {
        if (!path || !alloc) {
            LOG_FATAL("invalid arguments.");
    
    // Cross-platform function to get file size
    i64 file_get_size(Zstr filename) {
    #if PLATFORM_WINDOWS
        // Windows-specific code using GetFileSizeEx
    // ---------------------------------------------------------------------------
    
    i8 file_remove(Zstr path) {
        if (!path) {
            LOG_FATAL("FileRemove: NULL path");
    }
    
    i8 dir_remove(Zstr path) {
        if (!path) {
            LOG_FATAL("DirRemove: NULL path");
    #define DIR_CREATE_MODE 0755
    
    i8 dir_create(Zstr path) {
        if (!path) {
            LOG_FATAL("DirCreate: NULL path");
    }
    
    i8 dir_create_all(Zstr path) {
        if (!path) {
            LOG_FATAL("DirCreateAll: NULL path");
    #define DIR_REMOVE_ALL_PATH_CAP 512
    
    i8 dir_remove_all(Zstr path) {
        if (!path) {
            LOG_FATAL("DirRemoveAll: NULL path");
    }
    
    bool pe_open(Pe *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("PeOpen: NULL argument (contract violation)");
    }
    
    const PeSection *PeFindSection(const Pe *self, Zstr name) {
        if (!self || !name)
            return NULL;
    #include <Misra/Parsers/KvConfig.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Map/Private.h>
    #include <Misra/Std/Memory.h>
    }
    
    Str *KvConfigGetPtr(KvConfig *cfg, Zstr key) {
        Str  lookup = {0};
        Str *value  = NULL;
    }
    
    Str KvConfigGet(KvConfig *cfg, Zstr key) {
        Str *value = KvConfigGetPtr(cfg, key);
    }
    
    bool KvConfigContains(KvConfig *cfg, Zstr key) {
        return KvConfigGetPtr(cfg, key) != NULL;
    }
    }
    
    bool pdb_open(Pdb *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("PdbOpen: NULL argument (contract violation)");
    
    #include <Misra/Parsers/Http.h>
    #include <Misra/Std/Zstr.h>
    
    #if FEATURE_FILE
    }
    
    HttpHeader *HttpHeadersFind(HttpHeaders *headers, Zstr key) {
        if (!headers || !key) {
            LOG_FATAL("invalid arguments");
    }
    
    const char *HttpRequestParse(HttpRequest *req, Zstr in) {
        if (!req || !req->allocator || !in) {
            LOG_FATAL("invalid arguments");
    #if FEATURE_FILE
    HttpResponse *
        HttpRespondWithFile(HttpResponse *response, HttpResponseCode status, HttpContentType content_type, Zstr filepath) {
        if (!response || !response->allocator || !filepath) {
            LOG_FATAL("invalid arguments");
    }
    
    bool elf_open(Elf *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("ElfOpen: NULL argument (contract violation)");
    }
    
    const ElfSection *ElfFindSection(const Elf *self, Zstr name) {
        if (!self || !name)
            return NULL;
    #include <Misra/Parsers/JSON.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Allocator/Default.h>
    }
    
    bool macho_open(Macho *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("MachoOpen: NULL argument (contract violation)");
    }
    
    const MachoSection *MachoFindSection(const Macho *self, Zstr segment, Zstr section) {
        if (!self || !segment || !section)
            return NULL;
    
    #include <Misra/Std/ArgParse.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/File.h>
    #include <Misra/Std/Io.h>
    /* ------------------------------------------------------------------ */
    
    ArgParse arg_parse_init(Zstr name, Zstr about, Allocator *alloc) {
        if (!name)
            LOG_FATAL("ArgParseInit: name is required");
    
    #include <Misra/Std/Allocator/Default.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/File.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Zstr.h>
    
    size ZstrLen(const char *str) {
    #include <Misra/Sys/Backtrace.h>
    
    void LogWrite(LogMessageType type, Zstr tag, u64 line, Zstr msg) {
        if (!msg) {
            return;
    // ---------------------------------------------------------------------------
    
    File file_open(Zstr path, Zstr mode) {
        File f = {0};
    #if PLATFORM_WINDOWS
    
    #include <Misra/Std/Container/BitVec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Memory.h>
    
    #include <Misra/Std/Container/Int.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Int/Private.h>
    #include <Misra/Std/Container/BitVec.h>
    }
    
    bool IntTryFromStr(Int *out, Zstr decimal) {
        u64 start = 0;
    }
    
    Int int_from_str(Zstr decimal, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    bool IntTryFromStrRadix(Int *out, Zstr digits, u8 radix) {
        u64 start = 0;
    }
    
    Int int_from_str_radix(Zstr digits, u8 radix, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    bool IntTryFromBinary(Int *out, Zstr binary) {
        u64 start = 0;
        u64 len   = 0;
    }
    
    Int int_from_binary(Zstr binary, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    bool IntTryFromOctStr(Int *out, Zstr octal) {
        u64 start = 0;
        u64 len   = 0;
    }
    
    Int int_from_oct_str(Zstr octal, Allocator *alloc) {
        Int out = IntInit(alloc);
    }
    
    bool IntTryFromHexStr(Int *out, Zstr hex) {
        if (!out || !hex) {
            LOG_FATAL("Invalid arguments");
    }
    
    Int int_from_hex_str(Zstr hex, Allocator *alloc) {
        Int out = IntInit(alloc);
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Vec/Private.h>
    #include <Misra/Std/Log.h>
    }
    
    StrIters StrSplitToIters(Str *s, Zstr key) {
        ValidateStr(s);
    }
    
    Strs StrSplit(Str *s, Zstr key) {
        ValidateStr(s);
    }
    
    size StrIndexOfZstr(const Str *s, Zstr key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    }
    
    bool StrContainsZstr(const Str *s, Zstr key) {
        return StrIndexOfZstr(s, key) != SIZE_MAX;
    }
    //                 = -1 means from left
    //                 = 1 means from right
    Str strip_str(Str *s, Zstr chars_to_strip, int split_direction) {
        ValidateStr(s);
    }
    
    bool StrStartsWithZstr(const Str *s, Zstr prefix) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix, ZstrLen(prefix));
    }
    
    bool StrEndsWithZstr(const Str *s, Zstr suffix) {
        ValidateStr(s);
        return ends_with(s->data, s->length, suffix, ZstrLen(suffix));
    }
    
    void StrReplaceZstr(Str *s, Zstr match, Zstr replacement, size count) {
        ValidateStr(s);
        str_replace(s, match, ZstrLen(match), replacement, ZstrLen(replacement), count);
    
    #include <Misra/Std/Container/Float.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Float/Private.h>
    #include <Misra/Std/Container/Int.h>
    }
    
    bool FloatTryFromStr(Float *out, Zstr text) {
        Float result;
        Str   digits;
    }
    
    Float float_from_str(Zstr text, Allocator *alloc) {
        Float result = FloatInit(alloc);
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Utility.h>
    #include <Misra/Std/Zstr.h>
    
    #if FEATURE_ALLOC_ARENA
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys/Errno.h>
    #include <Misra/Sys/Mutex.h>
    /// TAGS: Environment
    ///
    Zstr EnvGet(Zstr name);
    
    ///
    
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    
    typedef enum DirEntryType {
    /// TAGS: System, Conversion, String, Utility
    ///
    Zstr DirEntryTypeToZstr(DirEntryType type);
    
    ///
    /// TAGS: System, FileSystem, Directory
    ///
    DirContents dir_get_contents(Zstr path, Allocator *alloc);
    #define DirGetContents(...) MISRA_OVERLOAD(DirGetContents, __VA_ARGS__)
    #define DirGetContents_1(path)                                                                                         \
    /// TAGS: System, File, Metadata
    ///
    i64 file_get_size(Zstr filename);
    #define FileGetSize(path)                                                                                              \
        _Generic(                                                                                                          \
    /// TAGS: System, File, FileSystem
    ///
    i8 file_remove(Zstr path);
    #define FileRemove(path)                                                                                               \
        _Generic(                                                                                                          \
    /// TAGS: System, Directory, FileSystem
    ///
    i8 dir_remove(Zstr path);
    #define DirRemove(path)                                                                                                \
        _Generic(                                                                                                          \
    /// TAGS: System, Directory, FileSystem
    ///
    i8 dir_create(Zstr path);
    #define DirCreate(path)                                                                                                \
        _Generic(                                                                                                          \
    /// TAGS: System, Directory, FileSystem
    ///
    i8 dir_create_all(Zstr path);
    #define DirCreateAll(path)                                                                                             \
        _Generic(                                                                                                          \
    /// TAGS: System, Directory, FileSystem
    ///
    i8 dir_remove_all(Zstr path);
    #define DirRemoveAll(path)                                                                                             \
        _Generic(                                                                                                          \
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Utility/StrIter.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
    /// FAILURE : Empty `Str` if key does not exist.
    ///
    Str KvConfigGet(KvConfig *cfg, Zstr key);
    
    ///
    /// FAILURE : `NULL` if key does not exist.
    ///
    Str *KvConfigGetPtr(KvConfig *cfg, Zstr key);
    
    ///
    /// FAILURE : `false`
    ///
    bool KvConfigContains(KvConfig *cfg, Zstr key);
    
    ///
    /// FAILURE : `false`
    ///
    bool KvConfigGetBool(KvConfig *cfg, Zstr key, bool *value);
    
    ///
    /// FAILURE : `false`
    ///
    bool KvConfigGetI64(KvConfig *cfg, Zstr key, i64 *value);
    
    ///
    /// FAILURE : `false`
    ///
    bool KvConfigGetF64(KvConfig *cfg, Zstr key, f64 *value);
    
    #endif // MISRA_PARSERS_KVCONFIG_H
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
    /// TAGS: Parser, PDB, File
    ///
    bool pdb_open(Pdb *out, Zstr path, Allocator *alloc);
    #define PdbOpen(...) MISRA_OVERLOAD(PdbOpen, __VA_ARGS__)
    #define PdbOpen_2(out, path)                                                                                           \
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
    /// TAGS: Parser, MachO, File
    ///
    bool macho_open(Macho *out, Zstr path, Allocator *alloc);
    #define MachoOpen(...) MISRA_OVERLOAD(MachoOpen, __VA_ARGS__)
    #define MachoOpen_2(out, path)                                                                                         \
    /// absent.
    ///
    const MachoSection *MachoFindSection(const Macho *self, Zstr segment, Zstr section);
    
    ///
    /// FAILURE : NULL if no header matches.
    ///
    HttpHeader *HttpHeadersFind(HttpHeaders *headers, Zstr key);
    
    typedef enum HttpResponseCode {
    /// FAILURE : Returns `in` unchanged when the input is malformed.
    ///
    const char *HttpRequestParse(HttpRequest *req, Zstr in);
    
    ///
    ///
    HttpResponse *
        HttpRespondWithFile(HttpResponse *response, HttpResponseCode status, HttpContentType content_type, Zstr filepath);
    #endif
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
    /// TAGS: Parser, PE, File
    ///
    bool pe_open(Pe *out, Zstr path, Allocator *alloc);
    #define PeOpen(...) MISRA_OVERLOAD(PeOpen, __VA_ARGS__)
    #define PeOpen_2(out, path)                                                                                            \
    /// they're vanishingly rare).
    ///
    const PeSection *PeFindSection(const Pe *self, Zstr name);
    
    ///
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
    /// TAGS: Parser, ELF, File
    ///
    bool elf_open(Elf *out, Zstr path, Allocator *alloc);
    #define ElfOpen(...) MISRA_OVERLOAD(ElfOpen, __VA_ARGS__)
    #define ElfOpen_2(out, path)                                                                                           \
    /// Find a section by name (first match). Returns NULL if absent.
    ///
    const ElfSection *ElfFindSection(const Elf *self, Zstr name);
    
    #endif // MISRA_PARSERS_ELF_H
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Sys.h>
    #include <Misra/Types.h>
    /// FAILURE : Returns a File where `FileIsOpen(&out)` is false.
    ///
    File file_open(Zstr path, Zstr mode);
    #define FileOpen(path, mode)                                                                                           \
        _Generic(                                                                                                          \
    /// TAGS: File, Read
    ///
    i64 file_read_and_close_to_buf(Zstr path, Buf *out);
    i64 file_read_and_close_to_str(Zstr path, Str *out);
    #define FileReadAndClose(path, out)                                                                                    \
    ///
    i64 file_read_and_close_to_buf(Zstr path, Buf *out);
    i64 file_read_and_close_to_str(Zstr path, Str *out);
    #define FileReadAndClose(path, out)                                                                                    \
        _Generic(                                                                                                          \
    /// TAGS: File, Write
    ///
    i64 file_write_and_close_from_buf(Zstr path, const Buf *in);
    i64 file_write_and_close_from_str(Zstr path, const Str *in);
    i64 file_write_and_close_from_bytes(Zstr path, const void *buf, u64 n);
    ///
    i64 file_write_and_close_from_buf(Zstr path, const Buf *in);
    i64 file_write_and_close_from_str(Zstr path, const Str *in);
    i64 file_write_and_close_from_bytes(Zstr path, const void *buf, u64 n);
    #define FileWriteAndClose(...) MISRA_OVERLOAD(FileWriteAndClose, __VA_ARGS__)
    i64 file_write_and_close_from_buf(Zstr path, const Buf *in);
    i64 file_write_and_close_from_str(Zstr path, const Str *in);
    i64 file_write_and_close_from_bytes(Zstr path, const void *buf, u64 n);
    #define FileWriteAndClose(...) MISRA_OVERLOAD(FileWriteAndClose, __VA_ARGS__)
    #define FileWriteAndClose_2(path, container)                                                                           \
    ///           by design; there is no upstream reporter to surface to).
    ///
    void LogWrite(LogMessageType type, Zstr tag, u64 line, Zstr msg);
    
    #endif // MISRA_STD_LOG_H
    #include <Misra/Std/Container/Str.h>
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Types.h>
        /// FAILURE: Aborts via `LOG_FATAL` on allocator OOM.
        ///
        ArgParse arg_parse_init(Zstr name, Zstr about, Allocator *alloc);
    
    #define ArgParseInit(...)                      MISRA_OVERLOAD(ArgParseInit, __VA_ARGS__)
    /// glance; internal helpers may keep raw `const char *`.
    typedef const char *Zstr;
    typedef Vec(Zstr) Zstrs;
    
    ///
    #include <Misra/Std/Container.h>
    #include <Misra/Std/Container/Buf.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/File.h>
    #include <Misra/Types.h>
                Str: TO_TYPE_SPECIFIC_IO(Str, &(x)),                                                                       \
                IOFMT_FLOAT_CASE_(x, &(x)) IOFMT_INT_CASE_(x, &(x)) IOFMT_BITVEC_CASE_(x, &(x))                            \
                    const char *: TO_TYPE_SPECIFIC_IO(Zstr, &(x)),                                                         \
                char *: TO_TYPE_SPECIFIC_IO(Zstr, &(x)),                                                                   \
                unsigned char: TO_TYPE_SPECIFIC_IO(u8, &(x)),                                                              \
                IOFMT_FLOAT_CASE_(x, &(x)) IOFMT_INT_CASE_(x, &(x)) IOFMT_BITVEC_CASE_(x, &(x))                            \
                    const char *: TO_TYPE_SPECIFIC_IO(Zstr, &(x)),                                                         \
                char *: TO_TYPE_SPECIFIC_IO(Zstr, &(x)),                                                                   \
                unsigned char: TO_TYPE_SPECIFIC_IO(u8, &(x)),                                                              \
                unsigned short: TO_TYPE_SPECIFIC_IO(u16, &(x)),                                                            \
                Str: TO_TYPE_SPECIFIC_IO(Str, (void *)&(x)),                                                               \
                IOFMT_FLOAT_CASE_(x, (void *)&(x)) IOFMT_INT_CASE_(x, (void *)&(x)) IOFMT_BITVEC_CASE_(x, (void *)&(x))    \
                    const char *: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)),                                                 \
                char *: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)),                                                           \
                unsigned char: TO_TYPE_SPECIFIC_IO(u8, (void *)&(x)),                                                      \
                IOFMT_FLOAT_CASE_(x, (void *)&(x)) IOFMT_INT_CASE_(x, (void *)&(x)) IOFMT_BITVEC_CASE_(x, (void *)&(x))    \
                    const char *: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)),                                                 \
                char *: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)),                                                           \
                unsigned char: TO_TYPE_SPECIFIC_IO(u8, (void *)&(x)),                                                      \
                unsigned short: TO_TYPE_SPECIFIC_IO(u16, (void *)&(x)),                                                    \
        /// TAGS: Float, Convert, Parse, Decimal
        ///
        bool FloatTryFromStr(Float *out, Zstr text);
    
        ///
        /// SUCCESS : Returns Parsed floating-point value, or zero on failure.
        ///
        Float float_from_str(Zstr text, Allocator *alloc);
    #define FloatFromStr(...)           MISRA_OVERLOAD(FloatFromStr, __VA_ARGS__)
    #define FloatFromStr_1(text)        float_from_str((text), MisraScope)
    #include "Type.h"
    #include <Misra/Std/Utility/StrIter.h>
    #include <Misra/Std/Zstr.h>
    
    #ifdef __cplusplus
        /// TAGS: Str, IndexOf, Search
        ///
        size StrIndexOfZstr(const Str *s, Zstr key);
    
        ///
        /// TAGS: Str, Contains, Search
        ///
        bool StrContainsZstr(const Str *s, Zstr key);
    
        ///
        /// FAILURE : Returns `false`. The string is not modified.
        ///
        bool StrStartsWithZstr(const Str *s, Zstr prefix);
    
        ///
        /// FAILURE : Returns `false`. The string is not modified.
        ///
        bool StrEndsWithZstr(const Str *s, Zstr suffix);
    
        ///
        /// FAILURE : No replacement if `match` not found.
        ///
        void StrReplaceZstr(Str *s, Zstr match, Zstr replacement, size count);
    
        ///
        /// FAILURE : StrIters vector of zero-length
        ///
        StrIters StrSplitToIters(Str *s, Zstr key);
    
        ///
        /// FAILURE : Strs vector of zero-length
        ///
        Strs StrSplit(Str *s, Zstr key);
    
        //
        /// Used by StrStrip, StrLStrip, and StrRStrip macros.
        ///
        Str strip_str(Str *s, Zstr key, int split_direction);
    
    ///
    #include "Type.h"
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Container/Vec/Type.h>
    
    #include "Type.h"
    #include <Misra/Std/Zstr.h>
    
    #ifdef __cplusplus
        /// TAGS: Int, Convert, Parse, Radix
        ///
        bool IntTryFromStrRadix(Int *out, Zstr digits, u8 radix);
    
        ///
        /// SUCCESS : Returns Parsed integer value, or zero on failure.
        ///
        Int int_from_str_radix(Zstr digits, u8 radix, Allocator *alloc);
    #define IntFromStrRadix(...)                    MISRA_OVERLOAD(IntFromStrRadix, __VA_ARGS__)
    #define IntFromStrRadix_2(digits, radix)        int_from_str_radix((digits), (radix), MisraScope)
        /// TAGS: Int, Convert, Parse, Decimal
        ///
        bool IntTryFromStr(Int *out, Zstr decimal);
    
        ///
        /// SUCCESS : Returns Parsed integer value, or zero on failure.
        ///
        Int int_from_str(Zstr decimal, Allocator *alloc);
    #define IntFromStr(...)              MISRA_OVERLOAD(IntFromStr, __VA_ARGS__)
    #define IntFromStr_1(decimal)        int_from_str((decimal), MisraScope)
        /// TAGS: Int, Convert, Parse, Binary
        ///
        bool IntTryFromBinary(Int *out, Zstr binary);
    
        ///
        /// SUCCESS : Returns Parsed integer value, or zero on failure.
        ///
        Int int_from_binary(Zstr binary, Allocator *alloc);
    #define IntFromBinary(...)             MISRA_OVERLOAD(IntFromBinary, __VA_ARGS__)
    #define IntFromBinary_1(binary)        int_from_binary((binary), MisraScope)
        /// TAGS: Int, Convert, Parse, Octal
        ///
        bool IntTryFromOctStr(Int *out, Zstr octal);
    
        ///
        /// SUCCESS : Returns Parsed integer value, or zero on failure.
        ///
        Int int_from_oct_str(Zstr octal, Allocator *alloc);
    #define IntFromOctStr(...)            MISRA_OVERLOAD(IntFromOctStr, __VA_ARGS__)
    #define IntFromOctStr_1(octal)        int_from_oct_str((octal), MisraScope)
        /// TAGS: Int, Convert, Parse, Hex
        ///
        bool IntTryFromHexStr(Int *out, Zstr hex);
    
        ///
        /// SUCCESS : Returns Parsed integer value, or zero on failure.
        ///
        Int int_from_hex_str(Zstr hex, Allocator *alloc);
    #define IntFromHexStr(...)          MISRA_OVERLOAD(IntFromHexStr, __VA_ARGS__)
    #define IntFromHexStr_1(hex)        int_from_hex_str((hex), MisraScope)
    
    #include <Misra/Std/Container/Vec/Type.h>
    #include <Misra/Std/Zstr.h>
    #include <Misra/Std/Utility/Iter.h>
    #include <Misra/Types.h>
Last updated on