You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <AzCore/RTTI/RTTI.h>
|
|
|
|
#include <ExpressionEngine/ExpressionElementParser.h>
|
|
#include <ExpressionEngine/InternalTypes.h>
|
|
|
|
namespace ExpressionEvaluation
|
|
{
|
|
struct VariableDescriptor
|
|
{
|
|
AZ_RTTI(VariableDescriptor, "{6D219DB1-3763-4408-A3E8-75E4AE66E9BD}");
|
|
|
|
VariableDescriptor()
|
|
{
|
|
}
|
|
|
|
VariableDescriptor(const AZStd::string& displayName)
|
|
: m_displayName(displayName)
|
|
, m_nameHash(AZ::Crc32(displayName))
|
|
{
|
|
}
|
|
|
|
virtual ~VariableDescriptor() = default;
|
|
|
|
AZStd::string m_displayName;
|
|
AZ::Crc32 m_nameHash;
|
|
};
|
|
|
|
// Interface that adds in support for Variables into the Expression grammar.
|
|
class VariableParser
|
|
: public ExpressionElementParser
|
|
{
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(VariableParser, AZ::SystemAllocator, 0);
|
|
|
|
static int GetVariableOperatorId()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
static ElementInformation GetVariableInformation(const AZStd::string& displayName);
|
|
|
|
VariableParser();
|
|
|
|
ExpressionParserId GetParserId() const override
|
|
{
|
|
return InternalTypes::Interfaces::InternalParser;
|
|
}
|
|
|
|
ParseResult ParseElement(const AZStd::string& inputText, size_t offset) const override;
|
|
void EvaluateToken(const ElementInformation& parseResult, ExpressionResultStack& evaluationStack) const override;
|
|
|
|
private:
|
|
AZStd::regex m_regex;
|
|
};
|
|
}
|