Description
The ExpressionCalculator class allows you to create an expression calculator.
Constructors
NewExpressionCalculator
Constructs this class with default parameters.
NewExpressionCalculator() *ExpressionCalculator
ExpressionCalculatorFromExpression
Constructs this class and assigns expression string.
ExpressionCalculatorFromExpression(expression string) (*ExpressionCalculator, error)
- expression: string - expression string.
ExpressionCalculatorFromExpression
Constructs this class and assigns token values.
ExpressionCalculatorFromTokens(originalTokens []*tokenizers.Token) *ExpressionCalculator
- expression: string - expression string.
- originalTokens: []*Token
Properties
AutoVariables
Gets the flag to turn on auto-creation of variables for a specified expression.
(c *ExpressionCalculator) AutoVariables() bool
- returns: bool - returns the flag to turn on auto-creation.
DefaultFunctions
List with default functions.
(c *ExpressionCalculator) DefaultFunctions() IFunctionCollection
- returns: IFunctionCollection - list with default functions.
DefaultVariables
List with default variables.
(c *ExpressionCalculator) DefaultVariables() IVariableCollection
- returns: IVariableCollection - list with default variables.
Expression
Expression string.
(c *ExpressionCalculator) Expression() string
- returns: string - expression string.
InitialTokens
List of original expression tokens.
(c *ExpressionCalculator) InitialTokens() []*ExpressionToken
- returns: []*ExpressionToken - list of original expression tokens.
OriginalTokens
List of expression tokens.
(c *ExpressionCalculator) OriginalTokens() []*Token
- returns: []*Token - list of expression tokens.
ResultTokens
List of processed expression tokens.
(c *ExpressionCalculator) ResultTokens() []*ExpressionToken
- returns: []*ExpressionToken - list of processed expression tokens.
VariantOperations
Gets the manager for operations on variant values.
(c *ExpressionCalculator) VariantOperations() IVariantOperations
- returns: IVariantOperations - manager for operations.
SetAutoVariables
Sets the flag to turn on auto-creation of variables for specified expression.
(c *ExpressionCalculator) SetAutoVariables(value bool)
- value: bool - flag to turn on auto-creation.
SetExpression
Gets the expression string.
(c *ExpressionCalculator) SetExpression(value string) error
- value: string - expression string.
- returns: error - error or nil if no errors occured.
SetOriginalTokens
Sets list of expression tokens.
(c *ExpressionCalculator) SetOriginalTokens(value []*Token)
- value: []*Token - list of expression tokens.
SetVariantOperations
Sets the manager for operations on variant values.
(c *ExpressionCalculator) SetVariantOperations(value IVariantOperations)
- value: IVariantOperations - manager for operations.
Methods
Clear
Cleans up this calculator from all data.
(c *ExpressionCalculator) Clear()
CreateVariables
Cleans up this calculator from all data.
(c *ExpressionCalculator) CreateVariables(vars IVariantOperations)
- variables: IVariantOperations - list of variables to be populated.
Evaluate
Evaluates this expression using default variables and functions.
(c *ExpressionCalculator) Evaluate() (*Variant, error)
- returns: (*Variant, error) - evaluation result.
EvaluateUsingVariables
Evaluates this expression using specified variables.
(c *ExpressionCalculator) EvaluateUsingVariables(vars IVariantOperations) (*Variant, error)
- variables: IVariantOperations - list of variables.
- returns: (*Variant, error) - evaluation result.
evaluateWithVariablesAndFunctions
Evaluates this expression using specified variables and functions.
(c *ExpressionCalculator) EvaluateUsingVariablesAndFunctions(vars IVariantOperations, funcs IFunctionCollection) (*Variant, error)
- variables: IVariantOperations - list of variables.
- functions: IFunctionCollection - list of functions
- returns: (*Variant, error) - evaluation result.