public static string ToString(CompareOperator op)
        {
            switch (op)
            {
            case CompareOperator.Equals:
                return("==");

            case CompareOperator.NotEquals:
                return("!=");

            case CompareOperator.LessThan:
                return("<");

            case CompareOperator.LessThanOrEquals:
                return("<=");

            case CompareOperator.GreaterThan:
                return(">");

            case CompareOperator.GreaterThanOrEquals:
                return(">=");

            case CompareOperator.StartsWith:
                return("|>");

            case CompareOperator.Contains:
                return(":");

            case CompareOperator.EndsWith:
                return(">|");

            default:
                throw new NotImplementedException(op.ToString());
            }
        }
        public static string ToStatementString(this CompareOperator Operator)
        {
            switch (Operator)
            {
            case CompareOperator.LT:
                return("<");

            case CompareOperator.LE:
                return("<=");

            case CompareOperator.GT:
                return(">");

            case CompareOperator.GE:
                return(">=");

            case CompareOperator.EQ:
                return("==");

            case CompareOperator.NE:
                return("!=");

            case CompareOperator.IS:
                return("is");

            case CompareOperator.none:
                return("");

            default:
                throw new ApplicationException("unsupported enum " + Operator.ToString());
            }
        }
Beispiel #3
0
 /// <summary>
 /// Renders a comaprison operator
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="op"></param>
 protected virtual void Operator(StringBuilder builder, CompareOperator op)
 {
     if (op == CompareOperator.Equal)
     {
         builder.Append("=");
     }
     else if (op == CompareOperator.NotEqual)
     {
         builder.Append("<>");
     }
     else if (op == CompareOperator.Greater)
     {
         builder.Append(">");
     }
     else if (op == CompareOperator.Less)
     {
         builder.Append("<");
     }
     else if (op == CompareOperator.LessOrEqual)
     {
         builder.Append("<=");
     }
     else if (op == CompareOperator.GreaterOrEqual)
     {
         builder.Append(">=");
     }
     else if (op == CompareOperator.Like)
     {
         builder.Append("like");
     }
     else
     {
         throw new InvalidQueryException("Unkown operator: " + op.ToString());
     }
 }
Beispiel #4
0
        // 支持的比较操作
        public virtual bool Evaluate(CompareOperator compareOperator, bool booleanValue)
        {
            bool condition = false;

            bool lhs = Value;
            bool rhs = booleanValue;

            switch (compareOperator)
            {
            // 相等
            case CompareOperator.Equals:
                condition = lhs == rhs;
                break;

            // 不相等
            case CompareOperator.NotEquals:
                condition = lhs != rhs;
                break;

            default:
                Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
                break;
            }

            return(condition);
        }
Beispiel #5
0
        private static bool CompareSingle <T>(T left, T right, CompareOperator cOp) where T : IComparable <T>
        {
            // Implement dynamic comparison to validate V5 comparison
            int cmp = left.CompareTo(right);

            switch (cOp)
            {
            case CompareOperator.Equal:
                return(cmp == 0);

            case CompareOperator.NotEqual:
                return(cmp != 0);

            case CompareOperator.GreaterThan:
                return(cmp > 0);

            case CompareOperator.GreaterThanOrEqual:
                return(cmp >= 0);

            case CompareOperator.LessThan:
                return(cmp < 0);

            case CompareOperator.LessThanOrEqual:
                return(cmp <= 0);
            }

            throw new NotImplementedException(cOp.ToString());
        }
Beispiel #6
0
 /// <summary>
 /// Get the display name for the specified compare operator.
 /// </summary>
 /// <param name="compareOperator">The operator.</param>
 /// <returns>The display name for the operator.</returns>
 private static string GetOperatorDisplay(CompareOperator compareOperator)
 {
     return(typeof(CompareOperator)
            .GetField(compareOperator.ToString())
            .GetCustomAttributes(typeof(DisplayAttribute), false)
            .Cast <DisplayAttribute>()
            .Single()
            .GetName());
 }
Beispiel #7
0
        public virtual bool Evaluate(CompareOperator compareOperator, T value)
        {
            bool condition = false;

            switch (compareOperator)
            {
            case CompareOperator.Equals:
                condition = Equals(Value, value);// Value.Equals(value);
                break;

            case CompareOperator.NotEquals:
                condition = !Equals(Value, value);
                break;

            default:
                Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
                break;
            }

            return(condition);
        }
        public virtual bool Evaluate(CompareOperator compareOperator, AudioSource value)
        {
            bool condition = false;

            switch (compareOperator)
            {
            case CompareOperator.Equals:
                condition = Value == value;
                break;

            case CompareOperator.NotEquals:
                condition = Value != value;
                break;

            default:
                Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
                break;
            }

            return(condition);
        }
Beispiel #9
0
        public virtual bool Evaluate(CompareOperator compareOperator, int integerValue)
        {
            int lhs = Value;
            int rhs = integerValue;

            bool condition = false;

            switch (compareOperator)
            {
            case CompareOperator.Equals:
                condition = lhs == rhs;
                break;

            case CompareOperator.NotEquals:
                condition = lhs != rhs;
                break;

            case CompareOperator.LessThan:
                condition = lhs < rhs;
                break;

            case CompareOperator.GreaterThan:
                condition = lhs > rhs;
                break;

            case CompareOperator.LessThanOrEquals:
                condition = lhs <= rhs;
                break;

            case CompareOperator.GreaterThanOrEquals:
                condition = lhs >= rhs;
                break;

            default:
                Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
                break;
            }

            return(condition);
        }
Beispiel #10
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0}, ", Group);
            switch (Group)
            {
            case Group.Branch:
                switch (SubGroupBranch)
                {
                case GroupBranch.Goto: sb.AppendFormat("{0}, {1}", BranchOptionsGoto.ToString(), PrintOperands()); break;

                case GroupBranch.Jump: sb.AppendFormat("{0}, {1}", BranchOptionsJump.ToString(), PrintOperands()); break;

                case GroupBranch.Play: sb.AppendFormat("{0}, {1}", BranchOptionsPlay.ToString(), PrintOperands()); break;

                default: sb.Append("???, "); break;
                }
                break;

            case Group.Compare:
                sb.AppendFormat("{0}, {1}", CompareOperator.ToString(), PrintOperands());
                break;

            case Group.Set:
                switch (SubGroupSet)
                {
                case GroupSet.Set: sb.AppendFormat("{0}, {1}", SetOperator.ToString(), PrintOperands()); break;

                case GroupSet.SetSystem: sb.AppendFormat("{0}, {1}", SetOperator.ToString(), PrintOperands()); break;

                default: sb.Append("???, "); break;
                }
                break;
            }
            return(sb.ToString());
        }
        public virtual bool Evaluate(CompareOperator compareOperator, GameObject gameObjectValue)
        {
            GameObject lhs = Value;
            GameObject rhs = gameObjectValue;

            bool condition = false;

            switch (compareOperator)
            {
            case CompareOperator.Equals:
                condition = lhs == rhs;
                break;

            case CompareOperator.NotEquals:
                condition = lhs != rhs;
                break;

            default:
                Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
                break;
            }

            return(condition);
        }
		/// <summary>
		/// Renders a comaprison operator
		/// </summary>
		/// <param name="builder"></param>
		/// <param name="op"></param>
		protected virtual void Operator(StringBuilder builder, CompareOperator op)
		{
			if (op == CompareOperator.Equal)
			{
				builder.Append("=");
			}
			else if (op == CompareOperator.NotEqual)
			{
				builder.Append("<>");
			}
			else if (op == CompareOperator.Greater)
			{
				builder.Append(">");
			}
			else if (op == CompareOperator.Less)
			{
				builder.Append("<");
			}
			else if (op == CompareOperator.LessOrEqual)
			{
				builder.Append("<=");
			}
			else if (op == CompareOperator.GreaterOrEqual)
			{
				builder.Append(">=");
			}
			else if (op == CompareOperator.Like)
			{
				builder.Append("like");
			}
			else if (op == CompareOperator.Is)
			{
				builder.Append(" is ");
			}
			else if (op == CompareOperator.IsNot)
			{
				builder.Append(" is not ");
			}
			else
			{
				throw new InvalidQueryException("Unkown operator: " + op.ToString());
			}
		}
Beispiel #13
0
        public void WhereBlock(XArray left, String8 rightValue, bool ignoreCase, CompareOperator cOp, BitVector vector)
        {
            if (rightValue.Length == 0) return;
            if (cOp != CompareOperator.Contains && cOp != CompareOperator.Equal && cOp != CompareOperator.StartsWith) throw new NotImplementedException(cOp.ToString());

            String8[] leftArray = (String8[])left.Array;
            String8 last = leftArray[left.Selector.EndIndexExclusive - 1];
            String8 all = new String8(last.Array, 0, last.Index + last.Length);
            Allocator.AllocateToSize(ref _indicesBuffer, 1024);

            int nextIndex = leftArray[left.Selector.StartIndexInclusive].Index;
            int nextRowIndex = left.Selector.StartIndexInclusive + 1;

            while (true)
            {
                // Find a batch of matches
                int countFound;
                if (s_IndexOfAllNative != null)
                {
                    countFound = s_IndexOfAllNative(all.Array, nextIndex, all.Length - nextIndex, rightValue.Array, rightValue.Index, rightValue.Length, ignoreCase, _indicesBuffer);
                }
                else
                {
                    countFound = all.IndexOfAll(rightValue, nextIndex, true, _indicesBuffer);
                }

                // Map the indices found to rows
                if (cOp == CompareOperator.Contains)
                {
                    IndicesToContainsRows(leftArray, rightValue.Length, ref nextRowIndex, left.Selector.StartIndexInclusive, left.Selector.EndIndexExclusive, countFound, vector);
                }
                else if (cOp == CompareOperator.Equal)
                {
                    IndicesToEqualsRows(leftArray, rightValue.Length, ref nextRowIndex, left.Selector.StartIndexInclusive, left.Selector.EndIndexExclusive, countFound, vector);
                }
                else // if(cOp == CompareOperator.StartsWith)
                {
                    IndicesToStartsWithRows(leftArray, rightValue.Length, ref nextRowIndex, left.Selector.StartIndexInclusive, left.Selector.EndIndexExclusive, countFound, vector);
                }

                // Find the next index to search for matches from
                if (countFound < _indicesBuffer.Length) break;
                nextIndex = _indicesBuffer[countFound - 1] + 1;
            }
        }
 /// <summary>
 /// Get the display name for the specified compare operator.
 /// </summary>
 /// <param name="compareOperator">The operator.</param>
 /// <returns>The display name for the operator.</returns>
 private static string GetOperatorDisplay(CompareOperator compareOperator)
 {
     return typeof(CompareOperator)
         .GetField(compareOperator.ToString())
         .GetCustomAttributes(typeof(DisplayAttribute), false)
         .Cast<DisplayAttribute>()
         .Single()
         .GetName();
 }