Ark Server API (ASA) - Wiki
|
#include <ExpressionParserTypes.h>
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, FUnaryFunction > | PreUnaryOps |
TMap< FOperatorFunctionID, FUnaryFunction > | PostUnaryOps |
TMap< FOperatorFunctionID, FBinaryFunction > | BinaryOps |
TMap< FOperatorFunctionID, FShortCircuit > | BinaryShortCircuits |
Jump table specifying how to execute an operator with different types
Definition at line 280 of file ExpressionParserTypes.h.
typedef TFunction<FExpressionResult(const FExpressionNode&, const FExpressionNode&, const ContextType* Context) TOperatorJumpTable< ContextType >::FBinaryFunction) |
Definition at line 361 of file ExpressionParserTypes.h.
typedef TFunction<bool(const FExpressionNode&, const ContextType* Context) TOperatorJumpTable< ContextType >::FShortCircuit) |
Definition at line 362 of file ExpressionParserTypes.h.
typedef TFunction<FExpressionResult(const FExpressionNode&, const ContextType* Context) TOperatorJumpTable< ContextType >::FUnaryFunction) |
Definition at line 360 of file ExpressionParserTypes.h.
FExpressionResult TOperatorJumpTable< ContextType >::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
Definition at line 188 of file ExpressionParserTypes.inl.
FExpressionResult TOperatorJumpTable< ContextType >::ExecPostUnary | ( | const FExpressionToken & | Operator, |
const FExpressionToken & | L, | ||
const ContextType * | Context ) const |
Execute the specified token as a unary operator, if such an overload exists
Definition at line 231 of file ExpressionParserTypes.inl.
FExpressionResult TOperatorJumpTable< ContextType >::ExecPreUnary | ( | const FExpressionToken & | Operator, |
const FExpressionToken & | R, | ||
const ContextType * | Context ) const |
Execute the specified token as a unary operator, if such an overload exists
Definition at line 216 of file ExpressionParserTypes.inl.
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.
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.
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.
void TOperatorJumpTable< ContextType >::MapShortCircuit | ( | FuncType | InFunc | ) |
Definition at line 293 of file ExpressionParserTypes.inl.
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.
|
private |
Definition at line 369 of file ExpressionParserTypes.h.
|
private |
Definition at line 370 of file ExpressionParserTypes.h.
|
private |
Definition at line 368 of file ExpressionParserTypes.h.
|
private |
Maps of unary/binary operators
Definition at line 367 of file ExpressionParserTypes.h.