Skip to content

ZstrIOArg

Description

Explicit raw C-string I/O descriptor with allocator provenance.

This is used when a formatted I/O call needs to read into or rewrite a caller-owned zero-terminated string pointer whose storage may already be managed by a specific allocator.

Parameters

Name Direction Description
value in,out Address of the char * / const char * variable.
allocator in Allocator responsible for any existing pointed-to storage.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg) {
        const char **value = NULL;
    }
    
    const char *_read_ZstrAlloc(const char *i, FmtInfo *fmt_info, ZstrIOArg *arg) {
        char       **out              = NULL;
        char        *previous         = NULL;
        void      *value;
        Allocator *allocator;
    } ZstrIOArg;
    
    #ifdef __cplusplus
    #ifdef __cplusplus
    #    define ZstrIO(zstr, alloc_ptr)                                                                                   \
            TO_TYPE_SPECIFIC_IO(ZstrAlloc, &LVAL(((ZstrIOArg) {.value = (void *)&(zstr), .allocator = (alloc_ptr)})))
    #else
    #    define ZstrIO(zstr, alloc_ptr)                                                                                   \
                .writer = (TypeSpecificWriter)_write_ZstrAlloc,                                                           \
                .reader = (TypeSpecificReader)_read_ZstrAlloc,                                                           \
                .data   = &((ZstrIOArg) {.value = (void *)&(zstr), .allocator = (alloc_ptr)}),                           \
            })
    #endif
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
    bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
    bool _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
    bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
    const char *_read_i64(const char *i, FmtInfo *fmt_info, i64 *v);
    const char *_read_Zstr(const char *i, FmtInfo *fmt_info, const char **v);
    const char *_read_ZstrAlloc(const char *i, FmtInfo *fmt_info, ZstrIOArg *arg);
    const char *_read_UnsupportedType(const char *i, FmtInfo *fmt_info, const char **s);
    const char *_read_f32(const char *i, FmtInfo *fmt_info, f32 *v);
Last updated on