To use the node in your project you should have the gweimer/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
node {
char* strBuff;
char* subBuff;
size_t maxlen;
CStringView view;
void evaluate(Context ctx) {
if (isSettingUp() || isInputDirty<input_STR>(ctx) || isInputDirty<input_OFST>(ctx) || isInputDirty<input_LEN>(ctx)) {
auto str = getValue<input_STR>(ctx);
maxlen = length(str);
char* strBuff = new char[maxlen+1];
memset(strBuff, '\0', maxlen + 1);
dump(str, strBuff);
auto ofst = getValue<input_OFST>(ctx);
auto len = getValue<input_LEN>(ctx);
subBuff = new char[maxlen+1];
memset(subBuff, '\0', maxlen + 1);
if (ofst < maxlen) {
if (ofst+len > maxlen) {
len = maxlen-ofst;
}
for (auto i = 0; i < len; i++) {
subBuff[i] = strBuff[ofst+i];
}
}
view = CStringView(subBuff);
emitValue<output_SUB>(ctx, XString(&view));
}
}
}