Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TOperatorJumpTable< ContextType > Struct Template Reference

#include <ExpressionParserTypes.h>

+ Collaboration diagram for TOperatorJumpTable< ContextType >:

Public Types

typedef TFunction< FExpressionResult(const FExpressionNode &, const ContextType *Context) FUnaryFunction)
 
typedef TFunction< FExpressionResult(const FExpressionNode &, const FExpressionNode &, const ContextType *Context) FBinaryFunction)
 
typedef TFunction< bool(const FExpressionNode &, const ContextType *Context) FShortCircuit)
 

Public Member Functions

FExpressionResult ExecPreUnary (const FExpressionToken &Operator, const FExpressionToken &R, const ContextType *Context) const
 
FExpressionResult ExecPostUnary (const FExpressionToken &Operator, const FExpressionToken &L, const ContextType *Context) const
 
FExpressionResult ExecBinary (const FExpressionToken &Operator, const FExpressionToken &L, const FExpressionToken &R, const ContextType *Context) const
 
bool ShouldShortCircuit (const FExpressionToken &Operator, const FExpressionToken &L, const ContextType *Context) const
 
template<typename OperatorType , typename FuncType >
void MapPreUnary (FuncType InFunc)
 
template<typename OperatorType , typename FuncType >
void MapPostUnary (FuncType InFunc)
 
template<typename OperatorType , typename FuncType >
void MapBinary (FuncType InFunc)
 
template<typename OperatorType , typename FuncType >
void MapShortCircuit (FuncType InFunc)
 

Private Attributes

TMap< FOperatorFunctionID, FUnaryFunctionPreUnaryOps
 
TMap< FOperatorFunctionID, FUnaryFunctionPostUnaryOps
 
TMap< FOperatorFunctionID, FBinaryFunctionBinaryOps
 
TMap< FOperatorFunctionID, FShortCircuitBinaryShortCircuits
 

Detailed Description

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

Jump table specifying how to execute an operator with different types

Definition at line 280 of file ExpressionParserTypes.h.

Member Typedef Documentation

◆ FBinaryFunction

◆ FShortCircuit

Definition at line 362 of file ExpressionParserTypes.h.

◆ FUnaryFunction

Member Function Documentation

◆ ExecBinary()

Execute the specified token as a binary operator, if such an overload exists

Definition at line 188 of file ExpressionParserTypes.inl.

◆ ExecPostUnary()

Execute the specified token as a unary operator, if such an overload exists

Definition at line 231 of file ExpressionParserTypes.inl.

◆ ExecPreUnary()

Execute the specified token as a unary operator, if such an overload exists

Definition at line 216 of file ExpressionParserTypes.inl.

◆ MapBinary()

template<typename ContextType >
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); });

Definition at line 277 of file ExpressionParserTypes.inl.

◆ MapPostUnary()

template<typename ContextType >
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.

Definition at line 262 of file ExpressionParserTypes.inl.

◆ MapPreUnary()

template<typename ContextType >
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.")));

});

Definition at line 247 of file ExpressionParserTypes.inl.

◆ MapShortCircuit()

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

Definition at line 293 of file ExpressionParserTypes.inl.

◆ ShouldShortCircuit()

template<typename ContextType >
bool TOperatorJumpTable< ContextType >::ShouldShortCircuit ( const FExpressionToken & Operator,
const FExpressionToken & L,
const ContextType * Context ) const

Check whether we should short circuit the specified operator

Definition at line 204 of file ExpressionParserTypes.inl.

Member Data Documentation

◆ BinaryOps

Definition at line 369 of file ExpressionParserTypes.h.

◆ BinaryShortCircuits

template<typename ContextType = void>
TMap<FOperatorFunctionID, FShortCircuit> TOperatorJumpTable< ContextType >::BinaryShortCircuits
private

Definition at line 370 of file ExpressionParserTypes.h.

◆ PostUnaryOps

Definition at line 368 of file ExpressionParserTypes.h.

◆ PreUnaryOps

Maps of unary/binary operators

Definition at line 367 of file ExpressionParserTypes.h.


The documentation for this struct was generated from the following files: