Setup for making script options non global if desired
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
36
src/ScriptOptions.hpp
Normal file
36
src/ScriptOptions.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef PORYGONLANG_SCRIPTOPTIONS_HPP
|
||||
#define PORYGONLANG_SCRIPTOPTIONS_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Porygon{
|
||||
class ScriptOptions{
|
||||
static Porygon::ScriptOptions DefaultScriptOptions;
|
||||
static void (*_print)(const char16_t* s);
|
||||
static std::streambuf* _printBuffer;
|
||||
static std::ostream* _printStream;
|
||||
public:
|
||||
static Porygon::ScriptOptions* GetDefaultScriptOptions(){
|
||||
return &DefaultScriptOptions;
|
||||
}
|
||||
|
||||
inline void Print(const char16_t* s) const{
|
||||
ScriptOptions::_print(s);
|
||||
}
|
||||
|
||||
void SetPrintFunc(void (*print)(const char16_t *)){
|
||||
ScriptOptions::_print = print;
|
||||
}
|
||||
|
||||
std::ostream& GetPrintStream(){
|
||||
return *ScriptOptions::_printStream;
|
||||
}
|
||||
|
||||
void SetPrintStream(std::ostream* stream){
|
||||
delete ScriptOptions::_printStream;
|
||||
ScriptOptions::_printStream = stream;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //PORYGONLANG_SCRIPTOPTIONS_HPP
|
||||
Reference in New Issue
Block a user