diff options
| author | JMC47 <JMC4789@gmail.com> | 2019-10-17 17:35:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-17 17:35:30 -0400 |
| commit | 8bc0a92f2cbf7bd7683bd95cb7c92e0e97287faf (patch) | |
| tree | 181d622aa609748673e4533d674ca487f1eb6f6f /Source/Core/InputCommon/ControlReference/FunctionExpression.h | |
| parent | acf9bd5ebeadfa7f1b11d39e0384a78093c43f27 (diff) | |
| parent | 7295458c11e1465c9e0a823620ea935396c4ea39 (diff) | |
Merge pull request #7663 from jordan-woyak/expression-parser-improve
Expression parser improvements
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/FunctionExpression.h')
| -rw-r--r-- | Source/Core/InputCommon/ControlReference/FunctionExpression.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControlReference/FunctionExpression.h b/Source/Core/InputCommon/ControlReference/FunctionExpression.h new file mode 100644 index 0000000000..f5332a0d25 --- /dev/null +++ b/Source/Core/InputCommon/ControlReference/FunctionExpression.h @@ -0,0 +1,55 @@ +// Copyright 2019 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include <memory> +#include <string> +#include <variant> +#include <vector> + +#include "InputCommon/ControlReference/ExpressionParser.h" +#include "InputCommon/ControlReference/FunctionExpression.h" + +namespace ciface +{ +namespace ExpressionParser +{ +class FunctionExpression : public Expression +{ +public: + struct ArgumentsAreValid + { + }; + + struct ExpectedArguments + { + std::string text; + }; + + using ArgumentValidation = std::variant<ArgumentsAreValid, ExpectedArguments>; + + int CountNumControls() const override; + void UpdateReferences(ControlEnvironment& env) override; + + ArgumentValidation SetArguments(std::vector<std::unique_ptr<Expression>>&& args); + + void SetValue(ControlState value) override; + +protected: + virtual ArgumentValidation + ValidateArguments(const std::vector<std::unique_ptr<Expression>>& args) = 0; + + Expression& GetArg(u32 number); + const Expression& GetArg(u32 number) const; + u32 GetArgCount() const; + +private: + std::vector<std::unique_ptr<Expression>> m_args; +}; + +std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string name); + +} // namespace ExpressionParser +} // namespace ciface |
