IncreaseCurrentIndex() public méthode

public IncreaseCurrentIndex ( ) : CobarHint
Résultat CobarHint
Exemple #1
0
        /// <exception cref="System.SqlSyntaxErrorException" />
        public override void Process(CobarHint hint, string hintName, string sql)
        {
            string[] columns;
            if (NextChar(hint, sql) == '[')
            {
                hint.IncreaseCurrentIndex();
                columns = Convert2String(ParseArray(hint, sql, -1));
            }
            else
            {
                columns    = new string[1];
                columns[0] = (string)ParsePrimary(hint, sql);
            }
            object[][] values;
            switch (NextChar(hint, sql))
            {
            case '[':
            {
                if (columns.Length == 1)
                {
                    hint.IncreaseCurrentIndex();
                    var vs = ParseArray(hint, sql, -1);
                    values = new object[vs.Length][];
                    for (var i = 0; i < vs.Length; ++i)
                    {
                        values[i] = new object[1] {
                            vs[i]
                        };
                        //values[i][0] = vs[i];
                    }
                }
                else
                {
                    values = ParseArrayArray(hint, sql, columns.Length);
                }
                break;
            }

            default:
            {
                if (columns.Length == 1)
                {
                    values       = new object[1][] { new object[1] };
                    values[0][0] = ParsePrimary(hint, sql);
                }
                else
                {
                    throw new SqlSyntaxErrorException("err for partitionOperand: " + sql);
                }
                break;
            }
            }
            hint.PartitionOperand = new Pair <string[], object[][]>(columns, values);
            if (CurrentChar(hint, sql) == ')')
            {
                hint.IncreaseCurrentIndex();
            }
        }
        /// <exception cref="System.SqlSyntaxErrorException" />
        public override void Process(CobarHint hint, string hintName, string sql)
        {
            string[] columns;
            if (NextChar(hint, sql) == '[')
            {
                hint.IncreaseCurrentIndex();
                columns = Convert2String(ParseArray(hint, sql, -1));
            }
            else
            {
                columns = new string[1];
                columns[0] = (string)ParsePrimary(hint, sql);
            }
            object[][] values;
            switch (NextChar(hint, sql))
            {
                case '[':
                {
                    if (columns.Length == 1)
                    {
                        hint.IncreaseCurrentIndex();
                        var vs = ParseArray(hint, sql, -1);
                        values = new object[vs.Length][];
                        for (var i = 0; i < vs.Length; ++i)
                        {
                            values[i] = new object[1] {vs[i]};
                            //values[i][0] = vs[i];
                        }
                    }
                    else
                    {
                        values = ParseArrayArray(hint, sql, columns.Length);
                    }
                    break;
                }

                default:
                {
                    if (columns.Length == 1)
                    {
                        values = new object[1][] {new object[1]};
                        values[0][0] = ParsePrimary(hint, sql);
                    }
                    else
                    {
                        throw new SqlSyntaxErrorException("err for partitionOperand: " + sql);
                    }
                    break;
                }
            }
            hint.PartitionOperand = new Pair<string[], object[][]>(columns, values);
            if (CurrentChar(hint, sql) == ')')
            {
                hint.IncreaseCurrentIndex();
            }
        }
Exemple #3
0
        /// <summary>
        ///     current char is char after '[', after call, current char is char after
        ///     ']'
        /// </summary>
        /// <param name="len">less than 0 for array length unknown</param>
        /// <exception cref="System.SqlSyntaxErrorException" />
        private object[] ParseArray(CobarHint hint, string sql, int len)
        {
            object[]       rst  = null;
            IList <object> list = null;

            if (len >= 0)
            {
                rst = new object[len];
            }
            else
            {
                list = new List <object>();
            }
            for (var i = 0;; ++i)
            {
                var obj = ParsePrimary(hint, sql);
                if (len >= 0)
                {
                    rst[i] = obj;
                }
                else
                {
                    list.Add(obj);
                }
                switch (CurrentChar(hint, sql))
                {
                case ']':
                {
                    hint.IncreaseCurrentIndex();
                    if (len >= 0)
                    {
                        return(rst);
                    }
                    return(list.ToArray());
                }

                case ',':
                {
                    hint.IncreaseCurrentIndex();
                    break;
                }

                default:
                {
                    throw new SqlSyntaxErrorException("err for partitionOperand array: " + sql);
                }
                }
            }
        }
Exemple #4
0
 private void SkipSpace(CobarHint hint, string sql)
 {
     var ci = hint.CurrentIndex;
     for (;;)
     {
         switch (sql[ci])
         {
             case ' ':
             case '\t':
             case '\n':
             case '\r':
             {
                 hint.IncreaseCurrentIndex();
                 ++ci;
                 break;
             }
             default:
             {
                 goto skip_break;
             }
         }
     }
     skip_break:
     ;
 }
Exemple #5
0
        private void SkipSpace(CobarHint hint, string sql)
        {
            var ci = hint.CurrentIndex;

            for (;;)
            {
                switch (sql[ci])
                {
                case ' ':
                case '\t':
                case '\n':
                case '\r':
                {
                    hint.IncreaseCurrentIndex();
                    ++ci;
                    break;
                }

                default:
                {
                    goto skip_break;
                }
                }
            }
skip_break:
            ;
        }
Exemple #6
0
        /// <summary>current char is '[[', after call, current char is char after ']]'</summary>
        /// <exception cref="System.SqlSyntaxErrorException" />
        private object[][] ParseArrayArray(CobarHint hint, string sql, int columnNum)
        {
            if (NextChar(hint, sql) == '[')
            {
                IList <object[]> list = new List <object[]>();
                for (;;)
                {
                    NextChar(hint, sql);
                    list.Add(ParseArray(hint, sql, columnNum));
                    var c = CurrentChar(hint, sql);
                    switch (c)
                    {
                    case ']':
                    {
                        hint.IncreaseCurrentIndex();
                        return(list.ToArray());
                    }

                    case ',':
                    {
                        NextChar(hint, sql);
                        break;
                    }

                    default:
                    {
                        throw new SqlSyntaxErrorException("err for partitionOperand array[]: " + sql);
                    }
                    }
                }
            }
            var rst = new[] { new object[columnNum] };

            rst[0] = ParseArray(hint, sql, columnNum);
            return(rst);
        }
Exemple #7
0
 /// <summary>current char is not separator</summary>
 protected internal virtual char NextChar(CobarHint hint, string sql)
 {
     SkipSpace(hint, sql);
     SkipSpace(hint.IncreaseCurrentIndex(), sql);
     return sql[hint.CurrentIndex];
 }
Exemple #8
0
 /// <summary>current char is not separator</summary>
 protected internal virtual char NextChar(CobarHint hint, string sql)
 {
     SkipSpace(hint, sql);
     SkipSpace(hint.IncreaseCurrentIndex(), sql);
     return(sql[hint.CurrentIndex]);
 }
        /// <summary>current char is '[[', after call, current char is char after ']]'</summary>
        /// <exception cref="System.SqlSyntaxErrorException" />
        private object[][] ParseArrayArray(CobarHint hint, string sql, int columnNum)
        {
            if (NextChar(hint, sql) == '[')
            {
                IList<object[]> list = new List<object[]>();
                for (;;)
                {
                    NextChar(hint, sql);
                    list.Add(ParseArray(hint, sql, columnNum));
                    var c = CurrentChar(hint, sql);
                    switch (c)
                    {
                        case ']':
                        {
                            hint.IncreaseCurrentIndex();
                            return list.ToArray();
                        }

                        case ',':
                        {
                            NextChar(hint, sql);
                            break;
                        }

                        default:
                        {
                            throw new SqlSyntaxErrorException("err for partitionOperand array[]: " + sql);
                        }
                    }
                }
            }
            var rst = new[] {new object[columnNum]};
            rst[0] = ParseArray(hint, sql, columnNum);
            return rst;
        }
        /// <summary>
        ///     current char is char after '[', after call, current char is char after
        ///     ']'
        /// </summary>
        /// <param name="len">less than 0 for array length unknown</param>
        /// <exception cref="System.SqlSyntaxErrorException" />
        private object[] ParseArray(CobarHint hint, string sql, int len)
        {
            object[] rst = null;
            IList<object> list = null;
            if (len >= 0)
            {
                rst = new object[len];
            }
            else
            {
                list = new List<object>();
            }
            for (var i = 0;; ++i)
            {
                var obj = ParsePrimary(hint, sql);
                if (len >= 0)
                {
                    rst[i] = obj;
                }
                else
                {
                    list.Add(obj);
                }
                switch (CurrentChar(hint, sql))
                {
                    case ']':
                    {
                        hint.IncreaseCurrentIndex();
                        if (len >= 0)
                            return rst;
                        return list.ToArray();
                    }
                    case ',':
                    {
                        hint.IncreaseCurrentIndex();
                        break;
                    }

                    default:
                    {
                        throw new SqlSyntaxErrorException("err for partitionOperand array: " + sql);
                    }
                }
            }
        }