/// <summary>
        /// Adds the entries from the given input stream, decoding them with the specified codec.
        /// </summary>
        /// <param name="input">The input stream to read from.</param>
        /// <param name="codec">The codec to use in order to read each entry.</param>
        public void AddEntriesFrom(CodedInputStream input, FieldCodec <T> codec)
        {
            // TODO: Inline some of the Add code, so we can avoid checking the size on every
            // iteration.
            uint tag    = input.LastTag;
            var  reader = codec.ValueReader;

            // Non-nullable value types can be packed or not.
            if (FieldCodec <T> .IsPackedRepeatedField(tag))
            {
                int length = input.ReadLength();
                if (length > 0)
                {
                    int oldLimit = input.PushLimit(length);
                    while (!input.ReachedLimit)
                    {
                        Add(reader(input));
                    }
                    input.PopLimit(oldLimit);
                }
                // Empty packed field. Odd, but valid - just ignore.
            }
            else
            {
                // Not packed... (possibly not packable)
                do
                {
                    Add(reader(input));
                } while (input.MaybeConsumeTag(tag));
            }
        }
Example #2
0
        public void AddEntriesFrom(CodedInputStream input, FieldCodec <T> codec)
        {
            // TODO: Inline some of the Add code, so we can avoid checking the size on every
            // iteration and the mutability.
            uint tag    = input.LastTag;
            var  reader = codec.ValueReader;

            // Value types can be packed or not.
            if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
            {
                int length = input.ReadLength();
                if (length > 0)
                {
                    int oldLimit = input.PushLimit(length);
                    while (!input.ReachedLimit)
                    {
                        Add(reader(input));
                    }
                    input.PopLimit(oldLimit);
                }
                // Empty packed field. Odd, but valid - just ignore.
            }
            else
            {
                // Not packed... (possibly not packable)
                do
                {
                    Add(reader(input));
                } while (input.MaybeConsumeTag(tag));
            }
        }
Example #3
0
            /// <exception cref="Com.Google.Protobuf.InvalidProtocolBufferException"/>
            private ConcatVectorTable(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
            {
                InitFields();
                int mutable_bitField0_ = 0;

                UnknownFieldSet.Builder unknownFields = UnknownFieldSet.NewBuilder();
                try
                {
                    bool done = false;
                    while (!done)
                    {
                        int tag = input.ReadTag();
                        switch (tag)
                        {
                        case 0:
                        {
                            done = true;
                            break;
                        }

                        default:
                        {
                            if (!ParseUnknownField(input, unknownFields, extensionRegistry, tag))
                            {
                                done = true;
                            }
                            break;
                        }

                        case 8:
                        {
                            if (!((mutable_bitField0_ & unchecked ((int)(0x00000001))) == unchecked ((int)(0x00000001))))
                            {
                                dimensionSize_      = new List <int>();
                                mutable_bitField0_ |= unchecked ((int)(0x00000001));
                            }
                            dimensionSize_.Add(input.ReadInt32());
                            break;
                        }

                        case 10:
                        {
                            int length = input.ReadRawVarint32();
                            int limit  = input.PushLimit(length);
                            if (!((mutable_bitField0_ & unchecked ((int)(0x00000001))) == unchecked ((int)(0x00000001))) && input.GetBytesUntilLimit() > 0)
                            {
                                dimensionSize_      = new List <int>();
                                mutable_bitField0_ |= unchecked ((int)(0x00000001));
                            }
                            while (input.GetBytesUntilLimit() > 0)
                            {
                                dimensionSize_.Add(input.ReadInt32());
                            }
                            input.PopLimit(limit);
                            break;
                        }

                        case 18:
                        {
                            if (!((mutable_bitField0_ & unchecked ((int)(0x00000002))) == unchecked ((int)(0x00000002))))
                            {
                                factorTable_        = new List <ConcatVectorProto.ConcatVector>();
                                mutable_bitField0_ |= unchecked ((int)(0x00000002));
                            }
                            factorTable_.Add(input.ReadMessage(ConcatVectorProto.ConcatVector.Parser, extensionRegistry));
                            break;
                        }
                        }
                    }
                }
                catch (InvalidProtocolBufferException e)
                {
                    throw e.SetUnfinishedMessage(this);
                }
                catch (IOException e)
                {
                    throw new InvalidProtocolBufferException(e.Message).SetUnfinishedMessage(this);
                }
                finally
                {
                    if (((mutable_bitField0_ & unchecked ((int)(0x00000001))) == unchecked ((int)(0x00000001))))
                    {
                        dimensionSize_ = Java.Util.Collections.UnmodifiableList(dimensionSize_);
                    }
                    if (((mutable_bitField0_ & unchecked ((int)(0x00000002))) == unchecked ((int)(0x00000002))))
                    {
                        factorTable_ = Java.Util.Collections.UnmodifiableList(factorTable_);
                    }
                    this.unknownFields = unknownFields.Build();
                    MakeExtensionsImmutable();
                }
            }
Example #4
0
        public void AddEntriesFrom(CodedInputStream input, FieldCodec <T> codec)
        {
            uint lastTag = input.LastTag;
            Func <CodedInputStream, T> valueReader = codec.ValueReader;

            if (RepeatedField <T> .smethod_1(typeof(T).TypeHandle).IsValueType())
            {
                goto IL_79;
            }
            goto IL_189;
            uint arg_147_0;

            while (true)
            {
IL_142:
                uint num;
                switch ((num = (arg_147_0 ^ 349581016u)) % 13u)
                {
                case 0u:
                    arg_147_0 = ((input.MaybeConsumeTag(lastTag) ? 2792542167u : 2493560502u) ^ num * 4283985340u);
                    continue;

                case 1u:
                    arg_147_0 = (((WireFormat.GetTagWireType(lastTag) == WireFormat.WireType.LengthDelimited) ? 4182580420u : 2445968179u) ^ num * 3573087188u);
                    continue;

                case 2u:
                    arg_147_0 = (num * 2407926176u ^ 627495612u);
                    continue;

                case 3u:
                {
                    int num2;
                    arg_147_0 = (((num2 > 0) ? 704969730u : 1347903514u) ^ num * 2106852334u);
                    continue;
                }

                case 4u:
                {
                    int oldLimit;
                    input.PopLimit(oldLimit);
                    arg_147_0 = (num * 2913868755u ^ 1655185686u);
                    continue;
                }

                case 6u:
                {
                    int num2;
                    int oldLimit = input.PushLimit(num2);
                    arg_147_0 = (num * 3972840873u ^ 320789690u);
                    continue;
                }

                case 7u:
                    goto IL_79;

                case 8u:
                    this.Add(valueReader(input));
                    arg_147_0 = 1293084732u;
                    continue;

                case 9u:
                    arg_147_0 = ((!input.ReachedLimit) ? 862879642u : 1176527045u);
                    continue;

                case 10u:
                    return;

                case 11u:
                    goto IL_189;

                case 12u:
                {
                    int num2 = input.ReadLength();
                    arg_147_0 = (num * 1888486294u ^ 430467554u);
                    continue;
                }
                }
                break;
            }
            return;

IL_79:
            arg_147_0 = 431838837u;
            goto IL_142;
IL_189:
            this.Add(valueReader(input));
            arg_147_0 = 320588544u;
            goto IL_142;
        }