* Add peglib * - Add expression engine - Take an expression when setting a counter * Shift + Click = Middleclick for counters * minor cleanup for clangify Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com> * Added tip entry
28 lines
477 B
C++
28 lines
477 B
C++
#ifndef EXPRESSION_H
|
|
#define EXPRESSION_H
|
|
|
|
#include <QMap>
|
|
#include <QString>
|
|
#include <functional>
|
|
|
|
namespace peg
|
|
{
|
|
template <typename Annotation> struct AstBase;
|
|
struct EmptyType;
|
|
typedef AstBase<EmptyType> Ast;
|
|
} // namespace peg
|
|
|
|
class Expression
|
|
{
|
|
public:
|
|
double value;
|
|
|
|
explicit Expression(double initial = 0);
|
|
double parse(const QString &expr);
|
|
|
|
private:
|
|
double eval(const peg::Ast &ast);
|
|
QMap<QString, std::function<double(double)>> fns;
|
|
};
|
|
|
|
#endif
|