public static Node ReadSimpleComparison(Node condition, out CmpOp cmpOp, out ushort argCount) { var target = condition.Children.First.Value; argCount = (ushort)target.Children.Count; switch (target.Text) { case "=": case "equals": cmpOp = CmpOp.Equal; break; case "not-equals": case "<>": cmpOp = CmpOp.NotEqual; break; case "<": cmpOp = CmpOp.Less; break; case ">": cmpOp = CmpOp.Greater; break; default: throw new Exception("Invalid comparator. Investigate optimisation pre-check."); } return(Node.Repack(target.Children)); }
/** * When the second argument Is a string, many things are possible */ private static I_MatchPredicate CreateGeneralMatchPredicate(StringEval stringEval) { String value = stringEval.StringValue; CmpOp optr = CmpOp.GetOperator(value); value = value.Substring(optr.Length); bool?boolVal = ParseBoolean(value); if (boolVal != null) { return(new BooleanMatcher(boolVal == true?true:false, optr)); } Double doubleVal = OperandResolver.ParseDouble(value); if (!double.IsNaN(doubleVal)) { return(new NumberMatcher(doubleVal, optr)); } //else - just a plain string with no interpretation. return(new StringMatcher(value, optr)); }
/** * When the second argument is a string, many things are possible */ private static IMatchPredicate CreateGeneralMatchPredicate(StringEval stringEval) { String value = stringEval.StringValue; CmpOp operator1 = CmpOp.GetOperator(value); value = value.Substring(operator1.Length); bool?booleanVal = ParseBoolean(value); if (booleanVal != null) { return(new BooleanMatcher(booleanVal.Value, operator1)); } Double doubleVal = OperandResolver.ParseDouble(value); if (!double.IsNaN(doubleVal)) { return(new NumberMatcher(doubleVal, operator1)); } ErrorEval ee = ParseError(value); if (ee != null) { return(new ErrorMatcher(ee.ErrorCode, operator1)); } //else - just a plain string with no interpretation. return(new StringMatcher(value, operator1)); }
public StringMatcher(String value, CmpOp optr) : base(optr) { _value = value; _operator = optr; switch (optr.Code) { case CmpOp.NONE: case CmpOp.EQ: case CmpOp.NE: _pattern = GetWildCardPattern(value); break; default: _pattern = null; break; } }
public static FuncDef ToFunction(this CmpOp cmpOp) { switch (cmpOp) { case CmpOp.Equal: return(FuncDef.Equal); case CmpOp.NotEqual: return(FuncDef.NotEqual); case CmpOp.Less: return(FuncDef.LessThan); case CmpOp.Greater: return(FuncDef.GreaterThan); default: throw new ArgumentOutOfRangeException(nameof(cmpOp), cmpOp, null); } }
public StringMatcher(String value, CmpOp optr):base(optr) { _value = value; _operator = optr; switch (optr.Code) { case CmpOp.NONE: case CmpOp.EQ: case CmpOp.NE: _pattern = GetWildCardPattern(value); break; default: _pattern = null; break; } }
public NumberMatcher(double value, CmpOp optr) : base(optr) { _value = value; }
public BooleanMatcher(bool value, CmpOp optr) : base(optr) { _value = BoolToInt(value); }
protected MatcherBase(CmpOp operator1) { _operator = operator1; }
public ErrorMatcher(int errorCode, CmpOp operator1) : base(operator1) { ; _value = errorCode; }
public CompareExpression(IExpression left, CmpOp oper, IExpression right) { this.left = left; this.oper = oper; this.right = right; }
public void SetOper(CmpOp oper) { this.oper = oper; }
public MatcherBase(CmpOp operator1) { _operator = operator1; }
public BooleanMatcher(bool value, CmpOp optr) { _value = BoolToInt(value); _operator = optr; }
protected MatcherBase(CmpOp operator1) { _operator = operator1; }
public NumberMatcher(double value, CmpOp optr) : base(optr) { _value = value; }
public IfVersionAttribute(CmpOp Comparer, int Version) { this.Comparer = Comparer; this.Version = Version; }
public BooleanMatcher(bool value,CmpOp optr) { _value = BoolToInt(value); _operator = optr; }
public NumberMatcher(double value, CmpOp optr) { _value = value; _operator = optr; }
/* A Z L O G F I L T E R C O N D I T I O N */ /*---------------------------------------------------------------------------- * %%Function: AzLogFilterCondition * %%Qualified: AzLog.AzLogFilter.AzLogFilterCondition.AzLogFilterCondition * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public AzLogFilterCondition(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource dsLeft, AzLogEntry.LogColumn lc, CmpOp cmpop, DateTime dttmValueRight) { _Init(vt, dsLeft, lc, cmpop, dttmValueRight); }
/* _ I N I T */ /*---------------------------------------------------------------------------- * %%Function: _Init * %%Qualified: AzLog.AzLogFilter.AzLogFilterCondition._Init * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ private void _Init(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource dsLeft, AzLogEntry.LogColumn lc, CmpOp cmpop, DateTime dttmValueRight) { m_azlfvLHS = new AzLogFilterValue(vt, dsLeft, lc); m_azlfvRHS = new AzLogFilterValue(dttmValueRight); m_cmpop = cmpop; }
public ErrorMatcher(int errorCode, CmpOp operator1) : base(operator1) { ; _value = errorCode; }
/// <summary> /// Encode a compound compare /// </summary> /// <param name="operation">compare to do</param> /// <param name="argCount">number of value-stack args to compare</param> /// <param name="opCodeCount">opcodes to jump relative down if top if comparison result is false</param> public void CompoundCompareJump(CmpOp operation, ushort argCount, ushort opCodeCount) { _opcodes.Add(NanTags.EncodeOpcode('C', (byte)operation, argCount, opCodeCount)); }
public BooleanMatcher(bool value, CmpOp optr) : base(optr) { _value = BoolToInt(value); }
/* A Z L O G F I L T E R C O N D I T I O N */ /*---------------------------------------------------------------------------- %%Function: AzLogFilterCondition %%Qualified: AzLog.AzLogFilter.AzLogFilterCondition.AzLogFilterCondition %%Contact: rlittle ----------------------------------------------------------------------------*/ public AzLogFilterCondition(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource dsLeft, AzLogEntry.LogColumn lc, CmpOp cmpop, DateTime dttmValueRight) { _Init(vt, dsLeft, lc, cmpop, dttmValueRight); }
/* _ I N I T */ /*---------------------------------------------------------------------------- %%Function: _Init %%Qualified: AzLog.AzLogFilter.AzLogFilterCondition._Init %%Contact: rlittle ----------------------------------------------------------------------------*/ private void _Init(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource dsLeft, AzLogEntry.LogColumn lc, CmpOp cmpop, DateTime dttmValueRight) { m_azlfvLHS = new AzLogFilterValue(vt, dsLeft, lc); m_azlfvRHS = new AzLogFilterValue(dttmValueRight); m_cmpop = cmpop; }
public NumberMatcher(double value, CmpOp optr) { _value = value; _operator = optr; }