Exemplo n.º 1
0
        private uint ReadTagSlow()
        {
            if (IsAtEnd)
            {
                return(0);
            }

            uint tag = ReadRawVarint32();

            if (tag == 0)
            {
                // If we actually read zero, that's not a valid tag.
                throw InvalidProtocolBufferException.InvalidTag();
            }

            return(tag);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Reads a field tag, returning the tag of 0 for "end of stream".
 /// </summary>
 /// <remarks>
 /// If this method returns 0, it doesn't necessarily mean the end of all
 /// the data in this CodedInputStream; it may be the end of the logical stream
 /// for an embedded message, for example.
 /// </remarks>
 /// <returns>The next field tag, or 0 for end of stream. (0 is never a valid tag.)</returns>
 public uint ReadTag()
 {
     // Optimize for the incredibly common case of having at least one byte left in the buffer,
     // and this byte being enough to get the tag. This will be true for fields up to 31.
     if (bufferPos + 1 <= bufferSize)
     {
         uint tag = buffer[bufferPos];
         if (tag < 128)
         {
             bufferPos++;
             if (tag == 0)
             {
                 // If we actually read zero, that's not a valid tag.
                 throw InvalidProtocolBufferException.InvalidTag();
             }
             return(tag);
         }
     }
     return(ReadTagSlow());
 }