StrWriteFmtInternal

Table of Contents

StrWriteFmtInternal

Description

Print out a formatted string with rust-style placeholders to given string o.

Warning

Directly passing literals like 1337 is not supported, especially const char* literals. For constants like integers, booleans, you can use LVAL(r-value) to convert an l-value to an r-value an then use in FMT like LVAL(false)

Parameters

NameDirectionDescription
ooutContents appended to this string.
fmtstrinFormat string with placeholders.
argvinArguments that placeholders will be replaced with.
argcinNumber of arguments.

Success

Placeholders in fmtstr are replaced by passed arguments.

Failure

Does not return, displays log messages.

Usage example (Cross-references)

    TypeSpecificIO *argv_##__LINE__ = &(varr)[0];                                                                  \
    size            argc_##__LINE__ = sizeof(varr) / sizeof(TypeSpecificIO);                                       \
    StrWriteFmtInternal((input), (fmtstr), argv_##__LINE__, argc_##__LINE__ - 1);                                  \
    } while (0)
    size            argc_##__LINE__ = sizeof(varr) / sizeof(TypeSpecificIO) - 1;                                   \
    Str             out_##__LINE__  = StrInit();                                                                   \
    StrWriteFmtInternal(&out_##__LINE__, (fmtstr), argv_##__LINE__, argc_##__LINE__);                              \
    fwrite(out_##__LINE__.data, 1, out_##__LINE__.length, (stream));                                               \
    StrDeinit(&out_##__LINE__);                                                                                    \
    size            argc_##__LINE__ = sizeof(varr) / sizeof(TypeSpecificIO) - 1;                                   \
    Str             out_##__LINE__  = StrInit();                                                                   \
    StrWriteFmtInternal(&out_##__LINE__, (fmtstr), argv_##__LINE__, argc_##__LINE__);                              \
    fwrite(out_##__LINE__.data, 1, out_##__LINE__.length, (stream));                                               \
    fputc('\n', (stream));                                                                                         \
    }
    
    bool StrWriteFmtInternal(Str* o, const char* fmt, TypeSpecificIO* args, size argc) {
    if (!o || !fmt) {
    LOG_FATAL("Invalid arguments");

Share :

Related Posts

void

void Description Type-specific write callback signature

Read More

JW_STR

JW_STR Description Append a string value (quoted) to the JSON.

Read More

JR_STR

JR_STR Description Read a JSON string value from stream and assign to target. The resulting string is dynamically allocated in Str format.

Read More