repeat

wkov/colony/repeat

No description
repeat
@/repeat
CHRstring
One character as string.
LENnumber
String length.
repeat
STR
CHR
LEN
STRstring
To use the node in your project you should have the wkov/colony library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

node {
    char* result;
    CStringView view;

    void evaluate(Context ctx) {
        auto str = getValue<input_CHR>(ctx);
        unsigned char chr = *(str.iterate());

        size_t len = getValue<input_LEN>(ctx);

        result = new char[len + 1];
        view = CStringView(result);

        memset(result, chr, len);
        result[len] = '\0';

        emitValue<output_STR>(ctx, XString(&view));
    }
}

Tabular tests

CHRLENSTR
"#"2"##"
"*"3"***"
"x"4"xxxx"
"Hello"5"HHHHH"