blob: 631d78ad07be36adfc69b535c4b756bdd8d39951 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#pragma once
#include "../memory/Memory.hpp"
#include <expected>
#include <string>
#include <optional>
#include <string_view>
namespace mu {
class Parser;
};
namespace Math {
struct SExpressionVec2 {
std::string x;
std::string y;
bool empty() const;
std::string toString() const;
};
std::expected<SExpressionVec2, std::string> parseExpressionVec2(std::string_view raw);
class CExpression {
public:
CExpression();
~CExpression() = default;
CExpression(const CExpression&) = delete;
CExpression(CExpression&) = delete;
CExpression(CExpression&&) = delete;
void addVariable(const std::string& name, double val);
std::optional<double> compute(const std::string& expr);
private:
UP<mu::Parser> m_parser;
};
};
|