This class is used internally by the Protocol Buffer Library and generated message implementations. It is public only for the sake of those generated messages. Others should not use this class directly.

This class contains constants and helper functions useful for dealing with the Protocol Buffer wire format.

Exemplo n.º 1
0
        private void SkipGroup(uint startGroupTag)
        {
            // Note: Currently we expect this to be the way that groups are read. We could put the recursion
            // depth changes into the ReadTag method instead, potentially...
            recursionDepth++;
            if (recursionDepth >= recursionLimit)
            {
                throw InvalidProtocolBufferException.RecursionLimitExceeded();
            }
            uint tag;

            while (true)
            {
                tag = ReadTag();
                if (tag == 0)
                {
                    throw InvalidProtocolBufferException.TruncatedMessage();
                }
                // Can't call SkipLastField for this case- that would throw.
                if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup)
                {
                    break;
                }
                // This recursion will allow us to handle nested groups.
                SkipLastField();
            }
            int startField = WireFormat.GetTagFieldNumber(startGroupTag);
            int endField   = WireFormat.GetTagFieldNumber(tag);

            if (startField != endField)
            {
                throw new InvalidProtocolBufferException(
                          String.Format("Mismatched end-group tag. Started with field {0}; ended with field {1}", startField, endField));
            }
            recursionDepth--;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Encodes and writes a tag.
 /// </summary>
 /// <param name="fieldNumber">The number of the field to write the tag for</param>
 /// <param name="type">The wire format type of the tag to write</param>
 public void WriteTag(int fieldNumber, WireFormat.WireType type)
 {
     WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Encodes and writes a tag.
 /// </summary>
 /// <param name="fieldNumber">The number of the field to write the tag for</param>
 /// <param name="type">The wire format type of the tag to write</param>
 public void WriteTag(int fieldNumber, WireFormat.WireType type)
 {
     WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Encodes and writes a tag.
 /// </summary>
 public static void WriteTag(ref Span <byte> buffer, ref WriterInternalState state, int fieldNumber, WireFormat.WireType type)
 {
     WriteRawVarint32(ref buffer, ref state, WireFormat.MakeTag(fieldNumber, type));
 }
Exemplo n.º 5
0
 internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension)
 {
     return(extensions.TryGetValue(new ObjectIntPair <Type>(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension));
 }
 /// <summary>
 /// Computes the number of bytes that would be needed to encode a tag.
 /// </summary>
 public static int ComputeTagSize(int fieldNumber)
 {
     return(ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, 0)));
 }
Exemplo n.º 7
0
 public static int ComputeTagSize(int fieldNumber)
 {
     return(CodedOutputStream.ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.Varint)));
 }