switch-case

cesars/utils/switch-case

No description
switch-case
@/switch-case
INgeneric t1
DEFgeneric t2
Default value that is emitted if IN did not match any Xns
X1generic t1 (variadic)
Y1generic t2 (variadic)
switch-case
IN
DEF
X1
Y1
OUT
OUTgeneric t2
To use the node in your project you should have the cesars/utils 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 {
    void evaluate(Context ctx) {
        auto lhs = getValue<input_IN>(ctx);
        auto rhs = getValue<input_X1>(ctx);
        bool cond = (ctx, lhs == rhs);
        auto trueVal = getValue<input_Y1>(ctx);
        auto falseVal = getValue<input_DEF>(ctx);
        emitValue<output_OUT>(ctx, cond ? trueVal : falseVal);
    }
}