2019-01-26 18:17:30 +00:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2019-11-22 19:51:57 +00:00
|
|
|
#include <string_view>
|
2019-10-12 00:38:18 +00:00
|
|
|
#include <variant>
|
2019-01-26 18:17:30 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2019-11-22 19:48:10 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2019-01-26 18:17:30 +00:00
|
|
|
#include "InputCommon/ControlReference/ExpressionParser.h"
|
|
|
|
|
2019-11-22 19:44:33 +00:00
|
|
|
namespace ciface::ExpressionParser
|
2019-01-26 18:17:30 +00:00
|
|
|
{
|
|
|
|
class FunctionExpression : public Expression
|
|
|
|
{
|
|
|
|
public:
|
2019-10-12 00:38:18 +00:00
|
|
|
struct ArgumentsAreValid
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ExpectedArguments
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
};
|
|
|
|
|
|
|
|
using ArgumentValidation = std::variant<ArgumentsAreValid, ExpectedArguments>;
|
|
|
|
|
2019-01-26 18:17:30 +00:00
|
|
|
int CountNumControls() const override;
|
|
|
|
void UpdateReferences(ControlEnvironment& env) override;
|
|
|
|
|
2019-10-12 00:38:18 +00:00
|
|
|
ArgumentValidation SetArguments(std::vector<std::unique_ptr<Expression>>&& args);
|
2019-01-26 18:17:30 +00:00
|
|
|
|
2019-04-04 22:35:49 +00:00
|
|
|
void SetValue(ControlState value) override;
|
|
|
|
|
2019-01-26 18:17:30 +00:00
|
|
|
protected:
|
2019-10-12 00:38:18 +00:00
|
|
|
virtual ArgumentValidation
|
|
|
|
ValidateArguments(const std::vector<std::unique_ptr<Expression>>& args) = 0;
|
2019-01-26 18:17:30 +00:00
|
|
|
|
|
|
|
Expression& GetArg(u32 number);
|
|
|
|
const Expression& GetArg(u32 number) const;
|
2019-01-26 19:18:20 +00:00
|
|
|
u32 GetArgCount() const;
|
2019-01-26 18:17:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::unique_ptr<Expression>> m_args;
|
|
|
|
};
|
|
|
|
|
2019-11-22 19:51:57 +00:00
|
|
|
std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string_view name);
|
2019-01-26 18:17:30 +00:00
|
|
|
|
2019-11-22 19:44:33 +00:00
|
|
|
} // namespace ciface::ExpressionParser
|