uint64tconverter

hio/nwt-gus-hi/uint64tconverter

No description
uint64tconverter
@/uint64tconverter
INstring
UPDpulse
uint64tconverter
IN
UPD
To use the node in your project you should have the hio/nwt-gus-hi 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 require "0.35.0"

node {
    void evaluate(Context ctx) {
        if (!isInputDirty<input_UPD>(ctx))
            return;

        String str = getValue<input_String>(ctx);
        uint64_t result = 0;

        // Remove "0x" prefix if present
        if (str.startsWith("0x") || str.startsWith("0X")) {
            str = str.substring(2);
        }

        for (int i = 0; i < str.length(); i++) {
            char c = str[i];
            result = result * 16 + charToHex(c);
        }

        emitValue<output_OUT>(ctx, result);
        emitValue<output_Done>(ctx, 1); // Mark as complete
    }

    uint8_t charToHex(char c) {
        if (c >= '0' && c <= '9') {
            return c - '0';
        } else if (c >= 'A' && c <= 'F') {
            return c - 'A' + 10;
        } else if (c >= 'a' && c <= 'f') {
            return c - 'a' + 10;
        }
        return 0; // Invalid character (should not occur)
    }
}