swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <QMap> |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 4 | #include <QDebug> |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 5 | #include "Token.h" |
| 6 | |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 7 | class VarContext |
| 8 | { |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 9 | public: |
| 10 | VarContext() = default; |
swissChili | a44bf72 | 2022-04-16 18:41:54 -0700 | [diff] [blame] | 11 | VarContext(VarContext const &other) noexcept; |
| 12 | VarContext &operator =(const VarContext &other) = default; |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 13 | |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 14 | void add(char t, const QString &name, const Token &value); |
| 15 | void add(char t, const QString &name, const QList<Token> &value); |
| 16 | |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 17 | char exists(const QString &name); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 18 | Token singleVar(const QString &name); |
| 19 | QList<Token> expressionVar(const QString &name); |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 20 | |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 21 | friend QDebug &operator <<(QDebug &debug, const VarContext &ctx); |
| 22 | |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 23 | private: |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 24 | struct Var |
| 25 | { |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 26 | Var() = default; |
| 27 | |
| 28 | char t = 0; |
| 29 | Token value; |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 30 | QList<Token> expressionValue; |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | QMap<QString, Var> _vars; |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 34 | }; |
| 35 | |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 36 | QDebug &operator <<(QDebug &debug, const VarContext &ctx); |