UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BasicMathExpressionEvaluator.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
8#include "Misc/Optional.h"
10
12
13#define DEFINE_EXPRESSION_OPERATOR_NODE(EXPORTAPI, TYPE, ...) \
14namespace ExpressionParser {\
15 struct EXPORTAPI TYPE { static const TCHAR* const Moniker; }; \
16}\
17DEFINE_EXPRESSION_NODE_TYPE(ExpressionParser::TYPE, __VA_ARGS__)
18
20DEFINE_EXPRESSION_OPERATOR_NODE(CORE_API, FSubExpressionStart, 0xCC40A083, 0xADBF46E2, 0xA93D12BB, 0x525D7417)
22
34
35namespace ExpressionParser
36{
38 CORE_API const FDecimalNumberFormattingRules& GetLocalizedNumberFormattingRules();
39
42
45
47 CORE_API TOptional<FStringToken> ParseLocalizedNumberWithAgnosticFallback(const FTokenStream& InStream, FStringToken* Accumulate = nullptr, double* OutValue = nullptr);
48
50 CORE_API TOptional<FStringToken> ParseLocalizedNumber(const FTokenStream& InStream, FStringToken* Accumulate = nullptr, double* OutValue = nullptr);
51
53 CORE_API TOptional<FStringToken> ParseNumber(const FTokenStream& InStream, FStringToken* Accumulate = nullptr, double* OutValue = nullptr);
54
57
59 CORE_API TOptional<FExpressionError> ConsumeLocalizedNumberWithAgnosticFallback(FExpressionTokenConsumer& Consumer);
60
62 CORE_API TOptional<FExpressionError> ConsumeLocalizedNumber(FExpressionTokenConsumer& Consumer);
63
66
68 template<typename TSymbol>
70 {
71 TOptional<FStringToken> Token = Consumer.GetStream().ParseToken(TSymbol::Moniker);
72 if (Token.IsSet())
73 {
74 Consumer.Add(Token.GetValue(), TSymbol());
75 }
76
78 }
79}
80
83{
84public:
87
90
96 CORE_API static void DefineArithmeticTokens(FTokenDefinitions& TokenDefinitions);
97 CORE_API static void DefineArithmeticOperators(FExpressionGrammar& TokenDefinitions);
99
100private:
101 FTokenDefinitions TokenDefinitions;
102 FExpressionGrammar Grammar;
103 FOperatorJumpTable JumpTable;
104};
#define DEFINE_EXPRESSION_OPERATOR_NODE(EXPORTAPI, TYPE,...)
Definition BasicMathExpressionEvaluator.h:13
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition BasicMathExpressionEvaluator.h:83
static CORE_API void MapArithmeticOperators(FOperatorJumpTable &JumpTable)
Definition BasicMathExpressionEvaluator.cpp:177
CORE_API FBasicMathExpressionEvaluator()
Definition BasicMathExpressionEvaluator.cpp:208
static CORE_API void DefineArithmeticOperators(FExpressionGrammar &TokenDefinitions)
Definition BasicMathExpressionEvaluator.cpp:159
static CORE_API void DefineArithmeticTokens(FTokenDefinitions &TokenDefinitions)
Definition BasicMathExpressionEvaluator.cpp:142
CORE_API TValueOrError< double, FExpressionError > Evaluate(const TCHAR *InExpression, double InExistingValue=0) const
Definition BasicMathExpressionEvaluator.cpp:224
Definition ExpressionParserTypes.h:557
Definition ExpressionParserTypes.h:456
CORE_API TTokenStream< CharType > & GetStream()
Definition ExpressionParser.cpp:303
CORE_API void Add(const TStringToken< CharType > &SourceToken, FExpressionNode &&Node)
Definition ExpressionParser.cpp:296
Definition ExpressionParserTypes.h:39
Definition ExpressionParserTypes.h:121
Definition ValueOrError.h:58
Definition BasicMathExpressionEvaluator.cpp:13
TOptional< FExpressionError > ConsumeSymbol(FExpressionTokenConsumer &Consumer)
Definition BasicMathExpressionEvaluator.h:69
Definition FastDecimalFormat.h:16
Definition Optional.h:131
constexpr OptionalType & GetValue()
Definition Optional.h:443
constexpr bool IsSet() const
Definition Optional.h:69