In ChaiScript, there is a .use() function which takes a file path and loads the file and makes every function and variable available in the script. This is great functionality if you want a file from disk, however I'm looking to do the same but from a file which has been loaded, preprocessed as a string and stored in memory. So pretty much an equivalent to the .use function, taking a string representing the whole script instead of just a path.
Is this possible somehow?
I believe you simply want to call the eval
function, like:
std::string previouslyLoadedString = loadFileAsString();
chai.eval(previouslyLoadedString);
https://github.com/ChaiScript/ChaiScript/blob/develop/cheatsheet.md#general-1