![]() |
bcParser.NET
Math Parser for .NET
|
Classes | |
| interface | IFunction |
| IFunction interface represents a user defined callback function that takes n parameters. During evaluation of an expression, MathParser calls IFunction.Run(IParameter[] p) to request the value of the function when it takes parameters listed in p. For example, a user could define a function like this: public class MyFunc implements IFunction { public IConvertible Run(IParameter[] p){ return do_something_with_params( p ); } public int GetNumberOfParams(){ return 3; } } Another user defined function "if" could be used as "if(1,3,4)". In this case, implementation of IFunction.Run(IParameter[]) could return 3.0 if first parameter is >0 and it could return 4.0 if first parameter is 0 (false, to mimic "if" behavior). More... | |
| interface | IParameter |
| IParameter is used to supply a parameter value for a user defined function. The actual value may be calculated from a complicated sub expression. The value is not computed until you call the IParamater.GetValue() function(s). If you are going to use the value more than once, it is best to cache it in a local variable. The value can be numeric (DOUBLE_PARSER) or a String. If the string can be parsed as a double, then you can still call GetValueAsDouble on it and an automatic conversion will take place. All functions take an array of IParameter[] that enables them to query the current value of the parameters using the GetValue(), GetValueAsDouble() or GetValueAsString() functions. For most functions such as sin(x), cos(x) etc the length of IParameter[] p is 1. For some functions such as min(x,y), the length of IParameter[] p is 2. The built in IF(a, b,c) function has IParameter[] p length 3. The build in RDN() function has IParameter[] p length 0. For functions such as SUM(...) or CONCAT(...) the p.length (number of parameters that the function is taking) is determined at runtime. It can be 0 or more. See IFunction interface to learn more about defining functions and their parameter lengths. Example: public IConvertible Run(IParameter[] p) { double x__ = p[0].GetValueAsDouble(); return (Math.Exp(x__)+Math.Exp(-x__))*0.5; } br /> /summary> More... | |
| class | MathParser |
| MathParser class calculates the value of mathematical expressions given as strings at runtime. Expression can contain predefined or user defined variables and functions. More... | |
| class | Node |
| Support class that represents generic node, base for all nodes. More... | |
| class | OneParameterFunc |
| Base class for math parser functions that take 1 parameter. More... | |
| class | ParserException |
| ParserException is thrown by some methods of MathParser implementation if an expression cannot be parsed. These methods are: Parse(), Evaluate(), GetValue() /summary> More... | |
| class | StandardLib |
| A holder for the standard math parser functions. More... | |
| class | StrUtil |
| Basic String utilities. More... | |
| class | TwoParameterFunc |
| Base class for math parser functions that take 2 parameters. More... | |
| class | ZeroParameterFunc |
| Base class for functions that take no parameter. More... | |
Enumerations |
Functions | |
| delegate IConvertible | VariableDelegate (MathParser parser, String varName) |
| This delegate is used as a callback type that returns the values of variables when asked. This is useful when a variable value cannot be preset before evaluation and only if needed it will be provided. This is useful when for example the value comes from a database lookup. More... | |
|
strong |
The parser can use ampersand(&) or the plus(+) operator for string concatenations. You can set which one you want using StrConcatOperator property. The default is ampersand(&).
| delegate IConvertible Bestcode.MathParser.VariableDelegate | ( | MathParser | parser, |
| String | varName | ||
| ) |
This delegate is used as a callback type that returns the values of variables when asked. This is useful when a variable value cannot be preset before evaluation and only if needed it will be provided. This is useful when for example the value comes from a database lookup.
| parser | The MathParser instance making the request. |
| varName | The name of the variable to return the value for. |
1.8.11