Open source Star Ruler 2 source code!

This commit is contained in:
Lucas de Vries
2018-07-17 14:15:37 +02:00
commit cc307720ff
4342 changed files with 2365070 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#pragma once
#include <string>
typedef double varInterpreter(void*,const std::string*);
typedef double varIndexInterpreter(void*,int);
typedef int varIndexConverter(const std::string*);
double nullConverter(void*,const std::string*);
struct FormulaError {
std::string msg;
FormulaError(const char* message) : msg(message) {}
FormulaError(std::string message) : msg(message) {}
};
class Formula {
public:
//Evaluates the formula
//Variables in the formula will be passed to <VarConverter>, which receives
//the name of the variable, and the <UserPointer> passed to evaluate
virtual double evaluate(varInterpreter VarConverter = nullConverter, void* UserPointer = nullptr, varIndexInterpreter VarIndexConverter = 0) = 0;
virtual ~Formula() {}
//Creates a formula from infix notation
//Can throw FormulaError if there is an error in the expression
static Formula* fromInfix(const char* expression, varIndexConverter VarConverter = 0, bool catchErrors = true);
};
;