コード例 #1
0
 public Task Write(NpgsqlTsQueryEmpty value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
 => Write((NpgsqlTsQuery)value, buf, lengthCache, parameter, async);
コード例 #2
0
        public bool Read(out NpgsqlTsQuery result)
        {
            result = null;

            if (_tokenPos == -1)
            {
                if (_buf.ReadBytesLeft < 4)
                {
                    return(false);
                }
                _numTokens  = _buf.ReadInt32();
                _bytesLeft -= 4;
                _tokenPos   = 0;
            }

            if (_numTokens == 0)
            {
                result = new NpgsqlTsQueryEmpty();
                _buf   = null;
                _nodes = null;
                return(true);
            }

            for (; _tokenPos < _numTokens; _tokenPos++)
            {
                if (_buf.ReadBytesLeft < Math.Min(_bytesLeft, MaxSingleTokenBytes))
                {
                    return(false);
                }

                int readPos = _buf.ReadPosition;

                bool isOper = _buf.ReadByte() == 2;
                if (isOper)
                {
                    NpgsqlTsQuery.NodeKind operKind = (NpgsqlTsQuery.NodeKind)_buf.ReadByte();
                    if (operKind == NpgsqlTsQuery.NodeKind.Not)
                    {
                        var node = new NpgsqlTsQueryNot(null);
                        InsertInTree(node);
                        _nodes.Push(new Tuple <NpgsqlTsQuery, int>(node, 0));
                    }
                    else
                    {
                        NpgsqlTsQuery node = null;

                        if (operKind == NpgsqlTsQuery.NodeKind.And)
                        {
                            node = new NpgsqlTsQueryAnd(null, null);
                        }
                        else if (operKind == NpgsqlTsQuery.NodeKind.Or)
                        {
                            node = new NpgsqlTsQueryOr(null, null);
                        }
                        else
                        {
                            PGUtil.ThrowIfReached();
                        }

                        InsertInTree(node);

                        _nodes.Push(new Tuple <NpgsqlTsQuery, int>(node, 2));
                        _nodes.Push(new Tuple <NpgsqlTsQuery, int>(node, 1));
                    }
                }
                else
                {
                    NpgsqlTsQueryLexeme.Weight weight = (NpgsqlTsQueryLexeme.Weight)_buf.ReadByte();
                    bool   prefix = _buf.ReadByte() != 0;
                    string str    = _buf.ReadNullTerminatedString();
                    InsertInTree(new NpgsqlTsQueryLexeme(str, weight, prefix));
                }

                _bytesLeft -= _buf.ReadPosition - readPos;
            }

            if (_nodes.Count != 0)
            {
                PGUtil.ThrowIfReached();
            }

            result = _value;
            _buf   = null;
            _nodes = null;
            _value = null;
            return(true);
        }
コード例 #3
0
 public int ValidateAndGetLength(NpgsqlTsQueryEmpty value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
 => ValidateAndGetLength((NpgsqlTsQuery)value, ref lengthCache, parameter);