engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
TOperatorJumpTable< ContextType > 模板结构体 参考

Jump table specifying how to execute an operator with different types 更多...

#include <ExpressionParserTypes.h>

Public 成员函数

FExpressionResult ExecBinary (const FExpressionToken &Operator, const FExpressionToken &L, const FExpressionToken &R, const ContextType *Context) const
 Execute the specified token as a binary operator, if such an overload exists
 
FExpressionResult ExecPostUnary (const FExpressionToken &Operator, const FExpressionToken &L, const ContextType *Context) const
 Execute the specified token as a unary operator, if such an overload exists
 
FExpressionResult ExecPreUnary (const FExpressionToken &Operator, const FExpressionToken &R, const ContextType *Context) const
 Execute the specified token as a unary operator, if such an overload exists
 
template<typename OperatorType , typename FuncType >
void MapBinary (FuncType InFunc)
 Map an expression node to a binary operator with the specified implementation. 更多...
 
template<typename OperatorType , typename FuncType >
void MapPostUnary (FuncType InFunc)
 Map an expression node to a post-unary operator with the specified implementation. 更多...
 
template<typename OperatorType , typename FuncType >
void MapPreUnary (FuncType InFunc)
 Map an expression node to a pre-unary operator with the specified implementation. 更多...
 
bool ShouldShortCircuit (const FExpressionToken &Operator, const FExpressionToken &L, const ContextType *Context) const
 Check whether we should short circuit the specified operator
 

详细描述

template<typename ContextType = void>
struct TOperatorJumpTable< ContextType >

Jump table specifying how to execute an operator with different types

成员函数说明

◆ MapBinary()

template<typename ContextType = void>
template<typename OperatorType , typename FuncType >
void TOperatorJumpTable< ContextType >::MapBinary ( FuncType  InFunc)

Map an expression node to a binary operator with the specified implementation.

The callable type must match the declaration Ret(OperandL, OperandR, [, Context]), where: Ret = Any DEFINE_EXPRESSION_NODE_TYPE type, OR FExpressionResult OperandL = Any DEFINE_EXPRESSION_NODE_TYPE type OperandR = Any DEFINE_EXPRESSION_NODE_TYPE type Context = (optional) const ptr to user-supplied arbitrary context

Examples that binds a '/' token to a function that attempts to do a division: JumpTable.MapUnary<FForwardSlash>([](double A, double B){ return A / B; }); // Runtime exception on div/0 JumpTable.MapUnary<FForwardSlash>([](double A, double B, FMyContext* Ctxt){ if (!Ctxt->IsMathEnabled()) { return A; } return A / B; // Runtime exception on div/0 }); JumpTable.MapUnary<FForwardSlash>([](double A, double B, const FMyContext* Ctxt) -> FExpressionResult { if (!Ctxt->IsMathEnabled()) { return MakeError(FExpressionError(LOCTEXT("MathNotEnabled", "Math is not enabled."))); } else if (B == 0) { return MakeError(FExpressionError(LOCTEXT("DivisionByZero", "Division by zero."))); }

return MakeValue(!A); });

◆ MapPostUnary()

template<typename ContextType = void>
template<typename OperatorType , typename FuncType >
void TOperatorJumpTable< ContextType >::MapPostUnary ( FuncType  InFunc)

Map an expression node to a post-unary operator with the specified implementation.

The same function signature rules apply here as with MapPreUnary.

◆ MapPreUnary()

template<typename ContextType = void>
template<typename OperatorType , typename FuncType >
void TOperatorJumpTable< ContextType >::MapPreUnary ( FuncType  InFunc)

Map an expression node to a pre-unary operator with the specified implementation.

The callable type must match the declaration Ret(Operand[, Context]), where: Ret = Any DEFINE_EXPRESSION_NODE_TYPE type, OR FExpressionResult Operand = Any DEFINE_EXPRESSION_NODE_TYPE type Context = (optional) const ptr to user-supplied arbitrary context

Examples that binds a '!' token to a function that attempts to do a boolean 'not': JumpTable.MapPreUnary<FExclamation>([](bool A){ return !A; }); JumpTable.MapPreUnary<FExclamation>([](bool A, FMyContext* Ctxt){ if (Ctxt->IsBooleanNotOpEnabled()) { return !A; } else { return A; } }); JumpTable.MapPreUnary<FExclamation>([](bool A, const FMyContext* Ctxt) -> FExpressionResult {

if (Ctxt->IsBooleanNotOpEnabled())
{
    return MakeValue(!A);
}
return MakeError(FExpressionError(LOCTEXT("NotNotEnabled", "Boolean not is not enabled.")));

});


该结构体的文档由以下文件生成: